Skip to content

Instantly share code, notes, and snippets.

Avatar

Nathan Rajlich TooTallNate

View GitHub Profile
@TooTallNate
TooTallNate / sync.js
Last active Aug 29, 2015
`npm owner` syncing tool. Invoke like: gnode sync.js tootallnate rauchg coreh
View sync.js
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 Mar 13, 2014
Get Window's `path` node core module implementation, even on Unix
View windows-path.js
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 Aug 29, 2015
wpcom.js example
View example.html
<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 Aug 29, 2015
dlfcn load printf from the current process
View test.c
/* 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;
View learn.js
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 Jul 16, 2014
TypeScript single-file compiler
View tsc-single-file.js
/**
* 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 Aug 29, 2015
requirebin sketch
View index.js
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);
View wcwidth.js
/*
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
View hello.cgi
#!/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 Jun 11, 2015
MPI and node-ffi
View mpi.js
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',
You can’t perform that action at this time.