Skip to content

Instantly share code, notes, and snippets.

Avatar

Nic Haynes nicinabox

View GitHub Profile
@nicinabox
nicinabox / gist:9213299
Created Feb 25, 2014
Backup configs on unraid VMs
View gist:9213299

API

$ configs backup
=> Backing up sabnzbd
=> Backing up sickbeard
...

$ configs restore
=> Restoring up sabnzbd

=> Restoring up sickbeard

View install-nodejs.sh
#!/bin/sh
VERSION=0.8.6
PLATFORM=darwin
ARCH=x64
PREFIX="$HOME/node-v$VERSION-$PLATFORM-$ARCH"
mkdir -p "$PREFIX" && \
curl http://nodejs.org/dist/v$VERSION/node-v$VERSION-$PLATFORM-$ARCH.tar.gz \
| tar xzvf - --strip-components=1 -C "$PREFIX"
@nicinabox
nicinabox / Backbone.View.extend.coffee
Created Apr 25, 2014
Wrap Backbone's render function and fire a render event
View Backbone.View.extend.coffee
class Backbone.View extends Backbone.View
constructor: ->
super
@render = _.wrap @render, (viewRender, args) =>
viewRender = _.bind viewRender, this
viewRender(args)
setTimeout =>
@trigger('render')
View gist:98f379fb0f9adbcac98f
new Shortcode(document.querySelector('body'), {
button: function(done) {
sc_sn(this, 'button', done);
}
});
sc_sn = function(match, done) {
$.ajax({
success: function() {
var replacementValue = '...';
View gist:6b0486bb1ce812806f5d
var _ = require('lodash');
var natural = require('natural'),
classifier = new natural.BayesClassifier();
// First item denotes "changed motor oil"
var notes = [
[true, 'Change oil, oil filter, air filter, spark plugs'],
[true, 'Change oil, oil filter. 4qt Rotella T6, 0.5 Mobil 1 5W-40'],
[false, 'Change gearbox oil, rear drive oil, valve adjustment, torque heads'],
[false, 'Change transmission oil'],
View makepem
#!/usr/bin/env ruby
class MakePEM
def initialize(argv)
@file = argv[0]
abort help unless valid_args
parts = @file.split('.')
@name = parts.first
@nicinabox
nicinabox / server.js
Created Apr 12, 2015
A handy server to use in development
View server.js
var connect = require('connect')
var http = require('http')
var serveStatic = require('serve-static')
var PORT = 8000;
var app = connect()
app.use(serveStatic(__dirname + '/public'))
app.use(serveStatic(__dirname))
View tokens.txt
MOTOR_OIL
- Change oil, oil filter. 4qt Rotella T6, 0.5 Mobil 1 5W-40
- Change oil, oil filter, air filter, spark plugs
- Oil, oil filter, gearbox oil, rear drive oil, valve adjustment, torque heads
- Change oil and oil filter
- Changed oil and filter
- Changed oil with Castrol GTX 5w-30 and new filter
- New Tensioner - AC Delco (Littens) \nNew O-Ring for Front Crank Sensor\nOil Change (Royal Purple 5w30)
View gist:790299
$('form').submit(function() {
// get all the inputs into an array.
var $inputs = $('#form :input');
// get an associative array of just the values.
var values = {};
$inputs.each(function() {
values[this.name] = $(this).val();
if ($(this).val() == "") {
alert("You haven't filled out all the fields");
View gist:869865
users = []
xml.search('//dc:creator').each do |user|
unless users.include?(user)
users << user.inner_text
end
end