Tutorial by Examples: df

// logger middlerware that logs time taken to process each request func Logger(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { startTime := time.Now() h.ServeHttp(w,r) endTime := time.Since(startTime) log...
Opening a stream fopen opens a file stream handle, which can be used with various functions for reading, writing, seeking and other functions on top of it. This value is of resource type, and cannot be passed to other threads persisting its functionality. $f = fopen("errors.log", "a...
First step of creating a plugin is creating the folder and file which the plugin will load from. Plugins are located in /wp-content/plugins/. The WordPress standard is to create a folder and filename that mirror each other like so: /wp-content/plugins/myplugin/ /wp-content/plugins/myplugin/myplu...
These are some of useful keyboard functions to automate the key pressing. typewrite('') #this will type the string on the screen where current window has focused. typewrite(['a','b','left','left','X','Y']) pyautogui.KEYBOARD_KEYS #get the list of all the keyboard_keys. pyautogui.hotkey('ct...
first add the OkHttp to the gradle build file of the app module compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.squareup.okhttp:okhttp:2.4.0' compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.0.2' Then make a class extending Application import android.app.Application; ...
A common mistake is to forget surrounding compound function arguments with parentheses, leading to type errors. # string_of_int 1+1;; Error: This expression has type string but an expression was expected of type int This is because of the precedence. In fact, the above evaluates to # (string...
Keychain allows to save items with special SecAccessControl attribute which will allow to get item from Keychain only after user will be authenticated with Touch ID (or passcode if such fallback is allowed). App is only notified whether the authentication was successful or not, whole UI is managed b...
(require '[clj-time.core :as t]) (def example-time (t/date-time 2016 12 5 4 3 27 456)) (t/year example-time) ;; 2016 (t/month example-time) ;; 12 (t/day example-time) ;; 5 (t/hour example-time) ;; 4 (t/minute example-time) ;; 3 (t/second example-time) ;; 27
This macro gives the output of a given line as the first argument of the next line function call. For e.g. (rename-keys (assoc {:a 1} :b 1) {:b :new-b})) Can't understand anything, right? Lets try again, with -> (-> {:a 1} (assoc :b 1) ;;(assoc map key val) (rena...
Data can be extracted from a blastdb using blastdbcmd which should be included in a blast installation. You can specify from the options below as part of -outfmt what metadata to include and in what order. From the man page: -outfmt <String> Output format, where the available format sp...
In the previous example, we didn't end up needing the parentheses, because they did not affect the meaning of the statement. However, they are often necessary in more complex expression, like the one below. In C: plus(a, take(b, c)); In Haskell this becomes: (plus a (take b c)) -- or equivale...
This example helper class interacts with the finger print manager and performs encryption and decryption of password. Please note that the method used for encryption in this example is AES. This is not the only way to encrypt and other examples exist. In this example the data is encrypted and decryp...
public class NetworkConnection : IDisposable { string _networkName; public NetworkConnection(string networkName, NetworkCredential credentials) { _networkName = networkName; var netResource = new NetResource() {...
As Dispose() and finalizers are aimed to different purposes, a class managing external memory-heavy resources should implement both of them. The consequence is writing the class so that it handles well two possible scenarios: When only the finalizer is invoked When Dispose() is invoked first and...
In certain cases (e.g. logging) it might be useful to run task and do not await for the result. The following extension allows to run task and continue execution of the rest code: public static class TaskExtensions { public static async void RunAndForget( this Task task, Action<E...
Block Size and Blocks in HDFS : HDFS has the concept of storing data in blocks whenever a file is loaded. Blocks are the physical partitions of data in HDFS ( or in any other filesystem, for that matter ). Whenever a file is loaded onto the HDFS, it is splitted physically (yes, the file is divi...
String hostName = args[0]; int portNumber = Integer.parseInt(args[1]); try ( Socket echoSocket = new Socket(hostName, portNumber); PrintWriter out = new PrintWriter(echoSocket.getOutputStream(), true); BufferedReader in = new BufferedReader( new Inpu...
As a workaround, you may use the wildfly-specific VFS api and write your own ResourceAcessor implementation, such as this one below. public class WildflyVFSClassLoaderResourceAccessor extends AbstractResourceAccessor { private ClassLoader classLoader; public WildflyVFSClassLoaderResou...
If you want to use Swift3.0 or Bitcode you can add this code in your podfile. post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['ENABLE_BITCODE'] = 'YES' config.build_settings['SWIFT...
In order to chain asynchronous operations and avoid a callback hell, Vala supports the yield statement. Used with an asynchronous invocation, it will pause the current coroutine until the call is completed and extract the result. Used alone, yield pause the current coroutine until it's being woken...

Page 19 of 21