Tutorial by Examples: st

To apply the last stash and remove it from the stack - type: git stash pop To apply specific stash and remove it from the stack - type: git stash pop stash@{n}
Applies the last stash without removing it from the stack git stash apply Or a specific stash git stash apply stash@{n}
More complicated tests sometimes need to have things set up before you run the code you want to test. It is possible to do this in the test function itself, but then you end up with large test functions doing so much that it is difficult to tell where the setup stops and the test begins. You can als...
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...
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...
Custom views can also take custom attributes which can be used in Android layout resource files. To add attributes to your custom view you need to do the following: Define the name and type of your attributes: this is done inside res/values/attrs.xml (create it if necessary). The following file...
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...
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...
Load content in webview from the url Swift webview.loadRequest(NSURLRequest(URL: NSURL(string: "http://www.google.com")!)) Objective-C [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]];
The library CL-PPCRE provides the function split which allows us to split strings in substrings that match a regular expression, discarding the parts of the string that do not. (cl-ppcre:split "\\." "127.0.0.1") ;; => ("127" "0" "0" "1&quot...
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...
A Broadcast receiver is an Android component which allows you to register for system or application events. A receiver can be registered via the AndroidManifest.xml file or dynamically via the Context.registerReceiver() method. public class MyReceiver extends BroadcastReceiver { @Override ...
Defining Strings in the strings.xml file also allows for string formatting. The only caveat is that the String will need to be dealt with in code like below, versus simply attaching it to a layout. <string name="welcome_trainer">Hello Pokémon Trainer, %1$s! You have caught %2$d Poké...
Unlike C++ in C# you can call a virtual method from class constructor (OK, you can also in C++ but behavior at first is surprising). For example: abstract class Base { protected Base() { _obj = CreateAnother(); } protected virtual AnotherBase CreateAnother() { ...
Subclass UINavigationController and then override these methods: In Objective-C: - (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleLightContent; } In Swift: override func preferredStatusBarStyle() -> UIStatusBarStyle { return .lightContent } Alternativel...
Intents can be used to broadcast messages to other components of your application (such as a running background service) or to the entire Android system. To send a broadcast within your application, use the LocalBroadcastManager class: Intent intent = new Intent("com.example.YOUR_ACTION"...
It is a common practice to place multiple <div> inside another <div>. This is usually referred to as "nesting" elements and allows for further dividing elements into subsections or aid developers with CSS styling. The <div class="outer-div"> is used to group to...
You can access SharedPreferences in several ways: Get the default SharedPreferences file: import android.preference.PreferenceManager; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Get a specific SharedPreferences file: public static final String PREF_FILE_NAM...
@Provider public class CORSResponseFilter implements ContainerResponseFilter { public void filter( ContainerRequestContext requestContext, ContainerResponseContext responseContext ) throws IOException { MultivaluedMap<String, Object> headers = responseCo...

Page 50 of 369