Tutorial by Examples

Leaflet is an open-source JavaScript library for making dynamic maps for the web. RStudio wrote R bindings for Leaflet, available through its leaflet package, built with htmlwidgets. Leaflet maps integrate well with the RMarkdown and Shiny ecosystems. The interface is piped, using a leaflet() funct...
PHP is a loosely typed language. This means that, by default, it doesn't require operands in an expression to be of the same (or compatible) types. For example, you can append a number to a string and expect it to work. var_dump ("This is example number " . 1); The output will be: ...
When reading from a file, we want to be able to know when we've reached the end of that file. Knowing that fgets() returns false at the end of the file, we might use this as the condition for a loop. However, if the data returned from the last read happens to be something that evaluates as boolean f...
Switch statements use non-strict comparison to determine matches. This can lead to some nasty surprises. For example, consider the following statement: switch ($name) { case 'input 1': $mode = 'output_1'; break; case 'input 2': $mode = 'output_2'; bre...
When you install Oracle 11g or 12cR1, an older version of Apex is pre-installed. It is highly recommended to upgrade it to the latest version. Go to apex.oracle.com and download the latest version of Apex. Follow the documentation for the specific version to install it. Important Docu...
Add the following dependency to the build.gradle file: compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' Add the following permissions to the AndroidManifest.xml file: <uses-permission android:name="android.permission.INTERNET" /> <uses-permiss...
Load an image, decode it into a bitmap, and display the bitmap in an ImageView (or any other view which implements the ImageAware interface): ImageLoader.getInstance().displayImage(imageUri, imageView); Load an image, decode it into a bitmap, and return the bitmap to a callback: ImageLo...
A very useful and logical follow-up to histograms would be to plot the smoothed density function of a random variable. A basic plot produced by the command plot(density(rnorm(100)),main="Normal density",xlab="x") would look like You can overlay a histogram and a density...
To change MySQL's root user password: Step 1: Stop the MySQL server. in Ubuntu or Debian: sudo /etc/init.d/mysql stop in CentOS, Fedora or Red Hat Enterprise Linux: sudo /etc/init.d/mysqld stop Step 2: Start the MySQL server without the privilege system. sudo mysqld_safe --skip-grant-tab...
strsplit is a useful function for breaking up a vector into an list on some character pattern. With typical R tools, the whole list can be reincorporated to a data.frame or part of the list might be used in a graphing exercise. Here is a common usage of strsplit: break a character vector along a co...
Haskell has list comprehensions, which are a lot like set comprehensions in math and similar implementations in imperative languages such as Python and JavaScript. At their most basic, list comprehensions take the following form. [ x | x <- someList ] For example [ x | x <- [1..4] ] -...
Here is an example Picasso Circle Transform class based on the original, with the addition of a thin border, and also includes functionality for an optional separator for stacking: import android.graphics.Bitmap; import android.graphics.BitmapShader; import android.graphics.Canvas; import androi...
A 'tab bar' is commonly found in most iOS apps and is used to present distinct views in each tab. To create a tab bar controller using the interface builder, drag a tab bar Controller from the Object Library into the canvas. By default a tab bar controller comes with two views. To add additional...
Using the Story Board: Select the tab bar item from the corresponding view controller and go to the attributes inspector If you want a built-in icon and title, set the 'System Item' to the corresponding value. For a custom icon, add the required images to the assets folder and set the 'System It...
If you need an ActiveRecord method to raise an exception instead of a false value in case of failure, you can add ! to them. This is very important. As some exceptions/failures are hard to catch if you don't use ! on them. I recommended doing this in your development cycle to write all your ActiveRe...
You can find records by any field in your table using find_by. So, if you have a User model with a first_name attribute you can do: User.find_by(first_name: "John") #=> #<User id: 2005, first_name: "John", last_name: "Smith"> Mind that find_by doesn't thr...
If you need to delete a lot of records quickly, ActiveRecord gives .delete_all method. to be called directly on a model, to delete all records in that table, or a collection. Beware though, as .delete_all does not instantiate any object hence does not provide any callback (before_* and after_destroy...
The unchecked keyword prevents the compiler from checking for overflows/underflows. For example: const int ConstantMax = int.MaxValue; unchecked { int1 = 2147483647 + 10; } int1 = unchecked(ConstantMax + 10); Without the unchecked keyword, neither of the two addition operations will co...
for loop: arr=(a b c d e f) for i in "${arr[@]}";do echo "$i" done Or for ((i=0;i<${#arr[@]};i++));do echo "${arr[$i]}" done while loop: i=0 while [ $i -lt ${#arr[@]} ];do echo "${arr[$i]}" i=$(expr $i + 1) done Or i=0...
Break multiple loop: arr=(a b c d e f) for i in "${arr[@]}";do echo "$i" for j in "${arr[@]}";do echo "$j" break 2 done done Output: a a Break single loop: arr=(a b c d e f) for i in "${arr[@]}";do e...

Page 353 of 1336