Tutorial by Examples: bas

3.0 In Swift 3 there are multiple access-levels. This example uses them all except for open: public struct Car { public let make: String let model: String //Optional keyword: will automatically be "internal" private let fullName: String fileprivate var otherName...
One of ColdFusion's strengths is how easy it is to work with databases. And of course, query inputs can and should be parameterized. Tag Implementation <cfquery name="myQuery" datasource="myDatasource" result="myResult"> select firstName, lastName from...
It can also be installed by downloading the source code and placing it in a directory of your project. However there are many benefits to using composer. require '/path/to/lib/Twig/Autoloader.php'; Twig_Autoloader::register(); $loader = new Twig_Loader_Filesystem('/path/to/templates'); $opti...
Factors are one way to represent categorical variables in R. A factor is stored internally as a vector of integers. The unique elements of the supplied character vector are known as the levels of the factor. By default, if the levels are not supplied by the user, then R will generate the set of uniq...
Display all data files for all databases with size and growth info SELECT d.name AS 'Database', d.database_id, SF.fileid, SF.name AS 'LogicalFileName', CASE SF.status & 0x100000 WHEN 1048576 THEN 'Percentage' WHEN 0 THEN 'MB...
It's a bad idea to hard code paths in your application. One should always use relative urls so that your code can work seamlessly across different machines. The best way to set this up is to define a variable like this import os BASE_DIR = os.path.dirname(os.path.dirname(__file__)) Then use th...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-widt...
Discriminated unions in F# offer a a way to define types which may hold any number of different data types. Their functionality is similar to C++ unions or VB variants, but with the additional benefit of being type safe. // define a discriminated union that can hold either a float or a string type...
Each migration should have an up() method and a down() method. The purpose of the up() method is to perform the required operations to put the database schema in its new state, and the purpose of the down() method is to reverse any operations performed by the up() method. Ensuring that the down() me...
type person = {Name: string; Age: int} // Defines person record let user1 = {Name = "John Doe"; Age = 27} // creates a new person let user2 = {user1 with Age = 28} // creates a copy, with different Age let user3 = {user1 with Name = "Jane Doe"; Age = 29} //creates ...
One might want to group their data by the runs of a variable and perform some sort of analysis. Consider the following simple dataset: (dat <- data.frame(x = c(1, 1, 2, 2, 2, 1), y = 1:6)) # x y # 1 1 1 # 2 1 2 # 3 2 3 # 4 2 4 # 5 2 5 # 6 1 6 The variable x has three runs: a run of l...
Python has built-in support for complex arithmetic. The imaginary unit is denoted by j: z = 2+3j # A complex number w = 1-7j # Another complex number Complex numbers can be summed, subtracted, multiplied, divided and exponentiated: z + w # (3-4j) z - w # (1+10j) z * w # (23-11j) z / w # (...
The canvas element was introduced in HTML5 for drawing graphics. <canvas id="myCanvas"> Cannot display graphic. Canvas is not supported by your browser (IE<9) </canvas> The above will create a transparent HTML<canvas> element of 300×150 px in size. You can us...
Given the following HTML file: index.html <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>React Tutorial</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.2.1/react.js"></script>...
// Create a boolean value let a = true; // The following expression will try and find a pattern for our value starting with // the topmost pattern. // This is an exhaustive match expression because it checks for every possible value match a { true => println!("a is true"), ...
Creating the class to be the subject of the Mirror class Project { var title: String = "" var id: Int = 0 var platform: String = "" var version: Int = 0 var info: String? } Creating an instance that will actually be the subject of the mirror. Also he...
Given the following history, imagine you make a change that you want to squash into the commit bbb2222 A second commit: $ git log --oneline --decorate ccc3333 (HEAD -> master) A third commit bbb2222 A second commit aaa1111 A first commit 9999999 Initial commit Once you've made your change...
TypeScript is a typed superset of JavaScript, which means that all JavaScript code is valid TypeScript code. TypeScript adds a lot of new features on top of that. TypeScript makes JavaScript more like a strongly-typed, object-oriented language akin to C# and Java. This means that TypeScript code te...
In Python 3 str is the type for unicode-enabled strings, while bytes is the type for sequences of raw bytes. type("f") == type(u"f") # True, <class 'str'> type(b"f") # <class 'bytes'> In Python 2 a casual string was a sequence of raw byte...
Class based views let you focus on what make your views special. A static about page might have nothing special, except the template used. Use a TemplateView! All you have to do is set a template name. Job done. Next. views.py from django.views.generic import TemplateView class AboutView(Tem...

Page 8 of 65