Skip to content

Instantly share code, notes, and snippets.

@techiferous
techiferous / 0_reuse_code.js
Created May 16, 2016 18:52
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@techiferous
techiferous / gist:c5409009c78ec011ce79
Created March 7, 2015 18:29
Rewrite Ruby's backtrace to cover your tracks
this_file = Regexp.new(__FILE__)
# Capture every single time an exception is raised in this Ruby program.
# Use TracePoint for Ruby 2.0+, set_trace_func for Ruby 1.9-
trace = TracePoint.new(:raise) do |tp|
exception = tp.raised_exception
backtrace = exception.backtrace
# if the source of the error is in this file
@techiferous
techiferous / gist:2758986
Created May 20, 2012 18:08
Example of an Ember.js handler
App.handlers.employees = Ember.Object.create({
add: function() {
App.viewables.newEmployee.reset();
App.viewables.employeeFormPane.set('adding', true);
},
cancel: function() {
App.viewables.employeeFormPane.set('adding', false);
},
# This extends the behavior of Rake to allow you to see all of the dependencies
# of a Rake task recursively, not just the immediate dependencies.
#
# It adds a -d option (also called --dependency-tree). Left blank, this
# option shows you dependencies for all Rake tasks. Alternatively, you
# can pass a regular expression to this option and it will only show
# dependencies for matching tasks.
#
# To use this special version of Rake, save it in a Ruby file called
# raketree.rb (but the name really doesn't matter). Here are some examples of
This code has graduated from a gist to a gem!
http://gemcutter.org/gems/rack-linkify
http://github.com/techiferous/rack-linkify
# If you'd like this packaged up as a gem, send me a note. You can get
# in touch with me at http://www.techiferous.com/about
require 'nokogiri'
require 'ispell'
module Rack
class SpellCheck
def initialize(app, options = {})
require 'nokogiri'
module Rack
class Steamroller
def initialize(app, options = {})
@app = app
@options = options
end
This code has graduated from a gist to a gem!
http://gemcutter.org/gems/rack-gsub
http://github.com/techiferous/rack-gsub
module Rack
class EtyRack
def initialize(app)
@app = app
end
def call(env)
sleep 86400
end
module Rack
class Lockdown
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
if ["GET", "HEAD"].include?(request.request_method)