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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <ctype.h> | |
#define MAX_MESSAGE_LENGTH 1024 | |
int main(int argc, char* argv[]) { | |
if (argc != 2) { |
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 mitigated_event(f, t) { | |
var timeout; | |
return function(e) { | |
clearTimeout(timeout); | |
timeout = setTimeout(function() { f(e); }, t); | |
}; | |
} |
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 | |
// w.WriteHeader(200) -> w.WriteHeader(http.StatusOK) // 200 | |
array_map(function($a) { | |
$data = file_get_contents($a); | |
$data = preg_replace_callback("/\.WriteHeader\((\d+)\)/", function($d) { | |
static $constants = array( | |
100 => 'http.StatusContinue', | |
101 => 'http.StatusSwitchingProtocols', |
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 gethub() { | |
cd ~/Code | |
if [[ ! -d "$1" ]]; then | |
git clone [email protected]:$1 "$1" | |
fi | |
cd "$1" && sub . | |
} |
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 fill(x,y) { | |
if (c.getImageData(x,y, 1,1).data[0] !== 0) { | |
c.fillRect(x,y, 1,1); | |
fill(x-1, y-1); fill(x, y-1); fill(x+1, y-1); | |
fill(x-1, y); /* current */ fill(x+1, y); | |
fill(x-1, y+1); fill(x, y+1); fill(x+1, y+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
function generate_dom(string) { | |
var t = document.createElement('div'); | |
t.innerHTML = string; | |
return t.children.length === 1 ? t.children[0] : t.children; | |
} |
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 ctx_to_object_url(ctx) { | |
var img_bytes = atob(ctx.canvas.toDataURL().substring('data:image/png;base64,'.length)), | |
ua = new Uint8Array(new ArrayBuffer(img_bytes.length)); | |
for (var i = 0; i <= ua.length; i++) { | |
ua[i] = img_bytes.charCodeAt(i); | |
} | |
return (window.URL || window.webkitURL).createObjectURL(new Blob([ua], { type: 'image/png' })); |
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 cd() { | |
builtin cd $@ | |
if [[ -e .goenv ]]; then | |
source .goenv | |
fi | |
} | |
function gengo() { | |
local project=${1?:"Usage: gengo <projectname> [<git origin url>]"} | |
[ ! -d "$project" ] && mkdir "$project" && builtin cd "$project" && mkdir -p src bin pkg && |
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
package main | |
import ( | |
"log" | |
"net" | |
"net/rpc" | |
) | |
type System int |
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
package main | |
import ( | |
"log" | |
"net" | |
"net/rpc" | |
"sync" | |
"time" | |
) |