Skip to content

Instantly share code, notes, and snippets.

View effkay's full-sized avatar

Felipe Kaufmann effkay

View GitHub Profile
@effkay
effkay / hash_vs_inject.rb
Created February 17, 2011 11:52
Hash[] instead of inject
values = some_list.map do |val|
[val, some_transformation(val)]
end
Hash[values]
@effkay
effkay / redis-memory-usage.sh
Created January 4, 2011 08:36
redis memory usage
#!/bin/sh
if [ "$1" == "-h" ]; then
redis-cli info | grep 'used_memory_human:' | cut -d ':' -f2
else
redis-cli info | grep 'used_memory:' | cut -d ':' -f2
fi
sed -n '1,3p' # sed file from line 1 to line 3
curl -sw '%{http_code}\n' www.google.com -o /dev/null
namespace :bundler do
task :create_symlink, :roles => :app do
set :bundle_dir, File.join(release_path, 'vendor/bundle')
shared_dir = File.join(shared_path, 'bundle')
run "rm -rf #{bundle_dir}" # in the event it already exists..?
run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{bundle_dir}")
end
task :bundle_new_release, :roles => :app do
@effkay
effkay / bdd.task
Created July 27, 2010 07:58
BDD Rakefile
require 'rubygems'
require 'rake'
require 'cucumber/rake/task'
require 'spec/rake/spectask'
Spec::Rake::SpecTask.new(:spec) do |task|
task.spec_opts = ['--options', "spec/support/spec.opts"]
end
Cucumber::Rake::Task.new(:features)
%meta{ :name => "viewport", :content => "width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0" }
// or:
<meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0" name="viewport">
# config/initializers/carrierwave.rb
CarrierWave.configure do |config|
config.grid_fs_database = "database_name"
config.grid_fs_host = 'localhost'
config.grid_fs_access_url = "/uploads"
config.storage = :grid_fs
end
#! /bin/sh
### BEGIN INIT INFO
# Provides: mongodb
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the mongodb data-store
# Description: starts mongodb using start-stop-daemon
@effkay
effkay / license
Created January 27, 2010 11:22 — forked from defunkt/license
#!/bin/sh -e
# Usage: license
# Prints an MIT license appropriate for totin' around.
#
# $ license > COPYING
year=`date "+%Y"`
cat <<EOF
Copyright (c) $year Felipe Kaufmann
Permission is hereby granted, free of charge, to any person obtaining
@effkay
effkay / _README.md
Created November 19, 2009 23:08 — forked from netzpirat/_README.md

GitHub Javascript Strategy

Unless otherwise necessary (such as mobile development), the GitHub javascript codebase is based off jQuery. You can safely assume it will be included on every page.

File naming

  • All jquery plugins should be prefixed with jquery, such as jquery.facebox
  • All github-specific jquery plugins should be prefixed with jquery.github. Like jquery.github.repo_list.js
  • All page-specific files (that only run on ONE page) should be prefixed with page. page.billing.js