Skip to content

Instantly share code, notes, and snippets.

View getify's full-sized avatar
💭
Just coding

Kyle Simpson getify

💭
Just coding
View GitHub Profile
use Apache2::SubProcess();
$r = shift();
print "Content-type: text/html\n\n";
my($in, $out, $err) = $r->spawn_proc_prog("myprog");
while (<$out>) {
print $_; # works fine
function getElementsByClassName(classname,root,tagname) {
root = root || document;
tagname = tagname || "*";
classname = classname.split(/\s+/);
var els = root.getElementsByTagName(tagname),
ret=[], i,j=0,k,len = els.length, m, cn, klen=classname.length, reEdgeSpaces = /[\t\n\r\f]/g
;
for (i=0; i<len; i++) {
cn = ' '+els[i].className.replace(reEdgeSpaces,' ')+' ';
m = true;
// this is a JSON file with comments
{
"foo": "bar", // this is cool
"bar": [
"baz", "bum", "zam"
],
/* the rest of this document is just fluff
in case you are interested. */
"something": 10,
"else": 20
<?php
// located at: http://another.tld/auth.php
$api_callback = $_REQUEST["callback"];
if ($_COOKIE["token_1"] == "abcd1234" && $_GET["token_2"] == "efgh5678") {
$msg = "Yes, your API call was successful!";
}
else {
$msg = "API call not authorized.";
<html>
<head>
<script type="text/javascript" src="LAB.js"></script>
<script type="text/javascript">
var _queue = ["script1.js",null], $L = $LAB;
</script>
...
</head>
<body>
{$: "#main" | action=data.user.logged_in?"#logout":"#login" }
Hello, {$= data.name $}
{$= @action $}
{$}
{$: "#login" }
(function blah() {
alert(blah); // works!
(function() { alert(blah); })(); // fails :(
})();
<script src="data:text/javascript,alert('hello world');"></script>
<script>alert("hello world");</script>
(function(){
var abc = "123";
abc = 123;
})();
// shorten/alias long canvas method names
// adapted from: http://marijn.haverbeke.nl/js1k.html
var Canv = document.body.children.c,
Gr = Canv.getContext("2d"),
prop
;
for (prop in Gr) {
Gr[ prop[0] + (prop[3]||"") + (prop[6]||"") ] = Gr[prop];