Tutorial by Examples: c

This technique details how to ensure that your .apk has been signed with your developer certificate, and leverages the fact that the certificate remains consistent and that only you have access to it. We can break this technique into 3 simple steps: Find your developer certificate signature. Em...
The following are some of the more common/useful shortcuts. These are based on the default IntelliJ shortcut map. You can switch to other common IDE shortcut maps via File -> Settings -> Keymap -> <Choose Eclipse/Visual Studio/etc from Keymaps dropdown> ActionShortcutFormat codeCTRL...
Enable Offline Work: Click File -> Settings. Search for "gradle" and click in Offline work box. Go to Compiler (in same settings dialog just below Gradle) and add --offline to Command-line Options text box. Improve Gradle Performance Add following two line of code in your gradle...
We want to process data in parallel. Let's populate source with some data: source = Queue.new data = (1..100) data.each { |e| source << e } Then create some workers to process data: (1..16).to_a.map do Thread.new do until source.empty? item = source.pop sleep 0.5 ...
We want to process data in parallel and push it down the line to be processed by other workers. Since Workers both consume and produce data we have to create two queues: first_input_source = Queue.new first_output_sink = Queue.new 100.times { |i| first_input_source << i } First wave of...
syncer = Queue.new a = Thread.new do syncer.pop puts "this happens at end" end b = Thread.new do puts "this happens first" STDOUT.flush syncer << :ok end [a, b].map(&:join)
q = Queue.new q << 1 q << 2 a = Array.new a << q.pop until q.empty? Or a one liner: [].tap { |array| array < queue.pop until queue.empty? }
Values passed as enum constructor arguments can be captured into variables by use of pattern matching. Assume the following enum: enum Color { RGB(r : Int, g : Int, b : Int); HSV(h : Int, s : Float, v : Float); } The red channel value can be captured as follows: var color = Color.RG...
Enum constructors can be matched using pattern matching. Assume the following enum: enum Color { Red; Green; Blue; RGB(r : Int, g : Int, b : Int); } Colours with only a green channel value can be matched as follows: var color = Color.RGB(0, 127, 0); var isGreenOnly = swit...
BackAndroid.addEventListener('hardwareBackPress', function() { if (!this.onMainScreen()) { this.goBack(); return true; } return false; }); Note: this.onMainScreen() and this.goBack() are not built in functions, you also need to implement those. (https://github.c...
To set LFS options that apply to all clones, create and commit a file named .lfsconfig at the repository root. This file can specify LFS options the same way as allowed in .git/config. For example, to exclude a certain file from LFS fetches be default, create and commit .lfsconfig with the followin...
In Groovy, the inject() method is one of the cumulative methods that allows us to add (or inject) new functionality into any object that implements the inject() method. In the case of a Collection, we can apply a closure to a collection of objects uniformly and then collate the results into a single...
Complete the Installation and setup part to connect your app to Firebase. This will create the project in Firebase. Add the dependency for Firebase CrashReporting to your module-level build.gradle file: compile 'com.google.firebase:firebase-crash:9.4.0'
To get the the exact size of a UIButton's text based on its font, use the function intrinsicContentSize. Swift button.intrinsicContentSize.width Objective-C button.intrinsicContentSize.width;
NSString provides method boundingRectWithSize which can be used to predict the resulting CGSize of a UILabel based on its text and font without the need of creating a UILabel Objective-C [[text boundingRectWithSize:maxSize options:(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineF...
SilverStripe has reasonably good support for submitting form data using AJAX requests. Below is example code of how to set up a basic Form that accepts submissions by both AJAX and traditional default browser behaviour (as is good practice). Adding the form to our controller First we need to defin...
The following class is used to demonstrate, how instances of classes can be created: JavaFX 8 The annotation in Person(@NamedArg("name") String name) has to be removed, since the @NamedArg annotation is unavailable. package fxml.sample; import javafx.beans.NamedArg; import javafx....
public String getAppVersion() throws PackageManager.NameNotFoundException { PackageManager manager = getApplicationContext().getPackageManager(); PackageInfo info = manager.getPackageInfo( getApplicationContext().getPackageName(), ...
You should use this when you have two text fields that should receive exactly the same content. For example, you may want to confirm an email address or a password. This validation creates a virtual attribute whose name is the name of the field that has to be confirmed with _confirmation appended. ...
When using Autolayout with a UIScrollView, it does NOT resize properly depending on the size of its contents or subviews. In order to get a UIScrollView to automatically scroll when its contents become too large to fit in the visible area, we need to add a ContentView and some constraints that allo...

Page 395 of 826