Skip to content

Instantly share code, notes, and snippets.

View joshnesbitt's full-sized avatar

Josh Nesbitt joshnesbitt

View GitHub Profile
@joshnesbitt
joshnesbitt / railtie.rb
Created April 12, 2013 16:29
Register Dart with the asset pipeline.
module Dart
module Rails
class Railtie < ::Rails::Engine
initializer :setup_dart_rails do |app|
app.assets.register_engine '.dart', Dart::Rails::Template
end
end
end
function Bit(a, b) {
this.a = a;
this.b = b;
}
function construct() {
var args = Array.prototype.splice.call(arguments, 0);
var fn = args.shift();
function F() {
@joshnesbitt
joshnesbitt / geoip_service.rb
Created December 3, 2012 11:53 — forked from mislav/geoip_service.rb
Simple GeoIP service class using freegeoip.net and Faraday
require 'faraday_middleware'
require 'hashie/mash'
# Public: GeoIP service using freegeoip.net
#
# See https://github.com/fiorix/freegeoip#readme
#
# Examples
#
# res = GeoipService.new.call '173.194.64.19'
@joshnesbitt
joshnesbitt / easy_way.rb
Created December 3, 2012 11:54 — forked from mislav/easy_way.rb
RESOLVE SHORT URLS before storing. Short URLs are for microblogging; you should never actually keep them around.
require 'net/http'
# WARNING do not use this; it works but is very limited
def resolve url
res = Net::HTTP.get_response URI(url)
if res.code == '301' then res['location']
else url.to_s
end
end
alias subo='sudo'
alias bungle='bundle'
alias lcok='lock'
alias touch='say "cant touch this, da, da, da, da, duh, der, der, da"; touch'
@joshnesbitt
joshnesbitt / default_syntax.py
Created June 21, 2012 13:17
Set JavaScript as default syntax when creating new tab/window in Sublime Text 2
# Save this file in ~/Library/Application Support/Sublime Text 2/Packages/User
import sublime, sublime_plugin
class DefaultSyntaxCommand(sublime_plugin.EventListener):
def on_new(self, view):
view.set_syntax_file('JavaScript/JavaScript.tmLanguage')
// Listing bookmarks with a collection:
var BookmarksCollection = SignalBox.Backbone.Collection({
resource : 'bookmarks'
});
var bookmarks = new BookmarksCollection;
bookmarks.fetch({
success : function(collection){
#! /usr/bin/ruby
class HostsFile
attr_accessor :lines
def initialize(path = '/etc/hosts')
@file = File.open(path, 'r')
@entries = []
parse
// Setup the SDK
SignalBox.setup({
app : 'sdk_test',
username : 'signalboxdemo'
});
// List all users
@joshnesbitt
joshnesbitt / config.ru
Created February 29, 2012 17:48
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
# Be sure to have rails and thin installed.
require "rubygems"
require "rails"
# Let's load only action controller. If you want
# to use active record, just require it as well.
require "action_controller/railtie"
class MyApp < Rails::Application