Tutorial by Examples: sin

Creating a Window with OpenGL context (extension loading through GLEW): #define GLEW_STATIC #include <GL/glew.h> #include <SDL2/SDL.h> int main(int argc, char* argv[]) { SDL_Init(SDL_INIT_VIDEO); /* Initialises Video Subsystem in SDL */ /* Setting up OpenGL version a...
Most of the time you need to import namespaces in your XAML file. How this is done is different for the different XAML variants. For Windows Phone, Silverlight, WPF use the clr-namespace syntax: <Window ... xmlns:internal="clr-namespace:rootnamespace.namespace" xmlns:exte...
A Gemfile is the standard way to organize dependencies in your application. A basic Gemfile will look like this: source 'https://rubygems.org' gem 'rack' gem 'sinatra' gem 'uglifier' You can specify the versions of the gem you want as follows: # Match except on point release. Use only 1.5....
Assuming an implicit parameter list with more than one implicit parameter: case class Example(p1:String, p2:String)(implicit ctx1:SomeCtx1, ctx2:SomeCtx2) Now, assuming that one of the implicit instances is not available (SomeCtx1) while all other implicit instances needed are in-scope, to creat...
Browser support for ES6 is growing, but to be sure your code will work on environments that dont fully support it, you can use Babel, the ES6/7 to ES5 transpiler, try it out! If you would like to use ES6/7 in your projects without having to worry about compatibility, you can use Node and Babel CLI ...
this topic is a classical issue in iOS development, and its solution is various as other example already shown. In this example I'll show another daily common use one: passing data using closure by adapting delegate pattern example on this page into callback closure! one thing this method is superi...
By default, dotnet new creates C# projects. You can use the -l or --lang flag to scaffold projects in other languages: dotnet new -l f# dotnet restore dotnet run Currently, dotnet new supports C# and F#.
Angles are in Radians, not Degrees. All computations are done in IEEE 754 64-bit floating point. All floating point computations are subject to small errors, known as machine ε (epsilon) errors, so avoid trying to compare them for equality. There is no way to avoid these errors when using floating p...
Mixins are a sort of class that is used to "mix in" extra properties and methods into a class. This is usually fine because many times the mixin classes don't override each other's, or the base class' methods. But if you do override methods or properties in your mixins this can lead to une...
As ES6 introduced Symbols, which are both unique and immutable primitive values that may be used as the key of an Object property, instead of using strings as possible values for an enum, it's possible to use symbols. // Simple symbol const newSymbol = Symbol(); typeof newSymbol === 'symbol' // t...
The SilverStripe CMS can be customised to change the CMS logo, link and application name. This can be achieved with the following config.yml settings LeftAndMain: application_name: 'My Application' application_link: 'http://www.example.com/' extra_requirements_css: - mysite/css/cms.c...
SpriteKit functionality can be implemented in a subclass of SKScene. For example, a game may implement the main game functionality within an SKScene subclass called GameScene. In Swift: import SpriteKit class GameScene: SKScene { override func didMoveToView(view: SKView) { /* Co...
Chaining assignments as part of a var declaration will create global variables unintentionally. For example: (function foo() { var a = b = 0; })() console.log('a: ' + a); console.log('b: ' + b); Will result in: Uncaught ReferenceError: a is not defined 'b: 0' In the above examp...
Mapping Applying a function to all elements of an array : array_map('strtoupper', $array); Be aware that this is the only method of the list where the callback comes first. Reducing (or folding) Reducing an array to a single value : $sum = array_reduce($numbers, function ($carry, $number) { ...
The easiest and quickest way to encode a Haskell data type to JSON with Aeson is using generics. {-# LANGUAGE DeriveGeneric #-} import GHC.Generics import Data.Text import Data.Aeson import Data.ByteString.Lazy First let us create a data type Person: data Person = Person { firstName :...
Sometimes you doesn't want to simply replace or remove the string. Sometimes you want to extract and process matches. Here an example of how you manipulate matches. What is a match ? When a compatible substring is found for the entire regex in the string, the exec command produce a match. A match i...
If you want to extract something from a webpage (or any representation/programming language), a regex is the wrong tool for the task. You should instead use your language's libraries to achieve the task. If you want to read HTML, or XML, or JSON, just use the library that parses it properly and ser...
There are two common ways to encode a POST request body: URL encoding (application/x-www-form-urlencoded) and form data (multipart/form-data). Much of the code is similar, but the way you construct the body data is different. Sending a request using URL encoding Be it you have a server for your s...
The POSIX and C standards explicitly state that using fflush on an input stream is undefined behavior. The fflush is defined only for output streams. #include <stdio.h> int main() { int i; char input[4096]; scanf("%i", &i); fflush(stdin); // <-- unde...
Using alarm, user can schedule SIGALARM signal to be raised after specified interval. In case user did not blocked, ignored or specified explicit signal handler for this signal, the default action for this signal will be performed on arrival. Per specification default action for SIGALARM is to termi...

Page 73 of 161