Skip to content

Instantly share code, notes, and snippets.

View joshthecoder's full-sized avatar

Joshua Roesslein joshthecoder

View GitHub Profile
static Persistent<Function> isNaN;
bool V8Util::isValueNaN(Handle<Value> value)
{
HandleScope scope;
if (isNaN.isEmpty()) {
Local<Object> global = Context::GetCurrent()->Global();
Local<Value> isNaNValue = global->Get(String::NewSymbol("isNaN"));
isNaN = Persistent<Function>::New(isNaNValue.As<Function>());
@joshthecoder
joshthecoder / gist:1628511
Created January 17, 2012 20:01
Wikipedia - SOPA Blackout
How does blacking out a site help educate others what SOPA is and why it should be fought?
In my honest and humble opinion http://en.wikipedia.org/wiki/SOPA is our greatest weapon. Knowledge.
Many people, myself included, may have heard "SOPA", but never knew what it really meant. It is information
like that provided on Wikipedia which helps educate people so they can make knowledgeable discussions.
Without this knowledge we become blind and defenseless. If this blackout should accomplish anything, it will
turn off the lights and leave us wondering in the dark.
I recommend that Wikipedia and it's editors reconsider their action and choose the
more well lighted path to educating the people of SOPA. I suggest the landing page of wikipedia
be redirected to the SOPA wiki page. While I would prefer to keep all other pages online during this campaign to
@joshthecoder
joshthecoder / gist:1631238
Created January 18, 2012 05:45
Wikipedia SOPA Blackout Flashlight :)
Here's a little trick to re-light wikipedia if you just can't go
without digesting some yummy wiki pages...
Chrome
------
1. Go to Preferences, Under the hood, Content settings.
2. Go to JavaScript section and click Manage exceptions.
3. Add entry: hostname = en.wikipedia.org behavior = block
4. Now load Wikipedia and enjoy!
@joshthecoder
joshthecoder / gist:1654338
Created January 21, 2012 22:48
Using mobile devices as authentication devices.
QR code based authentication
============================
This would be mainly used when the user visits a site from a computer
besides their mobile device (ex: desktop). QR codes are used to initiate
a handshake.
User Experience
---------------
1. User visits site for the first time.
2. Site displays a QR code.
@joshthecoder
joshthecoder / gettimeofday.lua
Created June 27, 2012 06:18
gettimeofday() via LuaJIT + FFI
local ffi = require("ffi")
ffi.cdef[[
typedef long time_t;
typedef struct timeval {
time_t tv_sec;
time_t tv_usec;
} timeval;
int gettimeofday(struct timeval* t, void* tzp);
var spawn = require('child_process').spawn;
function Log(level, pid, message) {
this.level = level;
this.pid = pid;
this.message = message;
}
process.stdout.write(['time', 'mem_freed', 'allocated', 'size'].join('\t') + '\n');
parse_messages:
Parsed 100000 messages in 37 ms
2702703 messages/s
@joshthecoder
joshthecoder / echo_server.t
Last active December 18, 2015 20:59
A TCP echo server written in Terra using libuv
uv = terralib.includecstring([[
#include <uv.h>
// Keep uv_write_s alive by tricking clang with a dummy function.
void __ignore(uv_write_t*);
]])
terralib.linklibrary("libuv.dylib")
stdlib = terralib.includec("stdlib.h")
stdio = terralib.includec("stdio.h")
Traceback (most recent call last):
File "/Users/jroesslein/Development/Libraries/Python/tweepy/tweepy/tests/test_api.py", line 204, in testupdateprofilebannerimage
self.api.update_profile_banner('examples/banner.png')
File "/Users/jroesslein/Development/Libraries/Python/tweepy/tweepy/tweepy/api.py", line 377, in update_profile_banner
)(self, post_data=post_data, headers=headers)
File "/Users/jroesslein/Development/Libraries/Python/tweepy/tweepy/tweepy/binder.py", line 194, in _call
return method.execute()
File "/Users/jroesslein/Development/Libraries/Python/tweepy/tweepy/tweepy/binder.py", line 151, in execute
resp = conn.getresponse()
File "/Users/jroesslein/Development/Libraries/Python/tweepy/tweepy/.env/lib/python2.7/site-packages/httreplay/stubs/base.py", line 142, in getresponse
@joshthecoder
joshthecoder / gist:87bb9ab99667dce02bbe
Last active August 29, 2015 14:11
Flux stores and components decoupled w/ immutable JS.
var Actions = Flux.createActions(
INCR_COUNT, DECR_COUNT
);
var CountStore = Flux.createStore(
INCR_COUNT: (_, state) => state.update('count', count => count + 1)
DECR_COUNT: (_, state) => state.update('count', count => count - 1)
);
var App = React.createClass({