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 Helpers | |
def self.constantize(camel_cased_word) | |
names = camel_cased_word.split('::') | |
names.shift if names.empty? || names.first.empty? | |
constant = Object | |
names.each do |name| | |
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) | |
end | |
constant |
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
// HOWTO: load LABjs itself dynamically! | |
// inline this code in your page to load LABjs itself dynamically, if you're so inclined. | |
(function (global, oDOC, handler) { | |
var head = oDOC.head || oDOC.getElementsByTagName("head"); | |
function LABjsLoaded() { | |
// do cool stuff with $LAB here | |
} |
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
#badge_global { | |
background: url(/images/badges/all_badges_sprite.png) no-repeat top left; | |
} | |
#badge_global.sprite-CouchPotato{ background-position: 0 0; width: 50px; height: 50px; } | |
#badge_global.sprite-Eagle{ background-position: -52px 0; width: 50px; height: 50px; } | |
#badge_global.sprite-EarlyBird{ background-position: -104px 0; width: 50px; height: 50px; } | |
****** |
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
$sql = mysqli_query($link, "SELECT parameter_id, min_value, number_hit FROM intervals"); | |
if(!$sql) { | |
print_r(mysqli_error($link)); | |
} | |
while($row = mysqli_fetch_assoc($sql)) { | |
if($crowd[$row['parameter_id']] == null) { | |
$crowd[$row['parameter_id']] = array('interval' => array(), 'hits' => array()); | |
} |
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
`brew install redis` | |
`sudo mate /Library/LaunchDaemons/org.redis.redis-server.plist` | |
...enter content... | |
`sudo launchctl load /Library/LaunchDaemons/org.redis.redis-server.plist` | |
`sudo launchctl start org.redis.redis-server` |
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" | |
ActiveSupport::Dependencies.load_paths << Rails.root.join("app", "views") | |
class Mustache::Rails < Mustache | |
include ActionController::UrlWriter | |
include ActionView::Helpers | |
attr_accessor :request, :response, :params, :controller |
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
// Add a Mustache.js templating function to your JavaScript: | |
Mustache.template = function(templateString) { | |
return function () { | |
if (arguments.length < 1) { | |
// With no arguments, return the raw template -- useful for rendering | |
// partials. | |
return templateString; | |
} else { | |
return Mustache.to_html(templateString, arguments[0], arguments[1]); |
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
var val1, val2, val3, str, obj; | |
str = "info.first_name"; | |
obj = { | |
info: { | |
first_name: "Bob" | |
} | |
}; |
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'daemons' | |
# This is a bit hacky, but we don't have a clean way to hook into the parsed | |
# options, as Daemons is managing these internally. | |
number = 0 | |
for i in 0..ARGV.length | |
if ARGV[i] == '--number' | |
number = ARGV[i + 1] |
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
# If we ever end up running God / Starling on other environments than production. | |
# we'll have to find a different way to set the values below. | |
STARLING_PORT = 15151 | |
STARLING_HOST = '<my ip address>' | |
RAILS_ENV = 'production' | |
# Based on example from <http://railscasts.com/episodes/130-monitoring-with-god> | |
RAILS_ROOT = '/var/www/myapp' | |
NewerOlder