Skip to content

Instantly share code, notes, and snippets.

View fearphage's full-sized avatar
⌨️
Cache rules everything around me.

Phred Lane fearphage

⌨️
Cache rules everything around me.
View GitHub Profile
@fearphage
fearphage / dbg.js
Created December 9, 2013 16:30 — forked from hallvors/dbg.js
// post serialized no-script clone back to debugger
if(true){ // this is just to be able to toggle the dumping off easily
(function noscriptDump(){
var clone = document.documentElement.cloneNode(true);
var elms = clone.getElementsByTagName('script')
while(elms.length){
elms[elms.length-1].parentNode.removeChild(elms[elms.length-1]);
}
var html = clone.outerHTML;
var x = new XMLHttpRequest();
(function(slice) {
var proxy = function(source, eventName) {
var _self = this;
source.on(eventName, function(evt) {
_self.trigger.apply(_self, slice.call(arguments).splice(0, 1, eventName));
});
};
Backbone.View.prototype.proxyEvent =
Backbone.Model.prototype.proxyEvent =
// node.js proxy server example for adding CORS headers to any existing http services.
// yes, i know this is super basic, that's why it's here. use this to help understand how http-proxy works with express if you need future routing capabilities
var httpProxy = require('http-proxy'),
express = require('express');
var proxy = new httpProxy.RoutingProxy();
var proxyOptions = {
host: '192.168.3.11',
// Require libraries
var os = require("os");
var fs = require("fs");
var readline = require("readline");
var cluster = require("cluster");
var express = require("express");
var site = express();
// Var up, bro
var i, read;
#!/usr/bin/env node
var fs = require('fs');
var help = "Usage : trash [-lhx] files...\n\t-l : list trashcan\n\t-x : cancel (files: timestamp)\n\t-h : help";
var trash = process.env['HOME'] + "/.trash/";
(function(argv, log, error) {
argv = require('optimist').parse(argv);
if (typeof argv.l === 'string') {
...
// test for font-face version to load via Data URI'd CSS
// Basically, load WOFF unless it's android's default browser, which needs TTF, or ie8-, which needs eot
var fonts = ns.files.css.fontsWOFF,
ua = win.navigator.userAgent;
// android webkit browser, non-chrome
if( ua.indexOf( "Android" ) > -1 && ua.indexOf( "like Gecko" ) > -1 && ua.indexOf( "Chrome" ) === -1 ){
fonts = ns.files.css.fontsTTF;
}
#!/bin/sh
# btsync service
# Replace with linux users you want to run BTSync clients for
BTSYNC_USERS="mendel"
DAEMON=/usr/bin/btsync
start() {
echo "Starting btsync..."
for btsuser in $BTSYNC_USERS; do
HOMEDIR=`getent passwd $btsuser | cut -d: -f6`
@fearphage
fearphage / 1.js
Last active December 14, 2015 19:28 — forked from getify/1.js
(function(window) {
var
requestAnimationFrame = window.requestAnimationFrame
|| window.msRequestAnimationFrame
|| window.mozRequestAnimationFrame
|| window.webkitRequestAnimationFrame
|| window.oRequestAnimationFrame
,cancelAnimationFrame = window.cancelAnimationFrame
|| window.msCancelAnimationFrame
|| window.msCancelRequestAnimationFrame
@fearphage
fearphage / base.view.js
Created December 7, 2012 22:55
Make Backbone Your Own.
define(function () {
"use strict";
var templates = {};
return Backbone.View.extend({
template: '<div></div>',
_templatize: function () {
if ( !templates[ this.template ] ) {
templates[ this.template ] = _.template( this.template );
@fearphage
fearphage / fabfile.py
Created December 5, 2012 15:43 — forked from kmpm/fabfile.py
Fabric deployment of Node.js on Ubuntu
from __future__ import with_statement
from fabric.api import env
from fabric.api import *
from fabric.contrib.console import confirm
from fabric.contrib.project import upload_project
import ubuntu
import protobuf