Tutorial by Examples: e

Creating a Window with OpenGL context (extension loading through GLEW): #define GLEW_STATIC #include <GL/glew.h> #include <SDL2/SDL.h> int main(int argc, char* argv[]) { SDL_Init(SDL_INIT_VIDEO); /* Initialises Video Subsystem in SDL */ /* Setting up OpenGL version a...
Create User Model # Schema: User(token:string, auth_token:string) class User < ActiveRecord::Base has_secure_token has_secure_token :auth_token end Now when you create a new user a token and auth_token are automatically generated user = User.new user.save user.token # => "p...
Matlab allows some very trivial mistakes to go by silently, which might cause an error to be raised much later in the run - making debugging hard. If you assume something about your variables, validate it. function out1 = get_cell_value_at_index(scalar1,cell2) assert(isscalar(scalar1),'1st input ...
$username = 'Hadibut'; $email = '[email protected]'; $variables = compact('username', 'email'); // $variables is now ['username' => 'Hadibut', 'email' => '[email protected]'] This method is often used in frameworks to pass an array of variables between two components.
The entries() method returns a new Array Iterator object that contains the key/value pairs for each index in the array. 6 var letters = ['a','b','c']; for(const[index,element] of letters.entries()){ console.log(index,element); } result 0 "a" 1 "b" 2 "c"...
Images, static data, sounds, etc. are resources in a Playground. If the Project Navigator is hidden, choose View > Navigators > Show Project Navigator (⌘1) There are several ways to add files Drag your resources to the Resources folder or Select the Resources folder and choose File &gt...
You can display an SVG file within an HTML document, by specifying it as a background image in CSS. For example: .element { background-size: 100px 100px; background: url(my_svg_file.svg); height: 100px; width: 100px; } If the dimensions specified in your SVG file are larger ...
The Null-Coalescing operator ?? will return the left-hand side when not null. If it is null, it will return the right-hand side. object foo = null; object bar = new object(); var c = foo ?? bar; //c will be bar since foo was null The ?? operator can be chained which allows the removal of if...
Often times you will have reason to catch when your program is being told to stop by the OS and take some actions to preserve the state, or clean up your application. To accomplish this you can use the os/signal package from the standard library. Below is a simple example of assigning all signals fr...
Databings are essential for working with XAML. The XAML dialect for UWP apps provides a type of binding: the {x:Bind} markup extension. Working with {Binding XXX} and {x:Bind XXX} is mostly equivalent, with the difference that the x:Bind extension works at compile time, which enables better debuggi...
Most of the time you need to import namespaces in your XAML file. How this is done is different for the different XAML variants. For Windows Phone, Silverlight, WPF use the clr-namespace syntax: <Window ... xmlns:internal="clr-namespace:rootnamespace.namespace" xmlns:exte...
By default, RethinkDB binds all services to 127.0.0.1. So this following example will persist data to the host_data_path on the container's host machine and available to 127.0.0.1 on the standard ports. ServiceFlagDefault PortDriver--driver-port28015Cluster--cluster-port29015HTTP WebUI--http-port80...
When deploying RethinkDB in production, you want to either turn off or lock down the WebUI. This will only respond to localhost to access the WebUI allowing you to SSH Tunnel to the host machine and access it for diagnostics and troubleshooting. docker run -d \ -v host_data_path:/data \ ret...
By default, Android will display Toast messages at the bottom of the screen even if the keyboard is showing. This will show a Toast message just above the keyboard. public void showMessage(final String message, final int length) { View root = findViewById(android.R.id.content); Toast toas...
ndk-build NDK_PROJECT_PATH=PROJECT_PATH APP_BUILD_SCRIPT=MyAndroid.mk
Currently it contains rules for following libraries:- ButterKnife RxJava Android Support Library Android Design Support Library Retrofit Gson and Jackson Otto Crashlitycs Picasso Volley OkHttp3 Parcelable #Butterknife -keep class butterknife.** { *; } -keepnames class * { @butterk...
For enabling ProGuard configurations for your application you need to enable it in your module level gradle file. you need to set the value of minifyEnabled true. You can also enable shrinkResources true which will remove resources that ProGuard flaggs as unused. buildTypes { release { ...
public class ShakeDetector implements SensorEventListener { private static final float SHAKE_THRESHOLD_GRAVITY = 2.7F; private static final int SHAKE_SLOP_TIME_MS = 500; private static final int SHAKE_COUNT_RESET_TIME_MS = 3000; private OnShakeListener mListener; pri...
First of all you need to setup your project adding Firebase to your Android project following the steps described in this topic. Set up Firebase and the FCM SDK Add the FCM dependency to your app-level build.gradle file dependencies { compile 'com.google.firebase:firebase-messaging:11.0.4' } ...
This annotation ensures that only the valid integer constants that you expect are used. The following example illustrates the steps to create an annotation: import android.support.annotation.IntDef; public abstract class Car { //Define the list of accepted constants @IntDef({MICROCA...

Page 538 of 1191