Tutorial by Examples: f

One package for line profiling is lineprof which is written and maintained by Hadley Wickham. Here is a quick demonstration of how it works with auto.arima in the forecast package: library(lineprof) library(forecast) l <- lineprof(auto.arima(AirPassengers)) shine(l) This will provide you...
If you want to display to your users meaningful errors instead of simple "sorry, something went wrong", Rails has a nice utility for the purpose. Open the file app/controllers/application_controller.rb and you should find something like this: class ApplicationController < ActionContro...
It is possible to limit the tests executed by manage.py test by specifying which modules should be discovered by the test runner: # Run only tests for the app names "app1" $ python manage.py test app1 # If you split the tests file into a module with several tests files for an app $ p...
Drupal Console The new CLI for Drupal. A tool to generate boilerplate code, interact with and debug Drupal. First, we need to install Drupal Console. Drupal Console is needed not only for this time, but for future installations. # Run this in your terminal to get the latest project version: cur...
<PROJECT_ROOT>\app\build.gradle is specific for app module. <PROJECT_ROOT>\build.gradle is a "Top-level build file" where you can add configuration options common to all sub-projects/modules. If you use another module in your project, as a local library you would have another...
/** * The buildscript {} block is where you configure the repositories and * dependencies for Gradle itself--meaning, you should not include dependencies * for your modules here. For example, this block includes the Android plugin for * Gradle as a dependency because it provides the addition...
/** * The first line in the build configuration applies the Android plugin for * Gradle to this build and makes the android {} block available to specify * Android-specific build options. */ apply plugin: 'com.android.application' /** * The android {} block is where you configure all...
Looping over an iterable defined inside of your viewmodel or passed through as a bindable (if a Custom Attribute or Custom Element) can be done like so. An array of string values export class MyViewModel { myIterable = ['String 1', 'String 2', 'String 3', 'String 4']; } <template> ...
Make sure to have a file input on your page: <input type="file" id="upload"> Then in JavaScript: document.getElementById('upload').addEventListener('change', readFileAsString) function readFileAsString() { var files = this.files; if (files.length === 0) { ...
Reading the contents of a file within a web application can be accomplished by utilizing the HTML5 File API. First, add an input with type="file" in your HTML: <input type="file" id="upload"> Next, we're going to add a change listener on the file-input. This e...
Dim extensions As New Dictionary(Of String, String) _ from { { "txt", "notepad" }, { "bmp", "paint" }, { "doc", "winword" } } This creates a dictionary and immediately fills it with three KeyValuePairs. You can also add new val...
For named (non-anonymous) functions, you can break when the function is executed. debug(functionName); The next time functionName function runs, the debugger will stop on its first line.
From your Mac, download and install Xcode from the Mac App Store following this link. After the installation is complete, open Xcode and select Get started with a Playground: On the next panel, you can give your Playground a name or you can leave it MyPlayground and press Next: Select a locat...
people := map[string]int{ "john": 30, "jane": 29, "mark": 11, } for _, value := range people { fmt.Println("Age:", value) } Note that when iterating over a map with a range loop, the iteration order is not specified and is not guaranteed to...
Abstract factory pattern provides a way to obtain an coherent collection of objects through a collection of factories functions. As for every pattern, coupling is reduced by abstracting the way a set of objects are created, so that the user code is unaware of the many details of the objects he needs...
Factories can be used in conjunction with Inversion of Control (IoC) libraries too. The typical use case for such a factory is when we want to create an object based on parameters that are not known until run-time (such as the current User). In these cases it can be sometimes be difficult (if no...
Fourier Transform is probably the first lesson in Digital Signal Processing, it's application is everywhere and it is a powerful tool when it comes to analyze data (in all sectors) or signals. Matlab has a set of powerful toolboxes for Fourier Transform. In this example, we will use Fourier Transfor...
Objective-C [mySwitch setOn:YES]; //or [mySwitch setOn:YES animated:YES]; Swift mySwitch.setOn(false) //or mySwitch.setOn(false, animated: false)
Fortran 2003 introduced language features which can guarantee interoperability between C and Fortran (and to more languages by using C as an intermediary). These features are mostly accessed through the intrinsic module iso_c_binding: use, intrinsic :: iso_c_binding The intrinsic keyword here en...
The bind attribute can also be applied to derived types: geese.h struct Goose { int flock; float buoyancy; } struct Goose goose_c; geese.f90 use, intrinsic :: iso_c_binding, only : c_int, c_float type, bind(C) :: goose_t integer(c_int) :: flock real(c_float) :: buoyancy e...

Page 86 of 457