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 | |
// TEST | |
//print_r(getTagAttributes('<img enabled href=/fuck/my/attr/syntax" disabled id="idofmyelemtnt" title="Incredible Web Site" src="/images/incredibility.jpg" style="height:300px;width:900px;" />')); | |
function getTagAttributes($htmlortag, $name = false) { // name=false returns all attributes as array | |
$p = 0; | |
$tag = false; | |
$inquote = false; | |
$started = false; |
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
<select name="year"> | |
<option value="">Year</option> | |
<?php for ($year = date('Y'); $year > date('Y')-100; $year--) { ?> | |
<option value="<?php echo $year; ?>"><?php echo $year; ?></option> | |
<?php } ?> | |
</select> | |
<select name="month"> | |
<option value="">Month</option> | |
<?php for ($month = 1; $month <= 12; $month++) { ?> | |
<option value="<?php echo strlen($month)==1 ? '0'.$month : $month; ?>"><?php echo strlen($month)==1 ? '0'.$month : $month; ?></option> |
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 | |
// TEST | |
// $res[] = "procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----"; | |
// $res[] = " r b swpd free buff cache si so bi bo in cs us sy id wa"; | |
// $res[] = " 0 0 0 10376 148188 291056 0 0 4 29 85 9 1 0 98 1"; | |
// // or | |
// // exec('vmstat', $res); | |
// print_r(parseVMStatOutput($res)); |
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 | |
function ParseQueryString($query, $orig = false) { | |
$items = $orig ? $orig : array(); | |
$_items = explode('&', $query); | |
foreach ($_items as $item) { | |
if (strpos($item, '=')===false) { | |
$items[urldecode($item)] = true; | |
} | |
else { |
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
void onMainQueue(void(^block)(void)) { | |
if ([NSThread isMainThread]) | |
block(); | |
else | |
dispatch_sync(dispatch_get_main_queue(), block); | |
} | |
//usage example: | |
- (void)callbackThatIDontKnowWhichThreadIsItRunningOn { | |
onMainQueue(^{ |
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
#!/bin/bash | |
PUTIO_USERNAME="your put.io username" | |
PUTIO_PASSWORD="your put.io password" | |
wget --http-user=${PUTIO_USERNAME} --http-password=${PUTIO_PASSWORD} --content-disposition -c $@ |
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 | |
/** | |
* A Simple JSON Site-wide Configuration manager with key-path access, overriding, inline variables, etc.. | |
* It might look ugly for some people, most important goal with this is simplicity in the code that uses this. | |
* | |
* You can find usage sample at the end of the file | |
* | |
* @author Furkan Mustafa <furkan@fume.jp> | |
* @version 0.1.3 |
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
/** | |
Original Code From, Md. Mahmud Ahsan, http://thinkdiff.net/mixed/base-conversion-handle-upto-36-bases/, 2008.02.28 | |
Adapted Objective-C, Furkan Mustafa, 2013.05.28 | |
Description: Alpha Numeric Base Conversion, Handles upto base 36 | |
*/ | |
NSString* reverseString(NSString* original) { | |
const char* chars = [original cStringUsingEncoding:NSASCIIStringEncoding]; | |
int length = strlen(chars); | |
char* new = (char*)malloc(length+1); |
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 | |
/* | |
Memcache Proxy Class for data | |
Furkan Mustafa, 2013.05 | |
use it. | |
usage: | |
$dataUsedTooMuch = mem::cache('myhandle', 30, function() { | |
return db::query('SELECT CRAZY SLOW SQL SCRIPT'); |
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 | |
// a replacement for php's built-in explode function, doesn't break quotes, etc. | |
function nonBreakingExplode($delimiter, $string, $nobreakChars = array('"', '\'', '()', '[]')) { | |
$pos = 0; | |
$len = strlen($string); | |
$delimiterLen = strlen($delimiter); | |
$lastCut = 0; | |
$nest = array(); |
OlderNewer