Tutorial by Examples: sin

A common pattern in C, to easily imitate returning multiple values from a function, is to use pointers. #include <stdio.h> void Get( int* c , double* d ) { *c = 72; *d = 175.0; } int main(void) { int a = 0; double b = 0.0; Get( &a , &b ); pr...
Usually we are using String.Format method for formatting purpose, the.ToString is usually used for converting other types to string. We can specify the format along with the ToString method while conversion is taking place, So we can avoid an additional Formatting. Let Me Explain how it works with d...
Working in old browsers (IE >= 8) Automatic margins, paired with values of zero for the left and right or top and bottom offsets, will center an absolutely positioned elements within its parent. View Result HTML <div class="parent"> <img class="center" src=&quo...
This Makefile will cross compile and zip up executables for Windows, Mac and Linux (ARM and x86). # Replace demo with your desired executable name appname := demo sources := $(wildcard *.go) build = GOOS=$(1) GOARCH=$(2) go build -o build/$(appname)$(3) tar = cd build && tar -cvzf $...
This type of Singleton is thread safe, and prevents unnecessary locking after the Singleton instance has been created. Java SE 5 public class MySingleton { // instance of class private static volatile MySingleton instance = null; // Private constructor private MySingleton()...
Clicking the Select an element in the page to inspect it button in the upper left corner of the Elements tab in Chrome or Inspector tab in Firefox, available from Developer Tools, and then clicking on a element of the page highlights the element and assigns it to the $0 variable. Elements inspecto...
PHP implements a DOM Level 2 compliant parser, allowing you to work with HTML using familiar methods like getElementById() or appendChild(). $html = '<html><body><span id="text">Hello, World!</span></body></html>'; $doc = new DOMDocument(); libxml_u...
$html = '<html><body><span class="text">Hello, World!</span></body></html>'; $doc = new DOMDocument(); $doc->loadHTML($html); $xpath = new DOMXPath($doc); $span = $xpath->query("//span[@class='text']")->item(0); echo $span-&...
A simple program that writes "Hello, world!" to test.txt, reads back the data, and prints it out. Demonstrates simple file I/O operations. package main import ( "fmt" "io/ioutil" ) func main() { hello := []byte("Hello, world!") //...
package main import ( "fmt" "io/ioutil" ) func main() { files, err := ioutil.ReadDir(".") if err != nil { panic(err) } fmt.Println("Files and folders in the current directory:") for _, fileInfo := range fi...
To access member variables and member functions of an object of a class, the . operator is used: struct SomeStruct { int a; int b; void foo() {} }; SomeStruct var; // Accessing member variable a in var. std::cout << var.a << std::endl; // Assigning member variable b in v...
The example shows parsing a JSON object using the Gson library from Google. Parsing objects: class Robot { //OPTIONAL - this annotation allows for the key to be different from the field name, and can be omitted if key and field name are same . Also this is good coding practice as it decouple ...
Units of measure are additional type annotations that can be added to floats or integers. They can be used to verify at compile time that calculations are using units consistently. To define annotations: [<Measure>] type m // meters [<Measure>] type s // seconds [<Measure>] typ...
With IronPython you can access any .net assembly which is compiled using the same or a lower version than the IronPython core. Example: Importing a a .net assembly and class from System import Math Example: Using an imported class: from System import Math print Math.Abs(-123) You can also lo...
[StackDemo(Text = "Hello, World!")] public class MyClass { [StackDemo("Hello, World!")] static void MyMethod() { } }
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...
public class SuperClass { private func secretMethod() {} } internal class SubClass: SuperClass { override internal func secretMethod() { super.secretMethod() } }
class Animal def method_missing(method, *args, &block) say, speak = method.to_s.split("_") if say == "say" speak else super end end end => a = Animal.new => a.say_moo => "moo" => a.shout_moo => NoMethodE...
Android supports several configuration qualifiers that allow you to control how the system selects your alternative resources based on the characteristics of the current device screen. A configuration qualifier is a string that you can append to a resource directory in your Android project and speci...
To run migrations in the test environment, run this shell command: rake db:migrate RAILS_ENV=test 5.0 Starting in Rails 5.0, you can use rails instead of rake: rails db:migrate RAILS_ENV=test

Page 16 of 161