25 Oct 2013 Here's a simple function that will remove curly quotes aka smart quotes from your strings. Very useful if you enter data from MS Word files or other sources that may use weird unicode characters. Use it as an input cleaning step before saving the string data.
function remove_curly_quotes($text) {
// First, replace UTF-8 characters.
$text = str_replace(array("\xe2\x80\x98", "\xe2\x80\x99", "\xe2\x80\x9c", "\xe2\x80\x9d", "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x80\xa6"), array("'", "'", '"', '"', '-', '--',
'...'), $text);
// Next, replace their Windows-1252 equivalents.
$text = str_replace(array(chr(145), chr(146), chr(147), chr(148), chr(150), chr(151), chr(133)), array("'", "'", '"', '"', '-', '--', '...'), $text);
return $text;
}
25 Oct 2013 I needed to hit a number of files on a remote HTTP server with an index ranging from 1 to 150 and my first instinct was to use wget with some sort of a loop (bash script seemed like the most logical thing to do).
Then I realized that I can do the same thing in a simple oneliner using ‘curl’
It’s super easy using the following info:
You can specify multiple URLs or parts of URLs by writing part sets within braces as in:
http://site.{one,two,three}.com
or you can get sequences of alphanumeric series by using []
as in:
ftp://ftp.numericals.com/file[1-100].txt ftp://ftp.numericals.com/file[001-100].txt (with leading zeros) ftp://ftp.letters.com/file[a-z].txt
Nested sequences are not supported, but you can use several ones next to each other:
http://any.org/archive[1996-1999]/vol[1-4]/part{a,b,c}.html
You can specify any amount of URLs on the command line. They will be fetched in a sequential manner in the specified order. You can specify a step counter for the ranges to get every Nth number or letter:
yo
http://www.numericals.com/file[1-100:10].txt http://www.letters.com/file[a-z:2].txt
08 Sep 2013 Here’s a simple code snippet to calculate approximate physical size of the screen of any Android device. If you find that useful or have suggestions to improve, your thoughts and feedback are welcome in the comments.
/**
* Calculates an approximation to the diagonal size of the screen. Based on the width and height pixels, the # of pixels in diagonal are calculated and then using the density DPI
* the pixels are translated into physical dimension in pixels
*
* @param activity
* @return
*/
public static double getDiagonalSize(Activity activity) {
DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
return Math.sqrt((metrics.widthPixels * metrics.widthPixels)
+ (metrics.heightPixels * metrics.heightPixels))
/ metrics.densityDpi;
}
11 Jul 2013 Quick reference for available Facebook Graph API actions with accompanying parameters:
27 May 2013
These are the natural oils that can be used as SPF protection agains bad UV rays. It should be much more healthy than using a sun block as the sun block itself is cancerogenic substance