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
Parameters: {"group"=>{"enable_publisher_tab"=>"0", "title"=>"frogs", "feedback_visibility"=>"open", "is_private"=>"false", "locations_attributes"=>{"0"=>{"url"=>"http://frogs.totaltechshop.com", "selector"=>"body p"}, "1"=>{"url"=>"", "selector"=>"body p"}}, "allow_member_invite"=>"0", "group_type"=>"open", "allow_join_requests"=>"0", "short_name"=>"frogs", "publisher_logo_name"=>"", "description"=>"all about frogs"}, "commit"=>"Create Group", "authenticity_token"=>"wsRBrcH0Q1lWBBiCDvWRtceOpabF2ph7Sabmsd0zA+o="} |
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
function hex2rgb(hex) { | |
var c, o = [], k = 0, m = hex.match( | |
/^#(([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})|([0-9a-f])([0-9a-f])([0-9a-f]))$/i); | |
if (!m) return {r:0,g:0,b:0}; | |
for (var i = 2, s = m.length; i < s; i++) { | |
if (undefined === m[i]) continue; | |
c = parseInt(m[i], 16); | |
o[k++] = c + (i > 4 ? c * 16 : 0); | |
} |
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 script will install the following Textmate bundles | |
# | |
# Languages | |
# - c https://github.com/textmate/c.tmbundle | |
# - coffeescript https://github.com/jashkenas/coffee-script-tmbundle | |
# - context free https://github.com/textmate/context-free.tmbundle | |
# - erlang https://github.com/textmate/erlang.tmbundle | |
# - haskell https://github.com/textmate/haskell.tmbundle.git | |
# - html https://github.com/textmate/html.tmbundle |
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
#| | |
for both proj2 and proj3 you'll have to select "things" weighted by some | |
bias on how much we like "things" (e.g. stinky roads we do *not* like) | |
it uses a set of useful techniques that i'll walk us through on thursday | |
the following code is my generic "pick with bias code". here's the output | |
of the !pick1 and !pick2 demo. each demo is 10000 picks, biased by | |
the weights within the bias | |
CL-USER> (!pick1) |
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
################################################################ | |
# For views/migrations etc. check http://tinyurl.com/3xfx3zm # | |
################################################################ | |
# File : RAILS_APP/config/initializers/devise.rb | |
# Change the following only. Rest can stay same | |
# NOTE : You must use devise master or any version released after Mar 13, 2011 to get everything mentioned here working. | |
config.authentication_keys = [ :login ] | |
config.confirmation_keys = [ :login ] | |
config.unlock_keys = [ :login ] |
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
require 'httparty' | |
class Api::Bitly | |
include HTTParty | |
base_uri 'api.bit.ly' | |
basic_auth 'username', 'password' | |
format :json | |
def self.shorten(url) | |
response = get('/shorten', :query => required_params.merge(:longUrl => url)) |
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 goes in config/deploy.rb | |
namespace :memcached do | |
desc "Flush memcached" | |
task :flush, :roles => [:app] do | |
run("cd #{current_release} && RAILS_ENV=#{rails_env} /usr/bin/rake memcached:flush") | |
end | |
desc "Flush memcached if there are any pending migrations (hook this before db:migrate)" | |
task :flush_if_pending_migrations, :roles => [:app] do | |
output = capture("cd #{current_release} && RAILS_ENV=#{rails_env} /usr/bin/rake db:pending_migration_count" |
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
The red LED indicates the digital audio is switched on. | |
To toggle it off, simply run: | |
amixer set IEC958 off |
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
require 'mongoid' | |
# MongoDB ENV vars | |
File.open(File.join(RAILS_ROOT, 'config/mongodb.yml'), 'r') do |f| | |
@settings = YAML.load(f)[RAILS_ENV] | |
end | |
port = @settings["port"].nil? ? Mongo::Connection::DEFAULT_PORT : @settings["port"] | |
host_arr = @settings["host"] | |
connect = Mongo::Connection.multi([[host_arr[0], 27017], [host_arr[1], 27017], [host_arr[2], 27017]], :read_secondary => true) | |
db = connect.db(@settings["database"]) |
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
(defmacro deftestpackage (package-name for-package &optional (test-library-package-name :unit-test)) | |
"Define a new package PACKAGE-NAME used to test the package | |
designated by FOR-PACKAGE. The new package will import all symbols | |
from FOR-PACKAGE and :USE the package designated by | |
TEST-LIBRARY-PACKAGE-NAME which supposedly contains unit testing | |
functions and macros." | |
`(defpackage ,package-name | |
(:use ,test-library-package-name ,@(mapcar #'package-name (package-use-list for-package))) | |
(:import-from ,for-package | |
,@(let (symbols) |
OlderNewer