Tutorial by Examples: c

The bisect command helps you to track down the changeset that introduced a bug. Reset the bisect state and mark the current revision as bad (it contains the bug!) hg bisect --reset hg bisect --bad Go back to a point where you think the bug isn't present hg update -r -200 Now...
Serialization is the process of converting an object into a stream of bytes in order to store the object or transmit it to memory, a database, or a file. Microsoft page Serialization The following example demonstrates Serialization in WCF: [ServiceContract(Namespace="http://Microsoft.Ser...
Python 2.x2.7 In Python 2 filter, map and zip built-in functions return a sequence. map and zip always return a list while with filter the return type depends on the type of given parameter: >>> s = filter(lambda x: x.isalpha(), 'a1b2c3') >>> s 'abc' >>> s = map(lambd...
In Python 3.x, the reduce function already explained here has been removed from the built-ins and must now be imported from functools. from functools import reduce def factorial(n): return reduce(lambda a, b: (a*b), range(1, n+1))
public class Foo { private const int TASK_ITERATION_DELAY_MS = 1000; private CancellationTokenSource _cts; public Foo() { this._cts = new CancellationTokenSource(); } public void StartExecution() { Task.Factory.StartNew(this.OwnCodeCancelable...
public class Foo { private CancellationTokenSource _cts; public Foo() { this._cts = new CancellationTokenSource(); } public void StartExecution() { Task.Factory.StartNew(this.OwnCodeCancelableTask, this._cts.Token); } public void Cance...
private bool IsTaskRegistered(string taskName) => BackgroundTaskRegistration.AllTasks.Any(x => x.Value.Name.Equals(taskName));
In order to login to a user's account on machine with SSH you can use the command ssh username@ip_address. It will ask for a password. If you type the correct password, you will be connected to the shell of that user on that machine. Otherwise it will prompt for the password again. For example roo...
Whereas Classes are more like blueprints, Objects are static (i.e. already instantiated): object Dog { def bark: String = "Raf" } Dog.bark() // yields "Raf" They are often used as a companion to a class, they allow you to write: class Dog(val name: String) { } ...
Unlike durations, periods can be used to accurately model clock times without knowing when events such as leap seconds, leap days, and DST changes occur. start_2012 <- ymd_hms("2012-01-01 12:00:00") ## [1] "2012-01-01 12:00:00 UTC" # period() considers leap year calculati...
CSS: div{ width:200px; height:200px; background:teal; clip-path: polygon(0 0, 0 100%, 100% 50%); /* refer remarks before usage */ } HTML: <div></div> In the above example, a polygonal clipping path is used to clip the square (200 x 200) element into a triangle shape....
CSS: div{ width: 200px; height: 200px; background: teal; clip-path: circle(30% at 50% 50%); /* refer remarks before usage */ } HTML <div></div> This example shows how to clip a div to a circle. The element is clipped into a circle whose radius is 30% based on the dim...
GROUP BY is used in combination with aggregation functions. Consider the following table: orderIduserIdstoreNameorderValueorderDate143Store A2520-03-2016257Store B5022-03-2016343Store A3025-03-2016482Store C1026-03-2016521Store A4529-03-2016 The query below uses GROUP BY to perform aggregated calc...
When something fails in your transaction code and you want to undo it, you can rollback your transaction: BEGIN TRY BEGIN TRANSACTION INSERT INTO Users(ID, Name, Age) VALUES(1, 'Bob', 24) DELETE FROM Users WHERE Name = 'Todd' COMMIT TRANSACTION END TRY...
This option allows you to clear a TLA for references and values at TLA allocation time and pre-fetch the next chunk. When an integer, a reference, or anything else is declared, it has a default value of 0 or null (depending upon type). At the appropriate time, you will need to clear these references...
When used with -XXallocClearChunkSize, this option sets the size of the chunks to be cleared. If this flag is used but no value is specified, the default is 512 bytes. Usage: -XXallocClearChunks -XXallocClearChunkSize=<size>[k|K][m|M][g|G]
kotlin-gradle-plugin is used to compile Kotlin code with Gradle. Basically, its version should correspond to the Kotlin version you want to use. E.g. if you want to use Kotlin 1.0.3, then you need to aplly kotlin-gradle-plugin version 1.0.3 too. It's a good idea to externalize this version in gradl...
Protocol Oriented Programming is a useful tool in order to easily write better unit tests for our code. Let's say we want to test a UIViewController that relies on a ViewModel class. The needed steps on the production code are: Define a protocol that exposes the public interface of the class Vi...
#include <stdio.h> void print_all(FILE *stream) { int c; while ((c = getc(stream)) != EOF) putchar(c); } int main(void) { FILE *stream; /* call netstat command. netstat is available for Windows and Linux */ if ((stream = popen("netstat", &qu...
import ( "io/ioutil" "path/filepath" "gopkg.in/yaml.v2" ) func main() { filename, _ := filepath.Abs("config/config.yml") yamlFile, err := ioutil.ReadFile(filename) var config Config err = yaml.Unmarshal(yamlFile, &c...

Page 193 of 826