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 | |
$result = function_that_does_crazy_stuff($arg1, $arg2); | |
// becomes | |
$result = memoize('function_that_does_crazy_stuff', $arg1, $arg2); | |
$result = StaticClass::method($arg1, $arg2); | |
// becomes | |
$result = memoize(array('StaticClass', 'method'), $arg1, $arg2); |
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 | |
/** | |
* Call a function but memoize the results. | |
* | |
* @param $callback | |
* The function to call. | |
* @param $arguments | |
* The arguments to pass to callback | |
*/ |
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 | |
if (isset($_REQUEST['channel']) and $_REQUEST['channel'] >= 0 and $_REQUEST['channel'] < 32 and isset($_REQUEST['state'])) { | |
$states = file_get_contents('states'); | |
$states[$_REQUEST['channel']] = $_REQUEST['state'] == "on" ? 1 : 0; | |
$f = fopen('states', 'w'); | |
fwrite($f, $states); | |
fclose($f); | |
} |
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
using System; | |
using System.Runtime.InteropServices; | |
namespace ConsoleApplication | |
{ | |
class Program | |
{ | |
[DllImport("inpout32", EntryPoint = "Out32")] | |
private static extern void Output(ushort port, short 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
import os, urllib2 | |
print("Listening...") | |
while True: | |
os.system("lightthatshitup.exe %s" % urllib2.urlopen("http://fuckwithmysleep.com/states").read()) |
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
// FROM | |
_load: function(obj) { | |
if (obj) { | |
for (var prop in obj) { | |
if (obj.hasOwnProperty(prop) { | |
this[prop] = obj[prop]; | |
} | |
} | |
} | |
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() { | |
seltzer.init({ | |
database: "/Users/aaron/Downloads/inventories.sqlite" | |
}); | |
var items = seltzer.sQuery("select * from itemLog"); | |
for (var x = 0; x < items.length; x++) { | |
air.Introspector.Console.log(items[x]); | |
} |
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
Drupal.behaviors.myBehavior = function() { | |
// Retrieve a node synchronously | |
var node = Drupal.jsonify.load('node', 1); | |
console.log(node); | |
// Retrieve a node asynchronously | |
var node = Drupal.jsonify.load('node', 1, function(node) { | |
console.log(node); | |
}); | |
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 create_dmg(opts) { | |
var file, args, info, process; | |
var options = $.extend({ | |
"source": air.File.applicationStorageDirectory.resolvePath("tmp"), | |
"output": air.File.applicationStorageDirectory, | |
"name": "backup-" + (+(new Date())) + ".dmg", | |
"password": false, | |
"title": "Backup", | |
"error": function(e) { log(e); }, |
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 forum_block($op = 'list', $delta = 0, $edit = array()) { | |
switch ($op) { | |
case 'list': | |
$blocks[0]['info'] = t('Active forum topics'); | |
$blocks[1]['info'] = t('New forum topics'); | |
return $blocks; | |
case 'configure': |