Tutorial by Examples: ee

There are some functions to help tear down Free computations by interpreting them into another monad m: iterM :: (Functor f, Monad m) => (f (m a) -> m a) -> (Free f a -> m a) and foldFree :: Monad m => (forall x. f x -> m x) -> (Free f a -> m a). What are they doing? First l...
Self types can be used in traits and classes to define constraints on the concrete classes it is mixed to. It is also possible to use a different identifier for the this using this syntax (useful when outer object has to be referenced from an inner object). Assume you want to store some objects. Fo...
Firebase Crash Reporting automatically generates reports for fatal errors (or uncaught exceptions). You can create your custom report using: FirebaseCrash.report(new Exception("My first Android non-fatal error")); You can check in the log when FirebaseCrash initialized the module: ...
Problem: Vim users are not always happy. Solution: Make them happy. 7.4 :smile Note: Requires patch version ≥7.4.1005
textBox.SelectionStart = textBox.TextLength; textBox.ScrollToCaret(); Applying the same principle, SelectionStart can be set to 0 to scroll to the top or to a specific number to go to a specific character.
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ /$1/ [L,R=301] The first RewriteCond helps exclude the files. The second RewriteCond checks if there is already a trailing slash. If the case is so RewriteRule is not applied. If you have any URL that s...
This example will call the windows calculator. It's important to notice that the exit code will vary accordingly to the program/script that is being called. package process.example; import java.io.IOException; public class App { public static void main(String[] args) { try { ...
Window.h #include <QWidget> class Window : public QWidget { Q_OBJECT public: Window(QWidget *parent = Q_NULLPTR) : QWidget(parent) {} } main.cpp #include <QApplication> #include "Window.h" int main() { QApplication app; Window window; wi...
Specifying the -gui command line option when running an ANTLR grammar in the test rig will result in a window popping up with a visual representation of the parse tree. For example: Given the following grammar: JSON.g4 /** Taken from "The Definitive ANTLR 4 Reference" by Terence Parr */...
2.1.3 1. Preview Different Devices There is a preview panel at the right of the android studio. In thispanel there is a button with device name with which you are previewing the UI of your app like this . Click on small dropdown indicator of this and a floating panel will appear with all the pr...
Use the task dependencies. Depending on how your modules are set up, it may be either ./gradlew dependencies or to see the dependencies of module app use ./gradlew :app:dependencies The example following build.gradle file dependencies { compile 'com.android.support:design:23.2.1' compile...
Do not overcomplicate simple tasks. Most of the time you will need only: algebraic datatypes structural recursion monad-like api (map, flatMap, fold) There is plenty of complicated stuff in Scala, such as: Cake pattern or Reader Monad for Dependency Injection. Passing arbitrary values as...
Find meaningful names for computation units. Use for comprehensions or map to combine computations together. Let's say you have something like this: if (userAuthorized.nonEmtpy) { makeRequest().map { case Success(respone) => someProcessing(..) if (resendToUser) { ...
aiohttp provides asynchronous websockets. Python 3.x3.5 import asyncio from aiohttp import ClientSession with ClientSession() as session: async def hello_world(): websocket = await session.ws_connect("wss://echo.websocket.org") websocket.send_str("Hell...
Sometimes it's useful to check if a field is present or absent on your JSON to avoid some JSONException on your code. To achieve that, use the JSONObject#has(String) or the method, like on the following example: Sample JSON { "name":"James" } Java code String jsonStr...
The Keep-Alive extension to HTTP/1.0 and the persistent connection feature of HTTP/1.1 provide long-lived HTTP sessions which allow multiple requests to be sent over the same TCP connection. In some cases this has been shown to result in an almost 50% speedup in latency times for HTML documents ...
A common thought pattern for inexperienced Java programmers is that exceptions are "a problem" or "a burden" and the best way to deal with this is catch them all1 as soon as possible. This leads to code like this: .... try { InputStream is = new FileInputStream(fileName);...
Properties with notify:true also fires an event <link rel="import" href="../bower_components/paper-input/paper-input.html"> <dom-module id="property-change-event"> <template> <style></style> <paper-input id="input&quo...
Inline display elements, usually such as span or a, will include up to one white-space character before and after them in the document. In order to avoid very long lines in the markup (that are hard to read) and unintentional white-space (which affects formatting), the white-space can be commented o...
Consider this example function to check if a host is up: is_alive() { ping -c1 "$1" &> /dev/null } This function sends a single ping to the host specified by the first function parameter. The output and error output of ping are both redirected to /dev/null, so the functi...

Page 23 of 54