Tutorial by Examples: ad

Write formatted data to string int sprintf ( char * str, const char * format, ... ); use sprintf function to write float data to string. #include <stdio.h> int main () { char buffer [50]; double PI = 3.1415926; sprintf (buffer, "PI = %.7f", PI); printf ("%s\n&...
Channel uses a Buffer to read/write data. A buffer is a fixed sized container where we can write a block of data at once. Channel is a quite faster than stream-based I/O. To read data from a file using Channel we need to have the following steps- We need an instance of FileInputStream. FileInput...
If you need to add custom headers to your volley requests, you can't do this after initialisation, as the headers are saved in a private variable. Instead, you need to override the getHeaders() method of Request.class as such: new JsonObjectRequest(REQUEST_METHOD, REQUEST_URL, REQUEST_BODY, RESP_L...
<svg width="800px" height="600px"> <defs> <filter id="drop-shadow"> <feGaussianBlur in="SourceAlpha" stdDeviation="4"/> <feOffset dx="5" dy="5" result="offsetblur"/> <f...
<svg width="800px" height="600px"> <defs> <filter id="inner-glow"> <feFlood flood-color="red"/> <feComposite in2="SourceAlpha" operator="out"/> <feGaussianBlur stdDeviation="2" r...
<svg width="800px" height="600px"> <defs> <filter id="complex-shadow" color-interpolation-filters="sRGB" x="-50%" y="-50%" height="200%" width="200%"> <!-- Take source alpha, offset it by angle/...
Since Java 7 it has been possible to use one or more underscores (_) for separating groups of digits in a primitive number literal to improve their readability. For instance, these two declarations are equivalent: Java SE 7 int i1 = 123456; int i2 = 123_456; System.out.println(i1 == i2); // tru...
Elasticsearch is accessed through a HTTP REST API, typically using the cURL library. The messages between the search server and the client (your or your application) are sent in the form of JSON strings. By default, Elasticsearch runs on port 9200. In the examples below, ?pretty is added to tell El...
// Get the current colors of the gradient. let oldColors = self.gradientLayer.colors // Define the new colors for the gradient. let newColors = [UIColor.red.cgColor, UIColor.yellow.cgColor] // Set the new colors of the gradient. self.gradientLayer.colors = newColors // Initia...
Related to Monads are F# computation expressions (CE). A programmer typically implements a CE to provide an alternative approach to chaining Monads, ie instead of this: let v = m >>= fun x -> n >>= fun y -> return_ (x, y) You can write this: let v = ce { let! x = m ...
To load an image and place it on the canvas var image = new Image(); // see note on creating an image image.src = "imageURL"; image.onload = function(){ ctx.drawImage(this,0,0); } Creating an image There are several ways to create an image new Image() document.createEleme...
Objective c: //this is the dictionary you start with. NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"name1", @"Sam",@"name2", @"Sanju",nil]; //check if the dictionary contains the key you are going to modify. In this example, @&qu...
perl -0777 -ne'print "The whole file as a string: --->$_<---\n"' Note: The -0777 is just a convention. Any -0400 and above would de the same.
curl -XGET 'http://www.example.com:9200/myIndexName/myTypeName/1' Output: { "_index" : "myIndexName", "_type" : "myTypeName", "_id" : "1", "_version" : 1, "found": true, "_source&qu...
The --url flag can be tricky to use. There is a 60 second window to authenticate, and then the username/password randomly resets. So be sure to have robomongo open and ready to configure a new connection when you run the command. # get the MONGO_URL string for your app meteor mongo --url $METEOR...
Same thing as before, but you have to copy the info into the mongodump command. You have to run the following commands rediculously fast, and it requires hand/eye coordination. Be warned! This is a rediculously hacky! But fun! Think of it as a video game! :D # get the MONGO_URL string for your app ...
The analog to the meteordump command is meteorrestore. You can do a partial import by selecting the specific collection to import. Particularly useful after running a drop command. # make sure your app is running meteor # then import your data mongorestore --port 3001 --db meteor /path/to/dump...
db.posts.find().forEach(function(doc){ db.posts.update({_id: doc._id}, {$set:{'version':'v1.0'}}, false, true); });
var timestamp = Math.floor(new Date(1974, 6, 25).getTime() / 1000); var hex = ('00000000' + timestamp.toString(16)).substr(-8); // zero padding var objectId = new ObjectId(hex + new ObjectId().str.substring(8));
These functions are used to check Mouse Button Clicks. Input.GetMouseButton(int button); Input.GetMouseButtonDown(int button); Input.GetMouseButtonUp(int button); They all take the-same parameter. 0 = Left Mouse Click. 1 = Right Mouse Click. 2 = Middle Mouse Click. GetMouseButton i...

Page 41 of 114