Tutorial by Examples: basic

An AnimatedVectorDrawable requires at least 3 components: A VectorDrawable which will be manipulated An objectAnimator which defines what property to change and how The AnimatedVectorDrawable itself which connects the objectAnimator to the VectorDrawable to create the animation The following...
Scala has a special type of function called a partial function, which extends normal functions -- meaning that a PartialFunction instance can be used wherever Function1 is expected. Partial functions can be defined anonymously using case syntax also used in pattern matching: val pf: PartialFunction...
A function can be defined with parameters using the param block: function Write-Greeting { param( [Parameter(Mandatory,Position=0)] [String]$name, [Parameter(Mandatory,Position=1)] [Int]$age ) "Hello $name, you are $age years old." } ...
const auto input = "Some people, when confronted with a problem, think \"I know, I'll use regular expressions.\""s; smatch sm; cout << input << endl; // If input ends in a quotation that contains a word that begins with "reg" and another word begining...
$a = "some string"; results in $a having the value some string. The result of an assignment expression is the value being assigned. Note that a single equal sign = is NOT for comparison! $a = 3; $b = ($a = 5); does the following: Line 1 assigns 3 to $a. Line 2 assigns 5 to $a....
To create a PostgreSQL ArrayField, we should give ArrayField the type of data we want it to store as a field as its first argument. Since we'll be storing book ratings, we will use FloatField. from django.db import models, FloatField from django.contrib.postgres.fields import ArrayField cla...
Simple form with labels... <form action="/login" method="POST"> <label for="username">Username:</label> <input id="username" type="text" name="username" /> <label for="pass">Pa...
Remarks Every motion can be used after an operator command, so the command operates on the text comprised by the movement's reach. Just like operator commands, motions can include a count, so you can move by 2words, for example. Arrows In Vim, normal arrow/cursor keys (←↓↑→) work as expected...
Generics are placeholders for types, allowing you to write flexible code that can be applied across multiple types. The advantage of using generics over Any is that they still allow the compiler to enforce strong type-safety. A generic placeholder is defined within angle brackets <>. Generic...
cURL is a tool for transferring data with URL syntax. It support HTTP, FTP, SCP and many others(curl >= 7.19.4). Remember, you need to install and enable the cURL extension to use it. // a little script check is the cURL extension loaded or not if(!extension_loaded("curl")) { die...
Suppose we have a list of teams, named like this: Team A, Team B, ..., Team Z. Then: Team [AB]: This will match either either Team A or Team B Team [^AB]: This will match any team except Team A or Team B We often need to match characters that "belong" together in some context or ano...
# For Python 2 compatibility. from __future__ import print_function import lxml.html import requests def main(): r = requests.get("https://httpbin.org") html_source = r.text root_element = lxml.html.fromstring(html_source) # Note root_element.xpath() gives a *...
class UsersController < ApplicationController def index respond_to do |format| format.html { render html: "Hello World" } end end end This is a basic controller, with the addition of the following route (in routes.rb): resources :users, only: [:index] Will...
class UsersController < ApplicationController def index respond_to do |format| format.html do render html: "Hello #{ user_params[:name] } user_params[:sentence]" end end end private def user_params if params[:name] == "john&quo...
Each time WordPress loads the page, it will run main loop. The loop is the way to iterate over all elements related to the page you are currently on. Main loop will work on a global WP_Query object. The query has a globalized method have_posts(), that allows us to loop through all results. Finally...
State in React components is essential to manage and communicate data in your application. It is represented as a JavaScript object and has component level scope, it can be thought of as the private data of your component. In the example below we are defining some initial state in the constructor f...
Group by one column Using the following DataFrame df = pd.DataFrame({'A': ['a', 'b', 'c', 'a', 'b', 'b'], 'B': [2, 8, 1, 4, 3, 8], 'C': [102, 98, 107, 104, 115, 87]}) df # Output: # A B C # 0 a 2 102 # 1 b 8 98 # 2 c 1 107 # 3 a...
XML elements often nest, have data in attributes and/or as character data. The way to capture this data is by using ,attr and ,chardata respectively for those cases. var doc = ` <parent> <child1 attr1="attribute one"/> <child2>and some cdata</child2> </p...
MediaPlayer class can be used to control playback of audio/video files and streams. Creation of MediaPlayer object can be of three types: Media from local resource MediaPlayer mediaPlayer = MediaPlayer.create(context, R.raw.resource); mediaPlayer.start(); // no need to call prepare(); create...
import "reflect" value := reflect.ValueOf(4) // Interface returns an interface{}-typed value, which can be type-asserted value.Interface().(int) // 4 // Type gets the reflect.Type, which contains runtime type information about // this value value.Type().Name() // int value.SetInt(5)...

Page 9 of 43