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
# Amount should be a decimal between 0 and 1. Lower means darker | |
def darken_color(hex_color, amount=0.4) | |
hex_color = hex_color.gsub('#','') | |
rgb = hex_color.scan(/../).map {|color| color.hex} | |
rgb[0] = (rgb[0].to_i * amount).round | |
rgb[1] = (rgb[1].to_i * amount).round | |
rgb[2] = (rgb[2].to_i * amount).round | |
"#%02x%02x%02x" % rgb | |
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
#!/bin/sh | |
# | |
# redis - this script starts and stops the redis-server daemon | |
# | |
# chkconfig: - 85 15 | |
# description: Redis is a persistent key-value database | |
# processname: redis-server | |
# config: /etc/redis/redis.conf | |
# config: /etc/sysconfig/redis | |
# pidfile: /var/run/redis.pid |
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
# env.rb | |
Capybara.register_driver :selenium do |app| | |
Capybara::Selenium::Driver.new(app, :browser => :chrome) | |
end | |
Download chromedriver from http://code.google.com/p/selenium/downloads/list | |
mv chromedriver to /usr/local/bin so it's in your path. |
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
// server | |
var net = require("net") | |
, server | |
; | |
server = net.createServer(function(socket){ | |
// socket.end("bye\n"); | |
socket.on("connect", function(){ | |
console.log("conectou\n"); |
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
# config/initializers/will_paginate.rb | |
module WillPaginate | |
module ActionView | |
def will_paginate(collection = nil, options = {}) | |
options[:renderer] ||= BootstrapLinkRenderer | |
super.try :html_safe | |
end | |
class BootstrapLinkRenderer < LinkRenderer |
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
class FileResource < ActiveRecord::Base | |
has_attached_file :attachment, | |
:storage => :s3, | |
:bucket => ENV['S3_BUCKET'], | |
:s3_credentials => { :access_key_id => ENV['S3_KEY'], | |
:secret_access_key => ENV['S3_SECRET'] }, | |
:path => 'files/:id/:filename', | |
:url => '/files/:id/:filename' | |