This tutorial explains how to download Image using AsyncTask in Android. The example below download image while showing progress bar while during download.
Understanding Android AsyncTask
Async task enables you to implement MultiThreading without get Hands dirty into threads. AsyncTask enables pro...
Inline style
You can manipulate the inline CSS style of an HTML element by simply reading or editing its style property.
Assume the following element:
<div id="element_id" style="color:blue;width:200px;">abc</div>
With this JavaScript applied:
var element = doc...
You can install Json.Net into your Visual Studio Project in 1 of 2 ways.
Install Json.Net using the Package Manager Console.
Open the Package Manager Console window in Visual Studio either by typing package manager console in the Quick Launch box and selecting it
or by clicking View -> O...
Immutable types are types that when changed create a new version of the object in memory, rather than changing the existing object in memory. The simplest example of this is the built-in string type.
Taking the following code, that appends " world" onto the word "Hello"
string ...
A dotfile is a file whose names begin with a .. These are normally hidden by ls and not listed unless requested.
For example the following output of ls:
$ ls
bin pki
The -a or --all option will list all files, including dotfiles.
$ ls -a
. .ansible .bash_logout .bashrc .lesshst ...
Matplotlib axes are two-dimensional by default. In order to create three-dimensional plots, we need to import the Axes3D class from the mplot3d toolkit, that will enable a new kind of projection for an axes, namely '3d':
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fi...
Create a DataFrame from multiple lists by passing a dict whose values lists. The keys of the dictionary are used as column labels. The lists can also be ndarrays. The lists/ndarrays must all be the same length.
import pandas as pd
# Create DF from dict of lists/ndarrays
df = pd.DataFrame({'...
In Python 3 the cmp built-in function was removed, together with the __cmp__ special method.
From the documentation:
The cmp() function should be treated as gone, and the __cmp__() special method is no longer supported. Use __lt__() for sorting, __eq__() with __hash__(), and other rich compariso...
Function level annotations help IDEs identify return values or potentially dangerous code
/**
* Adds two numbers together.
*
* @param Int $a First parameter to add
* @param Int $b Second parameter to add
* @return Int
*/
function sum($a, $b)
{
return (int) $a + $b;
}
/**
* ...
File level metadata applies to all the code within the file and should be placed at the top of the file:
<?php
/**
* @author John Doe ([email protected])
* @copyright MIT
*/
Let's use *norm as an example. From the documentation:
dnorm(x, mean = 0, sd = 1, log = FALSE)
pnorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)
qnorm(p, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE)
rnorm(n, mean = 0, sd = 1)
So if I wanted to know the value of a standard no...
The URLVariables class allows you to define data to be sent along with a URLRequest.
Example:
var variables:URLVariables = new URLVariables();
variables.prop = "hello";
variables.anotherProp = 10;
var request:URLRequest = new URLRequest('http://someservice.com');
request.data = v...
This is the built-in way to deal with "exceptions" without relying on third party libraries like Try::Tiny.
my $ret;
eval {
$ret = some_function_that_might_die();
1;
} or do {
my $eval_error = $@ || "Zombie error!";
handle_error($eval_error);
};
# use $ret
...
Current file
You can get the name of the current PHP file (with the absolute path) using the __FILE__ magic constant. This is most often used as a logging/debugging technique.
echo "We are in the file:" , __FILE__ , "\n";
Current directory
To get the absolute path to the di...
The Flex compiler (mxmlc) is one of the most important parts of the Flex SDK. You can edit AS3 code in any text editor you like. Create a main class file that extends from DisplayObject.
You can trigger builds at the command line as follows:
mxmlc -source-path="." -default-size [width in...
To round a value to the nearest multiple of x:
function roundTo(value:Number, to:Number):Number {
return Math.round(value / to) * to;
}
Example:
roundTo(8, 5); // 10
roundTo(17, 3); // 18
In a Service Provider register method we can bind an interface to an implementation:
public function register()
{
App::bind( UserRepositoryInterface::class, EloquentUserRepository::class );
}
From now on, everytime the app will need an instance of UserRepositoryInterface, Larave...