Skip to content

Instantly share code, notes, and snippets.

View olivernn's full-sized avatar

Oliver Nightingale olivernn

View GitHub Profile
@olivernn
olivernn / gist:3121642
Created July 16, 2012 08:51
tlux dsl
name "rails"
description "rails development environment"
window "editor", selected: true do
command "vim ."
split :horizontal, height: 20
split :vertical do
dir "~/code/hotrod"
@olivernn
olivernn / davis.hash.js
Last active October 7, 2015 17:18
New Davis Hash Routing
Davis.hash = function () {
var handlers = [],
lastPolledLocation
var triggerHandlers = function (request) {
Davis.utils.forEach(handlers, function (handler) {
handler(request)
})
}
@olivernn
olivernn / gem
Created July 31, 2012 20:42
tlux configs
window :editor do
command "vim ."
end
window :shell
window :console do
command "irb"
end
@olivernn
olivernn / app.html
Created October 19, 2012 11:19
Davis.js Modifier Keys Fix
<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="https://raw.github.com/olivernn/davis.js/modifier-keys/davis.js"></script>
<a href="/foo">Foo</a>
<a href="/bar">Bar</a>
<script>
Davis(function () {
this.get('/foo', $.noop)
this.get('/bar', $.noop)
// Assuming a 'document' strucutre like below to represent a single icon
{
"id": "some-unique-id",
"tags": ["tag1", "tag2", "tag3"],
"title": "My Awesome Icon"
}
// You can then set up an index with the following, I put a boost on the tags, but it depends on your data
@olivernn
olivernn / projlog
Created January 11, 2013 12:42
Display some graphs based on git log output.
#!/usr/bin/env ruby
require 'date'
class Commit
attr_reader :sha, :author, :date
def initialize(attributes = {})
@sha = attributes[:sha]
@olivernn
olivernn / index.html
Last active December 13, 2015 21:19
Using Davis.hash extensions
<!DOCTYPE HTML>
<html>
<head>
<title>Davis tests</title>
<!-- dependencies -->
<script src="/tests/javascripts/jquery.js"></script>
<!-- davis -->
<script src="/davis.js"></script>
@olivernn
olivernn / dev_logs.conf
Last active December 20, 2015 06:48
Configuration for truncating dev logs using newsyslog
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/path/to/log/*.log 644 0 5120 * GN
@olivernn
olivernn / bench.rb
Last active December 20, 2015 11:09
Benchmarking map and compact vs each_with_object vs inject
require 'benchmark'
words = File.open('/usr/share/dict/words', 'r') do |file|
file.each_line.take(100_000).map(&:chomp)
end
Benchmark.bmbm(20) do |x|
GC.start
x.report("map") do
words.map do |word|
class Duration
include Comparable
attr_reader :milliseconds
def initialize(value = 0)
case value
when Fixnum
@milliseconds = value
when String