Tutorial by Examples: o

Installation Volley JCenter Gradle Import //in your project's app level build.gradle compile 'com.android.volley:volley:1.0.0' Create a subclass of Application public class AppController extends Application { public static final String TAG = AppController.class .getSimpleN...
.set-colors(@type) when (@type = error) { @base-color: #d9534f; background: @base-color; color: contrast(@base-color, lighten(@base-color, 25%), darken(@base-color, 25%)); border: 1px solid contrast(@base-color, lighten(@base-color, 25%), darken(@base-color, 25%)); } .set-colors(@type)...
There are two common ways to list all processes on a system. Both list all processes running by all users, though they differ in the format they output (the reason for the differences are historical). ps -ef # lists all processes ps aux # lists all processes in alternative format (BSD) Thi...
An array containing the full version information split into elements, much more convenient than $BASH_VERSION if you're just looking for the major version: ~> $ for ((i=0; i<=5; i++)); do echo "BASH_VERSINFO[$i] = ${BASH_VERSINFO[$i]}"; done BASH_VERSINFO[0] = 3 BASH_VERSINFO[1] =...
Shows the version of bash that is running, this allows you to decide whether you can use any advanced features: ~> $ echo $BASH_VERSION 4.1.2(1)-release
The default editor that will be involked by any scripts or programs, usually vi or emacs. ~> $ echo $EDITOR vi
The home directory of the user ~> $ echo $HOME /home/user
The hostname assigned to the system during startup. ~> $ echo $HOSTNAME mybox.mydomain.com
This variable identifies the hardware, it can be useful in determining which binaries to execute: ~> $ echo $HOSTTYPE x86_64
An array containing the numbers of groups the user is in: #!/usr/bin/env bash echo You are assigned to the following groups: for group in ${GROUPS[@]}; do IFS=: read -r name dummy number members < <(getent group $group ) printf "name: %-10s number: %-15s members: %s\n" &qu...
Outputs the line number in the current script. Mostly useful when debugging scripts. #!/bin/bash # this is line 2 echo something # this is line 3 echo $LINENO # Will output 4
OLDPWD (OLDPrintWorkingDirectory) contains directory before the last cd command: ~> $ cd directory directory> $ echo $OLDPWD /home/user
Returns information about the type of OS running on the machine, eg. ~> $ echo $OSTYPE linux-gnu
The number of seconds a script has been running. This can get quite large if shown in the shell: ~> $ echo $SECONDS 98834
A readonly list of the options bash is supplied on startup to control its behaviour: ~> $ echo $SHELLOPTS braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
LINQ provides a built-in function for checking the equality of two IEnumerables, and that function can be used on arrays. The SequenceEqual function will return true if the arrays have the same length and the values in corresponding indices are equal, and false otherwise. int[] arr1 = { 3, 5, 7 };...
Consider this example function to check if a host is up: is_alive() { ping -c1 "$1" &> /dev/null } This function sends a single ping to the host specified by the first function parameter. The output and error output of ping are both redirected to /dev/null, so the functi...
Comments in Sass vs. Scss are largely similar, except when multi-lines are concerned. SASS multi-lines are indentation-sensitive, while SCSS relies on comment terminators. Single-Line Comment style.scss // Just this line will be commented! h1 { color: red; } style.sass // Exactly the same ...
ssh -p 21 [email protected] <<EOF echo 'printing pwd' echo "\$(pwd)" ls -a find '*.txt' EOF $ is escaped because we do not want it to be expanded by the current shell i.e $(pwd) is to be executed on the remote shell. Another way: ssh -p 21 [email protected] <...
sudo -s <<EOF a='var' echo 'Running serveral commands with sudo' mktemp -d echo "\$a" EOF $a needs to be escaped to prevent it to be expanded by the current shell Or sudo -s <<'EOF' a='var' echo 'Running serveral commands with sudo' mktemp -d e...

Page 498 of 1038