This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Tire | |
def self.inverted_aliases | |
aliases.inject({}) do |acc, (index, aliases)| | |
aliases.each do |als| | |
acc[als] ||= SortedSet.new | |
acc[als] << index | |
end | |
acc | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'pp' | |
require 'redis' | |
require 'json' | |
configure do | |
redis = JSON.parse(ENV['VMC_SERVICES']).select {|srvc| srvc['name'] =~ /redis-.*?/ }.first['options'] | |
redis_conf = {:host => redis['hostname'], :port => redis['port'], :password => redis['password']} | |
@@redis = Redis.new redis_conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Step( | |
# () -> redis.select 15, @ | |
# () -> redis.flushdb @ | |
# () -> redis.rpush 'fakelist', '1', @ | |
# () -> redis.rpush 'fakelist', '2', @ | |
# () -> redis.rpush 'fakelist', '3', @ | |
# () -> redis.lrange 'fakelist', 0, 1, @ | |
# (err, arr) -> | |
# console.log arr.length | |
# console.log arr[0].toString() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onorientationchange = function() { | |
if (window.orientation == 0) { | |
$('#sidebar').fadeOut() | |
} else { | |
$('#sidebar').fadeIn() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mustache' | |
class Layout < Mustache | |
self.template = "Header | |
{{{yield}}} | |
Footer" | |
end | |
class Index < Mustache | |
self.template = "The Index." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mustache' | |
Mustache::Parser::ALLOWED_CONTENT = /(\w|[?!\/.-])*/ | |
class ImplicitIterator < Mustache | |
define_method "." do | |
self[:to_s] | |
end | |
def names |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mustache' | |
require 'yaml' | |
class Sep < Mustache | |
def last? | |
self[:to_s] == self[:names].last.to_s | |
end | |
end | |
template = <<template |
NewerOlder