Tutorial by Examples: c

Save the current state of working directory and the index (also known as the staging area) in a stack of stashes. git stash To include all untracked files in the stash use the --include-untracked or -u flags. git stash --include-untracked To include a message with your stash to make it more ...
The background-attachment property sets whether a background image is fixed or scrolls with the rest of the page. body { background-image: url('img.jpg'); background-attachment: fixed; } ValueDescriptionscrollThe background scrolls along with the element. This is default.fixedThe backgro...
The background-repeat property sets if/how a background image will be repeated. By default, a background-image is repeated both vertically and horizontally. div { background-image: url("img.jpg"); background-repeat: repeat-y; } Here's how a background-repeat: repeat-y looks lik...
To ignore a file foo.txt in any directory you should just write its name: foo.txt # matches all files 'foo.txt' in any directory If you want to ignore the file only in part of the tree, you can specify the subdirectories of a specific directory with ** pattern: bar/**/foo.txt # matches all file...
Example that builds an executable (editor) and links a library (highlight) to it. Project structure is straightforward, it needs a master CMakeLists and a directory for each subproject: CMakeLists.txt editor/ CMakeLists.txt src/ editor.cpp highlight/ CMakeLists.txt in...
Multiple rows can be inserted with a single insert command: INSERT INTO tbl_name (field1, field2, field3) VALUES (1,2,3), (4,5,6), (7,8,9); For inserting large quantities of data (bulk insert) at the same time, DBMS-specific features and recommendations exist. MySQL - LOAD DATA INFILE MSSQL - B...
Travis CI has CMake 2.8.7 pre-installed. A minimal .travis.yml script for an out-of source build language: cpp compiler: - gcc before_script: # create a build folder for the out-of-source build - mkdir build # switch to build directory - cd build # run cmake; here we assume...
The CMake version preinstalled on Travis is very old. You can use the official Linux binaries to build with a newer version. Here is an example .travis.yml: language: cpp compiler: - gcc # the install step will take care of deploying a newer cmake version install: # first we creat...
int a = 1; int *a_pointer = &a; To dereference a_pointer and change the value of a, we use the following operation *a_pointer = 2; This can be verified using the following print statements. printf("%d\n", a); /* Prints 2 */ printf("%d\n", *a_pointer); /* Also prints...
If you need a completely customized view, you'll need to subclass View (the superclass of all Android views) and provide your custom sizing (onMeasure(...)) and drawing (onDraw(...)) methods: Create your custom view skeleton: this is basically the same for every custom view. Here we create the...
Destructuring allows us to refer to one key in an object, but declare it as a variable with a different name. The syntax looks like the key-value syntax for a normal JavaScript object. let user = { name: 'John Smith', id: 10, email: '[email protected]', }; let {user: userName, id: us...
It is important for someone traversing through the git log to easily understand what each commit was all about. Good commit messages usually include a number of a task or an issue in a tracker and a concise description of what has been done and why, and sometimes also how it has been done. Better m...
Add this to your vimrc: nnoremap Q @q To start recording the "throwaway" macro, use qq. To finish recording hit q (in normal mode for both). To execute the recorded macro, use Q. This is useful for macros that you need to repeat many times in a row but won't be likely to use again af...
One way to create a macro is to record it. Start recording a macro and save it to a register (in this example, we'll use a, but it can be any register you could normally yank text to): qa Then run the commands you want to record in the macro (here, we'll surround the contents of a line with &lt...
LINQ is largely beneficial for querying collections (or arrays). For example, given the following sample data: var classroom = new Classroom { new Student { Name = "Alice", Grade = 97, HasSnack = true }, new Student { Name = "Bob", Grade = 82, HasSnack = false }, ...
public class LogActionFilter : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { Log("OnActionExecuting", filterContext.RouteData); } public override void OnActionExecuted(ActionExecute...
Swift let webview = UIWebView(frame: CGRect(x: 0, y: 0, width: 320, height: 480)) Objective-C UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; //Alternative way of defining frame for UIWebView UIWebView *webview = [[UIWebView alloc] init]; CGRect webviewFr...
Unlike many other programming languages, the throw and catch keywords are not related to exception handling in Ruby. In Ruby, throw and catch act a bit like labels in other languages. They are used to change the control flow, but are not related to a concept of "error" like Exceptions are...
std::async is also able to make threads. Compared to std::thread it is considered less powerful but easier to use when you just want to run a function asynchronously. Asynchronously calling a function #include <future> #include <iostream> unsigned int square(unsigned int i){ r...
This is how to create a basic method that logs 'Hello World" to the console: - (void)hello { NSLog(@"Hello World"); } The - at the beginning denotes this method as an instance method. The (void) denotes the return type. This method doesn't return anything, so you enter void. ...

Page 110 of 826