This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// http://en.wikipedia.org/wiki/ISO_3166-1 | |
// these are iso | |
$country_codes = array( | |
'AD' => "Andorra", | |
'AE' => "United Arab Emirates", | |
'AF' => "Afghanistan", | |
'AG' => "Antigua and Barbuda", | |
'AI' => "Anguilla", | |
'AL' => "Albania", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* this turns numbers like 45000 into 45K */ | |
print "0=" . numeric_abbr(0) . "\n\n"; | |
print "9=" . numeric_abbr(9) . "\n\n"; | |
print "10=" . numeric_abbr(10) . "\n\n"; | |
print "100=" . numeric_abbr(100) . "\n\n"; | |
print "999=" . numeric_abbr(999) . "\n\n"; | |
print "1000=" . numeric_abbr(1000) . "\n\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$column_width = 60; | |
$gutter_width = 20; | |
$columns = 12; | |
if ( isset($_GET['column_width']) ) { | |
$column_width = $_GET['column_width']; | |
} | |
if ( isset($_GET['gutter_width']) ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This script will generate a grid overlay for | |
* a 960 style grid given three params, column_width, gutter_width, height. | |
* and columns. These will default if not provided. The result | |
* will be a PNG file. The height specifies the height of the image which | |
* defaults to 1. | |
*/ | |
$expires = 60*60*24* 30; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.SimpleDateFormat; | |
import java.util.*; | |
import java.io.*; | |
import java.text.DateFormat; | |
// this seems to work for everything but hindi and thailand | |
public class LocaleDates { | |
static public void main(String[] args) throws IOException { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ISO 3166 Country Code | ISO639-2 Country Code | Country | ISO 3166 Country Code | ISO639-2 Lang | Language | Date Format | |
---|---|---|---|---|---|---|---|
ALB | AL | Albania | sqi | sq | Albanian | yyyy-MM-dd | |
ARE | AE | United Arab Emirates | ara | ar | Arabic | dd/MM/yyyy | |
ARG | AR | Argentina | spa | es | Spanish | dd/MM/yyyy | |
AUS | AU | Australia | eng | en | English | d/MM/yyyy | |
AUT | AT | Austria | deu | de | German | dd.MM.yyyy | |
BEL | BE | Belgium | fra | fr | French | d/MM/yyyy | |
BEL | BE | Belgium | nld | nl | Dutch | d/MM/yyyy | |
BGR | BG | Bulgaria | bul | bg | Bulgarian | yyyy-M-d | |
BHR | BH | Bahrain | ara | ar | Arabic | dd/MM/yyyy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
print get_file('http://www.google.com'); | |
function get_file($url) { | |
$curl = curl_init(); | |
$options = default_ops(array(CURLOPT_URL => $url)); | |
curl_setopt_array($curl, $options); | |
$output = curl_exec($curl); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myParseIni($iniStr, $processSections = false) { | |
// this will split on lines and then remove comments | |
$lines = preg_grep('|^\s*;|', preg_split('/$\R?^/m', $iniStr), PREG_GREP_INVERT); | |
$results = array(); | |
$section = null; | |
foreach ($lines as $line) { | |
// print $line; | |
$matches = array(); | |
if ( $processSections && preg_match('/^\s*\[\s*([^\s:]+)\s*(?::\s*(\S+))?\s*\]\s*$/', $line, $matches) ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$context = json_decode('{"this":{"that":{"some":[0,1,{"in":{"some":{"place":6}}}]}}}'); | |
if ( ! $context ) throw new Exception('json parsing failed'); | |
print OgnlPath::getValue('this.that.some[2].in.some.place', $context ); | |
class OgnlPath { | |
public static function getValue($expression, $context) { | |
$tokens = preg_split('/(\[[^\]]+\])|(?:\.)/', $expression, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); | |
print_r($tokens); | |
//print "context is " . print_r($context, true) . "\n"; | |
foreach ($tokens as $index => $match) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$am = new ArrayMath(); | |
$am->options = array('a'=>'sum', 'b'=>'avg', 'c'=>'max', 'd'=>'min', 'e'=>'prod'); | |
$result = array( | |
array('a'=>1, 'b'=>2, 'c'=>3, 'd'=>5, 'e'=>2), | |
array('a'=>2, 'b'=>3, 'c'=>4, 'd'=>6, 'e'=>3), | |
array('a'=>3, 'b'=>4, 'c'=>0, 'd'=>7, 'e'=>4) | |
); | |
print_r($am->run($result)); | |
/* RETURNS |
OlderNewer