This is just a snippet. For a working example (without geolocation) see JSFidde: http://jsfiddle.net/robhurring/fKbka/light/
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
#!/usr/bin/env sh | |
# IMPORTANT: exclude the current branch (*), master and dev branch. Add any other patterns here | |
# and do a --dry-run if you're unsure | |
to_prune=$(git branch --merged dev | grep -v '\*\|master\|dev') | |
function show_help { | |
echo Usage: $(basename $0) | |
echo " -n [--dry-run] Print branches that would be removed" | |
} |
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
namespace :db do | |
desc 'sync with prod database' | |
task :sync, :backup_id do |t, args| | |
dump_file = Rails.root.join('tmp', 'latest.dump') | |
db_configs = YAML.load_file(Rails.root.join('config', 'database.yml')) | |
db_config = db_configs[Rails.env] | |
commands = [ | |
"heroku pgbackups:capture --expire", | |
"curl -o #{dump_file} \`heroku pgbackups:url #{args[:backup_id]}\`", |
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
# app/forms/base_form.rb | |
class BaseForm | |
include ActiveModel::Validations | |
include ActiveModel::Conversion | |
extend ActiveModel::Naming | |
def initialize(attributes = {}) | |
attributes.each do |name, value| | |
send("#{name}=", value) | |
end |
This is just a snippet. For a working example see JSFidde: http://jsfiddle.net/robhurring/eVBug/light/
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
# add this to your ~/.slate file | |
# source our grid | |
source ~/.slate.grid if_exists | |
# use the grid to position windows | |
alias left-half move 0;0 ${span-6};${row-12} | |
alias right-half move ${push-6};0 ${span-6};${row-12} | |
alias top-left-quarter move 0;0 ${span-6};${row-6} | |
alias top-right-quarter move ${push-6};0 ${span-6};${row-6} |
This will allow you to use devise's TokenAuthenticatable strategy while passing your :auth_token in using HTTP Authorization headers instead of params.
You can check it out using
curl -H "Authorization: Token token=XXXXXX, option=1" -vv http://railsapp.dev/api/v1/endpoint.json
It should properly authenticate using the token as well as set request.env['token.options']
to {"options" => "1"}
.
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
# small concern that allows you to override the field names for validation messages | |
# | |
# Example: | |
# | |
# # without concern | |
# class User < ActiveRecord::Base | |
# validates :name, presence: true | |
# end | |
# # => "Name can't be blank" | |
# |
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
# this: https://gist.github.com/464257 in coffeescript, without the global stuff... | |
class EventsDispatcher | |
callbacks: {} | |
bind: (event_name, callback) -> | |
@callbacks[event_name] ||= [] | |
@callbacks[event_name].push callback | |
@ | |
trigger: (event_name, data) -> |
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
# add this to your ~/.gitconfig under the alias section to allow things like "git brt" | |
[alias] | |
brt = branch-time |