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 | |
/** | |
* Trait to get rid of naive getter/setter boilerplate | |
*/ | |
trait GetSet | |
{ | |
/** | |
* Dynamically create getters/setters |
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 to run on script shutdown | |
* -used to catch most fatal errors, and | |
* display them cleanly | |
* | |
* @return void | |
*/ | |
function shutdown() |
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 do_curl($url, $options=array()) | |
{ | |
$cookie = tempnam ("/tmp", "CURLCOOKIE"); | |
$ch = curl_init($url); | |
//Use the user's User Agent and Cookies | |
$opts= array( | |
CURLOPT_USERAGENT => "Tim's List Image Updater", | |
CURLOPT_COOKIEJAR => $cookie, |
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 | |
// Normal foreach loop | |
foreach($foo as $bar) | |
{ | |
... | |
} | |
// Foreach with reference | |
foreach($foo as &$bar) |
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
javascript:(function(doc){ | |
"use strict"; | |
var $ = function(id){ | |
return doc.getElementById(id); | |
}; | |
var html = '<div id="tc_form_wrapper"> \ | |
<input type="number" id="tch1" size="3" /> : <input type="number" id="tcm1" size="3" /> \ | |
<button id="tc_plus">+</button> \ |
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 | |
/** | |
* Creates directories based on the array given | |
* | |
* @param array $structure | |
* @param string $path | |
* @return void | |
*/ | |
function make_dir_tree($structure, $path=__DIR__) |
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/mac) | |
./configure --prefix=/opt/php-embed/ --exec-prefix=/opt/php-embed/ --enable-embed=static --disable-cgi --with-curl --disable-dom --enable-ftp --enable-mbstring --with-pdo-mysql=mysqlnd --with-pdo-pgsql --with-pgsql --enable-zip --with-interbase=/Library/Frameworks/Firebird.framework/Libraries/ --enable-phar --enable-debug | |
(php/linux) | |
./configure --prefix=/opt/php-embed/ --exec-prefix=/opt/php-embed/ --enable-embed=static --disable-cgi --disable-dom --enable-ftp --enable-mbstring --with-pdo-mysql=mysqlnd --with-pdo-pgsql --with-pgsql --enable-zip --with-interbase --enable-phar --enable-debug | |
(wxphp) | |
./configure --prefix=/opt/php-embed/ --exec-prefix=/opt/php-embed/ --with-wxwidgets=/opt/wxWidgets-svn --with-php-config=/opt/php-embed/bin/php-config |
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 | |
set_time_limit(-1); | |
$primes = json_decode(file_get_contents("prime.json")); | |
while (TRUE) | |
{ | |
$i = $primes[count($primes) -1] + 1; | |
$ip = $i + 999; |
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
// In javascript, object properties that are not valid for the dot syntax can be defined with square brackets. | |
// Similar to PHP: | |
obj[' '] = 'foo'; | |
// While there isn't a direct method to create a variable with a invalid name, | |
// you can fake it using the document/window variable, or this | |
this[' '] = 'bar'; |