This file contains hidden or 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
| jQuery(function() { | |
| $.cookie('tz', (new Date()).getTimezoneOffset()); | |
| }); |
This file contains hidden or 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
| class Stylesheet | |
| include MongoMapper::Document | |
| class Processor | |
| def self.errors | |
| [] | |
| end | |
| attr_reader :contents |
This file contains hidden or 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
| # capistrano deployment | |
| require "bundler/capistrano" | |
| require "capistrano/ext/multistage" | |
| set :stages, %w(canary production) | |
| set :default_stage, "canary" | |
| set :application, "lolcats" | |
| set :deploy_to, "/srv/#{application}" |
This file contains hidden or 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
| #config/initializers/carrierwave.rb | |
| CarrierWave.configure do |config| | |
| if Rails.env.production? or Rails.env.development? | |
| config.storage :cloud_files | |
| config.cloud_files_username = "your_username" | |
| config.cloud_files_api_key = "your_key" | |
| config.cloud_files_container = "test" | |
| config.cloud_files_cdn_host = "c0012345.cdnn.cloudfiles.rackspacecloud.com" | |
| def store_dir |
This file contains hidden or 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
| # How we store all time views across the entire system for http://gauge.es. | |
| # All in one document that gets incremented using MongoDB $inc modifier in | |
| # every track. The $inc increments t, year.t, year.month.t, year.month.day.t | |
| # so we get to the day numbers. These are in EST, as we are in EST and these | |
| # stats are just for us. :) Nothing amazing, but thought I would share. | |
| # | |
| # >> pp View.all_time | |
| { | |
| "_id" => "all_time", | |
| "t" => 502352, |
This file contains hidden or 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
| # logger = require('logger').create() | |
| # logger.info("blah") | |
| # => [2011-3-3T20:24:4.810 info (5021)] blah | |
| # logger.debug("boom") | |
| # => | |
| # logger.level = Logger.levels.debug | |
| # logger.debug(function() { return "booom" }) | |
| # => [2011-3-3T20:24:4.810 error (5021)] booom | |
| class Logger | |
| constructor: (options) -> |
This file contains hidden or 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
| #!/bin/sh | |
| # Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the | |
| # CREATE block and create them in separate commands _after_ all the INSERTs. | |
| # Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk. | |
| # The mysqldump file is traversed only once. | |
| # Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite | |
| # Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite |
This file contains hidden or 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 bash | |
| # | |
| # Usage: rage db:migrate --trace | |
| # should work transparently like rake | |
| # | |
| # if we're in a directory controlled by bundler | |
| # we do bundle exec rake | |
| if [ -f Gemfile ]; then | |
| bundle exec rake $@ | |
| # otherwise we use the system / rvm rake |
This file contains hidden or 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
| # autoload concerns | |
| module YourApp | |
| class Application < Rails::Application | |
| config.autoload_paths += %W( | |
| #{config.root}/app/controllers/concerns | |
| #{config.root}/app/models/concerns | |
| ) | |
| end | |
| end |
This file contains hidden or 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
| # This method finds related articles using Jaccard index (optimized for PostgreSQL). | |
| # More info: http://en.wikipedia.org/wiki/Jaccard_index | |
| class Article < ActiveRecord::Base | |
| def related(limit=10) | |
| Article.find_by_sql(%Q{ | |
| SELECT | |
| a.*, | |
| ( SELECT array_agg(t.name) FROM taggings tg, tags t |
OlderNewer