Skip to content

Instantly share code, notes, and snippets.

View nelix's full-sized avatar
🎯
Focusing

Nathan Hutchision nelix

🎯
Focusing
View GitHub Profile
@nelix
nelix / dataURIToBlob.js
Created November 26, 2012 21:54
Can anyone think of a faster or more correct way to convert a canvas object to a blob?
function dataURIToBlob(dataURI) {
var parts = dataURI.split(',');
var binary = atob(parts[1]);
var type = parts[0];
var array = [];
for(var i = 0; i < binary.length; i++) {
array.push(binary.charCodeAt(i));
}
return new Blob([new Uint8Array(array).buffer], {type: type});
}
@nelix
nelix / main.js
Created November 23, 2012 02:21
Jetpack/worker window function hack
let win = require("window-utils").windowIterator().next();
let {Cc, Ci} = require("chrome");
let window = win.QueryInterface(Ci.nsIDOMWindowInternal);
//window.atob, window.FormData, etc etc...
@nelix
nelix / board.js
Created October 26, 2012 11:35
Some idea I am playing with
// board.js
var roll, win_game, say, score, board, move, yeild;
var players = [{position:0, name: 'Jeff', points:0}, {position:0, name: 'Nathan', points: 0}];
//var players = [{position:0, name: 'bill'}];
var win = false;
// functions here take an argument and return how many places to move
roll = function() {
var dice = Math.floor((Math.random() * 6) + 1);
return dice;
@nelix
nelix / background.js
Created October 25, 2012 05:21
Chrome extension which reloads all unpacked extensions on opening of a url, for use with gruntjs's watch task.
/*
* Use with grunt-exec command: 'open -a "/Applications/Google Chrome.app" file://localhost/reload'
*/
chrome.webRequest.onBeforeRequest.addListener(hook, {urls: ['file://localhost/reload*']});
function hook(details) {
console.log('reloading all dev extensions');
chrome.management.getAll(function(extensions){
for(var i in extensions){
extension = extensions[i];
-Go to the starting point of the project
>> git checkout origin master
-Create and checkout your branch
>> git checkout -b [branch]
-Make changes
>> git commit -a -m"commit messages"
-Push the changes to the remote if you want review, so on
>> git push origin [branch]
-Go back to the branch you want to merge to
>> git checkout master
//Derived from http://people.mozilla.org/~dietrich/ubiquity.js
var sources = ["history", "bookmarks", "starred", "tagged", "session"];
var sorts = ["freshness", "age", "frequency", "infrequency", "recency", "staleness"]
var noun_type_places_datasource = new CmdUtils.NounType("datasource", sources);
var noun_type_places_sorts = new CmdUtils.NounType(" sort attribute", sorts);
var debugMode = true;
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#define NOINLINE __attribute__((noinline))
const size_t CONTINUATION_STACK_SIZE = 8192;
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdarg.h>
#define NOINLINE __attribute__((noinline))
typedef unsigned char byte;
typedef struct Continuation {
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#define NOINLINE __attribute__((noinline))
const size_t CONTINUATION_STACK_SIZE = 8192;
@nelix
nelix / sp.py
Created July 9, 2009 19:23 — forked from qingfeng/sp.py
from scrapy import log
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.xpath.selector import HtmlXPathSelector
from scrapy.item import ScrapedItem
def safecn(i):
try:
return unichr(int(i))
except: