Tutorial by Examples: c

xml of the Dialog: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="mat...
Add below to your build.gradle out of android tag: // Apply plug-in to app. apply plugin: 'com.google.gms.google-services' Add below helper class to your util package: /** * Created by Andy */ public class GoogleSignInHelper implements GoogleApiClient.OnConnectionFailedListener, ...
Rails provides a lot of generators, for controllers too of course. You can generate a new controller by running this command in your app folder rails generate controller NAME [action action] [options] Note: You can also use rails g alias to invoke rails generate For example, to generate a cont...
You can rescue a RecordNotFound exception with a redirect instead of showing an error page: class ApplicationController < ActionController::Base # your other stuff rescue_from ActiveRecord::RecordNotFound do |exception| redirect_to root_path, 404, alert: I18n.t("errors.record...
Database configuration of a rails project lies in a file config/database.yml. If you create a project using rails new command and don't specify a database engine to be used then rails uses sqlite as the default database. A typical database.yml file with default configuration will look similar to fol...
Callbacks offer a way to extend the functionality of a function (or method) without changing its code. This approach is often used in modules (libraries / plugins), the code of which is not supposed to be changed. Suppose we have written the following function, calculating the sum of a given array ...
You can get a Model class from a Controller name this way (context is Controller class): class MyModelController < ActionController::Base # Returns corresponding model class for this controller # @return [ActiveRecord::Base] def corresponding_model_class # ... add some validation...
In the case of a multi-project gradle build, you may sometimes need to depend on another project in your build. To accomplish this, you'd enter the following in your project's dependencies: dependencies { compile project(':OtherProject') } Where ':OtherProject' is the gradle path for the p...
Consumable Managed Products are products that can be bought multiple times such as in-game currency, game lives, power-ups, etc. In this example, we are going to implement 4 different consumable managed products "item1", "item2", "item3", "item4". Steps in...
DISCLAIMER: Scaffolding is not recommended unless it's for very conventional CRUD apps/testing. This may generate a lot of files(views/models/controllers) that are not needed in your web application thus causing headaches(bad :(). To generate a fully working scaffold for a new object, including mod...
console.count([obj]) places a counter on the object's value provided as argument. Each time this method is invoked, the counter is increased (with the exception of the empty string ''). A label together with a number is displayed in the debugging console according to the following format: [label]: ...
Debug.log's second argument is always returned, so you could write code like the following and it would just work: update : Msg -> Model -> (Model, Cmd Msg) update msg model = case Debug.log "The Message" msg of Something -> ... Replacing case msg o...
Any lodash collection method has two syntaxes. Without chaining: var arr1 = [10, 15, 20, 25, 30, 15, 25, 35]; var arr2 = _.filter(arr1, function(item){ return item % 10 === 5 }); // arr2 now contains [15, 25, 15, 25, 35] var arr3 = _.uniq(arr2); // arr3 now contains [15, 25, 35] var arr...
There are a few libraries for unit testing in Common Lisp FiveAM Prove, with a few unique features like extensive test reporters, colored output, report of test duration and asdf integration. Lisp-Unit2, similar to JUnit Fiasco, focusing on providing a good testing experience from the REPL. Su...
The Java language provides 4 operators that perform bitwise or logical operations on integer or boolean operands. The complement (~) operator is a unary operator that performs a bitwise or logical inversion of the bits of one operand; see JLS 15.15.5.. The AND (&) operator is a binary operat...
By default, all the .panel does is apply some basic border and padding to contain some content. <div class="panel panel-default"> <div class="panel-body"> Basic panel example </div> </div>
The following example can be tested on https://ellie-app.com/m9tk39VpQg/0. import Html exposing (..) import Json.Decode payload = """ ["fu", "bar"] """ main = Json.Decode.decodeString decoder payload -- Ok ["fu","b...
The following examples can be tested on https://ellie-app.com/m9vmQ8NcMc/0. import Html exposing (..) import Json.Decode payload = """ [ { "bark": true, "tag": "dog", "name": "Zap", "playful": true } , { "w...
Content scripts can be declared in manifest.json to be always injected into pages that match a set of URL patterns. Minimal example "content_scripts" : [ { "js": ["content.js"], "css": ["content.css"] "matches": [&quot...
If, instead of always having a content script injected based on the URL, you want to directly control when a content script is injected, you can use Programmatic Injection. Minimal example JavaScript chrome.tabs.executeScript({file: "content.js"}); CSS chrome.tabs.insert...

Page 224 of 826