This file contains 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 | |
$location = $_GET['q']; | |
$url = 'http://www.google.com/ig/api?weather='.urlencode($location); | |
$process = curl_init($url); | |
curl_setopt($process, CURLOPT_TIMEOUT, 30); | |
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE); | |
$response = curl_exec($process); | |
$xml = simplexml_load_string($response); | |
$temperature = $xml->weather->current_conditions->temp_c['data'].'°C'; | |
$conditions = $xml->weather->current_conditions->condition['data']; |
This file contains 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
location=`echo Miami Florida | sed -e 's/ /+/'` | |
curl -s "http://mysite.com/weather.php?q=$location" | sed -e 's/°/°/' |
This file contains 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 | |
class API { | |
public static function call($url) { | |
$user = Session::get('username'); | |
$password = Session::get('password'); | |
$process = curl_init($url); | |
curl_setopt($process, CURLOPT_USERPWD, $user.':'.Crypter::decrypt($password)); | |
curl_setopt($process, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); | |
curl_setopt($process, CURLOPT_TIMEOUT, 30); | |
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE); |
This file contains 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 | |
class Date { | |
public static function torelative($date) { | |
$diff = strtotime('-1 day') - strtotime($date); | |
if ($diff>0) { | |
if ($diff<60) | |
return $diff . " second" . self::plural($diff) . " ago"; | |
$diff = round($diff/60); | |
if ($diff<60) | |
return $diff . " minute" . self::plural($diff) . " ago"; |
This file contains 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
-(BOOL)processIsRunning:(NSString *)aProcess{ | |
NSTask* task = [[NSTask alloc] init]; | |
[task setLaunchPath: @"/usr/bin/top"]; | |
NSArray* arguments = [NSArray arrayWithObjects: @"-s", @"1",@"-l",@"3600",@"-stats",@"pid,cpu,time,command", nil]; | |
[task setArguments: arguments]; | |
NSPipe* pipe = [NSPipe pipe]; | |
[task setStandardOutput: pipe]; |
This file contains 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 git-cb() { | |
if [ $# -ne 1 ]; then | |
echo 1>&2 Usage: git-cb branch_name | |
else | |
git push origin origin:refs/heads/$1 | |
git fetch origin | |
git checkout --track -b $1 origin/$1 | |
git pull | |
fi | |
} |
This file contains 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
var alphabet = Array.apply(0, Array(26)).map(function(x,y) { | |
return String.fromCharCode(y + 65); | |
}).join(''); | |
console.log(alphabet); | |
//Outputs 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' |
This file contains 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
//Helper Methods | |
function getObjectCount(obj) { | |
var count = 0; | |
var key; | |
for(key in obj) { | |
if(obj.hasOwnProperty(key)) count++; | |
} | |
return count; | |
} |
This file contains 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
/* | |
* HTML Parser By John Resig (ejohn.org) | |
* Original code by Erik Arvidsson, Mozilla Public License | |
* http://erik.eae.net/simplehtmlparser/simplehtmlparser.js | |
* | |
* // Use like so: | |
* HTMLParser(htmlString, { | |
* start: function(tag, attrs, unary) {}, | |
* end: function(tag) {}, | |
* chars: function(text) {}, |
This file contains 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
PS1='\u:\[\033[0;37m\]\W\e[0m$(__git_ps1 :"\[\033[0;35m\][%s]\e[0m")\$ ' |
OlderNewer