Tutorial by Examples: and

Keeping a GUI responsive while running a lengthy process requires either some very elaborate "callbacks" to allow the GUI to process its message queue, or the use of (background) (worker) threads. Kicking off any number of threads to do some work usually isn't a problem. The fun starts wh...
Simple example of using the Chrome Logging API. Template.landingPage.events({ 'click .selectItemButton':function(){ // color code and count the user interaction (blue) console.count('click .selectItemButton'); } });
In the assets initalizer (config/initializers/assets.rb) are a few files explicitly defined to be precompiled. # Precompile additional assets. # application.coffee, application.scss, and all non-JS/CSS in app/assets folder are already added. # Rails.application.config.assets.precompile += %w( sea...
# config/locales/en.yml en: stackoverflow: header: title_html: "Use <strong>I18n</strong> with Tags & Symbols" Note the addition of extra _html after the name title. And in Views, # ERB <h2><%= t(:title_html, scope: [:stackoverflow, :heade...
We have a Product model and we want to group them by their category. Product.select(:category).group(:category) This will query the database as follows: SELECT "product"."category" FROM "product" GROUP BY "product"."category" Make sure that t...
The getopts builtin can be used inside functions to write functions that accommodate flags and optional parameters. This presents no special difficulty but one has to handle appropriately the values touched by getopts. As an example, we define a failwith function that writes a message on stderr an...
In elm, a function's value is computed when the last argument is applied. In the example below, the diagnostic from log will be printed when f is invoked with 3 arguments or a curried form of f is applied with the last argument. import String import Debug exposing (log) f a b c = String.join &...
When reading tabular datasets with the read.* functions, R automatically looks for missing values that look like "NA". However, missing values are not always represented by NA. Sometimes a dot (.), a hyphen(-) or a character-value (e.g.: empty) indicates that a value is NA. The na.strings ...
Install the stable release from CRAN: install.packages("data.table") Or the development version from github: install.packages("data.table", type = "source", repos = "http://Rdatatable.github.io/data.table") To revert from devel to CRAN, the ...
CSS and JS files should be reside under 'static' directory in the root directory of module (the rest of subdirectory tree under 'static' is an optional convention): static/src/css/your_file.css static/src/js/your_file.js Then add links to these files unsing one of the 3 ways listed in the fol...
Odoo v8.0 way is to add corresponding record in the XML file: ​Add XML file to the manifest (i.e. __openerp__.py file.): ... 'data' : [ 'your_file.xml' ], ​... Then add following record in 'your_file.xml': <openerp> <data> <template id="...
Note: you should use this way if you've installed a "website" module and you have a public website available. Add following record in 'your_file.xml': <openerp> <data> <template id="assets_frontend" name="your_module_name assets" inherit...
Add following record in 'your_file.xml': <openerp> <data> <template id="assets_common" name="your_module_name assets" inherit_id="web.assets_common"> <xpath expr="." position="inside"> <link rel...
Encoding and decoding functions for a variety of Unicode encodings can be found in the Data.Text.Encoding module. ghci> import Data.Text.Encoding ghci> decodeUtf8 (encodeUtf8 "my text") "my text" Note that decodeUtf8 will throw an exception on invalid input. If you wa...
All functions to interact with coroutines are avaliable in the coroutine table. A new coroutine is created by using the coroutine.create function with a single argument: a function with the code to be executed: thread1 = coroutine.create(function() print("honk") end)...
Input must must read from the Update function. Reference for all the available Keycode enum. 1. Reading key press with Input.GetKey: Input.GetKey will repeatedly return true while the user holds down the specified key. This can be used to repeatedly fire a weapon while holding the specified key ...
CSS Getter The .css() getter function can be applied to every DOM element on the page like the following: // Rendered width in px as a string. ex: `150px` // Notice the `as a string` designation - if you require a true integer, // refer to `$.width()` method $("body").css("width...
Callbacks can be used to provide code to be executed after a method has completed: /** * @arg {Function} then continuation callback */ function doSomething(then) { console.log('Doing something'); then(); } // Do something, then execute callback to log 'done' doSomething(function () ...
Callbacks are often used to provide error handling. This is a form of control flow branching, where some instructions are executed only when an error occurs: const expected = true; function compare(actual, success, failure) { if (actual === expected) { success(); } else { failure...
#Modules to use use Cwd 'abs_path'; use Win32::OLE; use Win32::OLE qw(in with); use Win32::OLE::Const "Microsoft Excel"; $Win32::OLE::Warn = 3; #Need to use absolute path for Excel files my $excel_file = abs_path("$Excel_path") or die "Error: the file $Excel_path ha...

Page 50 of 153