Skip to content

Instantly share code, notes, and snippets.

View agibralter's full-sized avatar
:shipit:

Aaron Gibralter agibralter

:shipit:
View GitHub Profile
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
// 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
}
#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; }
******
$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());
}
`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`
@agibralter
agibralter / rails.rb
Created May 3, 2010 18:32 — forked from foca/rails.rb
Rails + Mustache
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
@agibralter
agibralter / jammit-mustache.js
Created April 19, 2010 22:22 — forked from documentcloud/jammit-mustache.js
Mustache.js templating function for Jammit.
// 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]);
var val1, val2, val3, str, obj;
str = "info.first_name";
obj = {
info: {
first_name: "Bob"
}
};
#!/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]
# 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'