Skip to content

Instantly share code, notes, and snippets.

@wulftone
wulftone / user.json.rabl_spec.rb
Created February 27, 2012 23:31
Isolated Rabl Specs
# user.json.rabl_spec.rb
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..'))
$: << File.join(APP_ROOT, 'spec/support') # for my spec helpers
$: << File.join(APP_ROOT, 'config/initializers') # for rabl_init.rb
require 'my_spec_mocks'
require 'rabl'
require 'rabl_init'
# We need to fool rabl into thinking we are running rails.
# All rabl wants is the root path to help in finding templates.
/**
* Based conceptually on the _.extend() function in underscore.js ( see http://documentcloud.github.com/underscore/#extend for more details )
* Copyright (C) 2012 Kurt Milam - http://xioup.com | Source: https://gist.github.com/1868955
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
**/
@wulftone
wulftone / backbone-rivets.config.js
Last active December 12, 2015 09:29
Rivetsjs adapter for backbonejs
rivets.configure({
adapter: {
subscribe: function(obj, keypath, callback) {
if (obj instanceof Backbone.Collection) {
obj.on('add remove reset', function () {
callback(obj[keypath])
});
} else {
obj.on('change:' + keypath, function (m, v) { callback(v) });
};

Demo

console.log 'hello'
print 'world!'
@wulftone
wulftone / config.ru
Last active December 16, 2015 04:19
Silly little webserver
# If you have ruby installed, you can use this file to run a basic web server
# and avoid silly cross-site forgery issues when doing your assignments.
#
# * Install ruby, if you haven't already
# Macs come with ruby, so just open up a terminal and type: ruby -v
# and press Return (or Enter or whatever). If you get a response,
# you have ruby already! Move to the next step. If not, consult Google.
#
# Windows users can easily install ruby, just check out http://rubyinstaller.org/
# When you're done installing, open up a command prompt (or powershell) and
@wulftone
wulftone / note.dtd
Last active September 26, 2020 06:23
Simple xml-dtd validator
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
@wulftone
wulftone / Default.sublime-theme
Created April 22, 2013 19:16
Dark Sublime Text theme
[
{
"class": "label_control",
"color": [255, 255, 255],
"shadow_color": [24, 24, 24],
"shadow_offset": [0, -1]
},
{
"class": "button_control",
"content_margin": [6, 5, 6, 6],
@wulftone
wulftone / mon
Last active December 16, 2015 15:29
Monitor some random process by current user and process name and notify when it is complete
#!/usr/bin/env ruby
# Usage:
#
# ./mon git 0.3 # => will monitor "git" every 0.3 seconds until it dies
start = Time.now
user = `whoami`.strip
name = ARGV[0]
frequency = (ARGV[1] || 1).to_f # Default to 1 second if second argument not given
@wulftone
wulftone / trello_lindy_json_to_file.rb
Created May 17, 2013 04:35
Made specifically for a Trello project, this script will troll through your Trello JSON export data and pick out the names of your Trello cards and Lists, and save them to a new file.
#! /usr/bin/ruby
# This file is intended to be used for a specific trello project, but the principle
# displayed here of extracting data from a trello json export file can be used in
# a wide variety of ways. Edit this file to your heart's content!
#
# Put this file in the same folder as "lindy-hop-thesaurus.json" (or whatever your
# Trello export file is called... and run it from the command line like this:
#
# ruby print_json.rb lindy-hop-thesaurus.json
@wulftone
wulftone / debounce.coffee
Last active December 19, 2015 09:09
A simple debouncing function that only executes the function after all input has stopped. http://blog.gaslight.co/page/3
###
source: http://blog.gaslight.co/page/3
Debounce a function so it only executes once, after all inputs to it have ended, or after
a specified timeout interval. Optionally pass another argument to your debounced function
to execute it immediately, for example: `myDebouncedFunction( some, arguments, { now: true } )`
@example An Ember.js controller example usage
App.DocumentController = Ember.ObjectController.extend