Skip to content

Instantly share code, notes, and snippets.

View nelix's full-sized avatar
🎯
Focusing

Nathan Hutchision nelix

🎯
Focusing
View GitHub Profile
-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
@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];
@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 / 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 / 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 / firefoxdespire.js
Created November 27, 2012 02:13
Why not just make the API magically more like the way I want to write things.
var workers = [];
PageMod({
include: "*",
contentScriptWhen: 'end',
contentScriptFile: data.url("content.js"),
attachTo: ["top", "existing"],
onAttach: function(worker) {
workers.push(worker);
worker.on('detach', function () {
log('worker detach');

This is a request for comment - this is a proposed configuration API for the BugHerd Public Feedback and Sidebar

The BugHerd sidebar can be configured to override some of its default behaviour as well as display extra information in any tasks that you pass in from a configuration object called BugHerdConfig.

When setting up BugHerd for the first time, you probably already know you need to add the following code to your site:

  <script type="text/javascript">
    (function (d, t) {
      var bh = d.createElement(t), s = d.getElementsByTagName(t)[0];
@nelix
nelix / stupid.rb
Created January 11, 2013 04:35
make urls match more.
def project_item(project)
url = project.devurl
if url.include?('*')
return [url] # User knows what they are doing
end
unless url.blank?
begin
uri = URI(project.devurl)
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
document.addEventListener("DOMContentLoaded", function(){
// an iframe and enough content to scroll is required
var iframe = document.getElementById('frame');
// if we touch this and there is a hash in the iframes parent location it will infiniscroll
// only if its parent is top
function each(items,fn){[].forEach.call(items,fn)}
each(document.styleSheets, function(sheet){
if (sheet.cssRules) each(sheet.cssRules, function(r){
try{
// look for the first matching element
if(!document.querySelectorAll(r.selectorText)[0])
console.log("Unused Selector: ", r.selectorText);
} catch (e){