Skip to content

Instantly share code, notes, and snippets.

View TooTallNate's full-sized avatar

Nathan Rajlich TooTallNate

View GitHub Profile
@TooTallNate
TooTallNate / sync.js
Last active August 29, 2015 13:56
`npm owner` syncing tool. Invoke like: gnode sync.js tootallnate rauchg coreh
var exec = require('child_process').exec;
var suspend = require('suspend');
var resume = suspend.resume;
suspend.run(function*(){
// first determine the list of npm usernames to sync up to
var npmUsers = process.argv.slice(2);
@TooTallNate
TooTallNate / windows-path.js
Created March 13, 2014 15:38
Get Window's `path` node core module implementation, even on Unix
var vm = require('vm');
var pathCode = process.binding('natives').path;
var sandbox = {
process: {
env: process.env,
cwd: process.cwd,
platform: 'win32'
},
require: require,
@TooTallNate
TooTallNate / example.html
Last active August 29, 2015 14:01
wpcom.js example
<script src="wpcom.js"></script>
<script>
// create a client WPCOM instance
var wpcom = WPCOM();
// retrieve a listing of the most recent
// 5 posts on "en.blog.wordpress.com"
wpcom
.site('en.blog.wordpress.com')
.postsList({ number: 5 }, function(err, data) {
@TooTallNate
TooTallNate / test.c
Last active August 29, 2015 14:02
dlfcn load printf from the current process
/* Compile:
* Unix/OSX: gcc -o test test.c -ldl
* Windows via dlfcn-win32: cl.exe /I dlfcn-win32 dlfcn-win32\dlfcn.c test.c /Fetest.exe
*/
#include <dlfcn.h>
#include <stdio.h>
int main () {
void *handle, *symbol;
var utility = ffi.Library('utility', {
'tesJson': ['void', ['string']]
});
var obj = {'1': 'one', '2': 'two'};
utility.tesJson(JSON.stringify(obj));
@TooTallNate
TooTallNate / tsc-single-file.js
Created July 16, 2014 21:29
TypeScript single-file compiler
/**
* TypeScript single-file compiler:
*
* $ node tsc-single-file.js < input.ts > output.js
*
* Avoids TypeScript attempting to compile an entire "project",
* so that a proper `make` target can be written.
*/
@TooTallNate
TooTallNate / index.js
Last active August 29, 2015 14:08
requirebin sketch
var domPaste = require('dom-paste');
console.log(domPaste);
var input = document.createElement('div');
input.contentEditable = 'true';
input.style.width='300px';
input.style.height='100px';
input.style.border='solid 1px black';
document.body.appendChild(input);
/*
wcwidth.js: JavaScript Portng of Markus Kuhn's wcwidth() Implementation
=======================================================================
Copyright (C) 2012 by Jun Woong.
This package is a JavaScript porting of `wcwidth()` implementation
[by Markus Kuhn](http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c).
Permission is hereby granted, free of charge, to any person obtaining a copy of
#!/usr/bin/perl -w
my $file = "logo.png";
my $length = -s $file;
print "Content-type: image/png\n";
print "Content-length: $length \n\n";
binmode STDOUT;
open (FH,'<', $file) || die "Could not open $file: $!";
my $buffer = "";
while (read(FH, $buffer, 10240)) {
print $buffer;
@TooTallNate
TooTallNate / mpi.js
Created June 11, 2015 20:52
MPI and node-ffi
var ref = require('ref');
var Struct = require('ref-struct');
var ffi = require('ffi');
// typedefs
var MPI_Datatype = 'int';
var MPI_Comm = 'int';
var MPI_Status = Struct({
count: 'int',
MPI_SOURCE: 'int',