Tutorial by Examples: el

The following code snippet shows how to open the Google Play Store Listing of your app in a safe way. Usually you want to use it when asking the user to leave a review for your app. private void openPlayStore() { String packageName = getPackageName(); Intent playStoreIntent = new Intent(I...
To get a verbose list of all devices connected to adb, write the following command in your terminal: adb devices -l Example Output List of devices attached ZX1G425DC6 device usb:336592896X product:shamu model:Nexus_6 device:shamu 013e4e127e59a868 device usb:337641472X produc...
If you need to remove one or more elements from a slice, or if you need to work with a sub slice of another existing one; you can use the following method. Following examples uses slice of int, but that works with all type of slice. So for that, we need a slice, from witch we will remove some ...
FrameLayout is designed to block out an area on the screen to display a single item. You can, however, add multiple children to a FrameLayout and control their position within the FrameLayout by assigning gravity to each child, using the android:layout_gravity attribute. Generally, FrameLayout is ...
Create a simple table create table MY_table ( what varchar2(10), who varchar2(10), mark varchar2(10) ); Insert values (you can omit target columns if you provide values for all columns) insert into my_table (what, who, mark) values ('Hello', 'world', '!' ); insert into my_table ...
Variables inside single quotes ' don't get expanded by POSIX compatible shells, so using a shell variable in a sed substitution requires the use of double quotes " instead of single quotes ': $ var="he" $ echo "hello" | sed "s/$var/XX/" XXllo $ var="he&q...
Generally, the syntax is: SELECT <column names> FROM <table name> WHERE <condition> For example: SELECT FirstName, Age FROM Users WHERE LastName = 'Smith' Conditions can be complex: SELECT FirstName, Age FROM Users WHERE LastName = 'Smith' AND (City = 'New York' OR C...
When a column name matches a reserved keyword, standard SQL requires that you enclose it in double quotation marks: SELECT "ORDER", ID FROM ORDERS Note that it makes the column name case-sensitive. Some DBMSes have proprietary ways of quoting names. For example, SQL Serve...
This will delete all rows that match the WHERE criteria. DELETE FROM Employees WHERE FName = 'John'
Omitting a WHERE clause will delete all rows from a table. DELETE FROM Employees See TRUNCATE documentation for details on how TRUNCATE performance can be better because it ignores triggers and indexes and logs to just delete the data.
if condition: body else: body The else statement will execute it's body only if preceding conditional statements all evaluate to False. if True: print "It is true!" else: print "This won't get printed.." # Output: It is true! if False: print &...
To catch a long click and use it you need to provide appropriate listener to button: View.OnLongClickListener listener = new View.OnLongClickListener() { public boolean onLongClick(View v) { Button clickedButton = (Button) v; String buttonText = clickedButton.getText().toStri...
As Array conforms to SequenceType, we can use map(_:) to transform an array of A into an array of B using a closure of type (A) throws -> B. For example, we could use it to transform an array of Ints into an array of Strings like so: let numbers = [1, 2, 3, 4, 5] let words = numbers.map { Stri...
There are two things you will need to know when writing a "hello world" application in Erlang: The source code is written in the erlang programming language using the text editor of your choice The application is then executed in the erlang virtual machine. In this example we will inte...
To apply a function to every item in an array, use array_map(). This will return a new array. $array = array(1,2,3,4,5); //each array item is iterated over and gets stored in the function parameter. $newArray = array_map(function($item) { return $item + 1; }, $array); $newArray now is a...
You can access the elements of an array by their indices. Array index numbering starts at 0. %w(a b c)[0] # => 'a' %w(a b c)[1] # => 'b' You can crop an array using range %w(a b c d)[1..2] # => ['b', 'c'] (indices from 1 to 2, including the 2) %w(a b c d)[1...2] # => ['b'] (indic...
The following code creates a simple user interface containing a single Button that prints a String to the console on click. import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; import javafx.scene.contr...
One of the first questions people have when they begin to use PowerShell for scripting is how to manipulate the output from a cmdlet to perform another action. The pipeline symbol | is used at the end of a cmdlet to take the data it exports and feed it to the next cmdlet. A simple example is using...
You may wish to use Model Factories within your seeds. This will create 3 new users. use App\Models\User; class UserTableSeeder extends Illuminate\Database\Seeder{ public function run(){ factory(User::class)->times(3)->create(); } } You may also want to define ...
The following is the original "Hello, World!" program from the book The C Programming Language by Brian Kernighan and Dennis Ritchie (Ritchie was the original developer of the C programming language at Bell Labs), referred to as "K&R": K&R #include <stdio.h> ma...

Page 14 of 145