Tutorial by Examples: def

With deferred execution, if the data to be queried is changed, the query object uses the data at the time of execution, not at the time of definition. var data = new List<int>() {2, 4, 6, 8}; var query = data.Select(x => x * x); If we execute the query at this point with an immediate m...
An enumerated type is a type that can hold one of a finite list of possible values. In Julia, enumerated types are typically called "enum types". For instance, one could use enum types to describe the seven days of the week, the twelve months of the year, the four suits of a standard 52-ca...
If you have create .Net class that represents some user-defined type, compiled it into .dll, and imported it into SQL server as an assembly, you can create user-defined function that references this class: CREATE TYPE dbo.Point EXTERNAL NAME MyLibrary.[Name.Space.Point] You need to specify name...
Often one wants to intermittently run one or more validation batches during the course of training a deep network. Typically the training data are fed by a queue while the validation data might be passed through the feed_dict parameter in sess.run(). tf.placeholder_with_default() is designed to work...
# encode/decode UTF-8 for files and standard input/output use open qw( :encoding(UTF-8) :std ); This pragma changes the default mode of reading and writing text ( files, standard input, standard output, and standard error ) to UTF-8, which is typically what you want when writing new application...
malloc() often calls underlying operating system functions to obtain pages of memory. But there is nothing special about the function and it can be implemented in straight C by declaring a large static array and allocating from it (there is a slight difficulty in ensuring correct alignment, in pract...
Sometimes we want to use a where query on a a collection of records returned which is not ActiveRecord::Relation.Hence we get the above error as Where clause is know to ActiveRecord and not to Array. There is a precise solution for this by using Joins. EXAMPLE:- Suppose i need to find all user ...
import Foundation class CookiesSingleton { static let instance : CookiesSingleton = CookiesSingleton() static var enableDebug = true func loadCookies() { if let cookiesDetails = NSUserDefaults.standardUserDefaults().objectForKey("customeWebsite") { for (keys,_) i...
Inheritance is one of the main concepts in Object Oriented Programming (OOP). Using inheritance, we can model a problem properly and we can reduce the number of lines we have to write. Let's see inheritance using a popular example. Consider you have to model animal kingdom (Simplified animal kingdo...
There’s a tempting existing field called profile that is added by default when a new user registers. This field was historically intended to be used as a scratch pad for user-specific data - maybe their image avatar, name, intro text, etc. Because of this, the profile field on every user is automati...
With the 2.x versions of typescript, typings are now available from the npm @types repository. These are automatically resolved by the typescript compiler and are much simpler to use. To install a type definition you simply install it as a dev dependency in your projects package.json e.g. npm i -...
Consider a simple asynchronous method: async Task Foo() { Bar(); await Baz(); Qux(); } Simplifying, we can say that this code actually means the following: Task Foo() { Bar(); Task t = Baz(); var context = SynchronizationContext.Current; t.ContinueWith(task...
This is a porting of set up sourced from DigitalOcean's tutorial of How To Serve Flask Applications with uWSGI and Nginx on Ubuntu 14.04 and some useful git resources for nginx servers. Flask Application This tutorial assume you use Ubuntu. locate var/www/ folder. Create your web app folder m...
inline int add(int x, int y) { return x + y; }
library(deSolve) ## ----------------------------------------------------------------------------- ## Define parameters and variables ## ----------------------------------------------------------------------------- eps <- 0.01; M <- 10 k <- M * eps^2/2 L <- 1 L0 <- 0.5 ...
sink("caraxis_C.c") cat(" /* suitable names for parameters and state variables */ #include <R.h> #include <math.h> static double parms[8]; #define eps parms[0] #define m parms[1] #define k parms[2] #define L parms[3] #define L0 parms[4] #define r p...
sink("caraxis_fortran.f") cat(" c---------------------------------------------------------------- c Initialiser for parameter common block c---------------------------------------------------------------- subroutine init_fortran(daeparms) external daeparms ...
In ruby you can add methods to existing instances of any class. This allows you to add behavior to and instance of a class without changing the behavior of the rest of the instances of that class. class Example def method1(foo) puts foo end end #defines method2 on object exp exp = E...
Using an Asynchronous Controller in ASP.NET MVC. The AsyncController class enables you to write asynchronous action methods. You can use asynchronous action methods for long-running, non-CPU bound requests. This avoids blocking the Web server from performing work while the request is being processed...
To define an atom, use an ordinary def, but add an atom function before it, like so: (def counter (atom 0)) This creates an atom of value 0. Atoms can be of any type: (def foo (atom "Hello")) (def bar (atom ["W" "o" "r" "l" "d"])) ...

Page 20 of 27