Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env zsh
#
# Works best with blinking text; the last heart will blink
# when you have less than 25% of your battery life remaining.
BATTERY="$(pmset -g ps | tail -1 | perl -pe 's/.*?(\d+)%.*/\1/')"
if [[ $BATTERY -lt 25 ]]; then
echo "\e[5;31m♥\e[0;31m♡♡\e[0m"
elif [[ $BATTERY -lt 50 ]]; then
@naudo
naudo / gist:3868506
Created October 10, 2012 21:24 — forked from dhh/gist:1014971
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@naudo
naudo / test_helper.rb
Created October 4, 2012 16:26 — forked from agraves/test_helper.rb
Allow Minitest and Rspec to coexist
# Minitest and Rspec will need separate environments because both gems define 'describe'
# 'm' is a nice test runner gem. It lets you run 'm test/models/foo.rb:21'
# Gemfile
group :minitest do
gem 'minitest-rails'
gem 'minitest-rails-capybara'
gem 'factory_girl_rails'
gem 'm'
@naudo
naudo / deploy.rake
Created October 2, 2012 00:56 — forked from njvitto/deploy.rake
Rakefile to deploy and rollback to Heroku in two different environments (staging and production) for the same app
#Deploy and rollback on Heroku in staging and production
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
namespace :deploy do
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU'
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU'
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag]
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on]
@naudo
naudo / gist:3777457
Created September 24, 2012 18:23 — forked from sstephenson/gist:1120938
Quick guide to installing rbenv
# Clone rbenv into ~/.rbenv
git clone [email protected]:sstephenson/rbenv.git ~/.rbenv
# Add rbenv to your PATH
# NOTE: rbenv is *NOT* compatible with rvm, so you'll need to
# remove rvm from your profile if it's present. (This is because
# rvm overrides the `gem` command.)
echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile
exec $SHELL
@naudo
naudo / app.js
Created August 16, 2012 02:31 — forked from joewest/app.js
ember.js login form
App = Ember.Application.create({});
App.loginController = Ember.Object.create({
// do login stuff
});
App.LoginFormView = Ember.View.extend({
login: null,
password: null,