Skip to content

Instantly share code, notes, and snippets.

View nathanpalmer's full-sized avatar

Nathan Palmer nathanpalmer

  • Crowd Ox
  • Washington, DC
View GitHub Profile
@nathanpalmer
nathanpalmer / base_action.rb
Last active August 29, 2015 14:16
Action separation for a controller
# Setup in a scenario way with perform the basic action that we have from base_actions controller
#
# Emulate or possibly just use the callbacks from within rails
# https://github.com/rails/rails/blob/master/actionpack/lib/abstract_controller/callbacks.rb
#
# This gives us the before_/after_/around_ filters along with a `run_callbacks` method
class BaseUpdateAction
def perform(method)
saved = each_from_parameters(params[collection_name]) do |model_hash|
# Need a way to get access to the model we're getting, but I haven't dug into the run_callbacks method
@nathanpalmer
nathanpalmer / setup.sh
Created February 13, 2015 16:02
Creating a new ember-cli project using coffeescript, sass and a few dependencies
# First you'll want to make sure to install ember-cli
# Install 0.1.12 explicitely until we make sure the latest is working. I ran into several first-run issues on the newest version.
npm install -g [email protected]
# Then create the initial project. This will create all the basic files you need
# install the npm and bower dependencies and create an initial git commit.
ember new todo
cd todo/
# Now install coffeescript. We use the ember-cli-coffees6 so we don't need
@nathanpalmer
nathanpalmer / convert_with_image_redirect.rb
Created February 12, 2015 22:54
Convert image sources to be usable even through redirects and https
require 'imgkit'
require 'dimensions'
require 'nokogiri'
require 'net/http'
require 'uri'
count = 0
def get_url(original_url, count, redirect_url = nil, limit = 10)
raise ArgumentError, 'HTTP redirect too deep' if limit == 0
@nathanpalmer
nathanpalmer / app.js
Created February 3, 2015 22:03
ember-cli
// Please wait a bit.
// Compiled script is not shown while source map is being loaded!
@nathanpalmer
nathanpalmer / addon.js
Last active August 29, 2015 14:14
Addon Application
import Ember from 'ember';
initialize = function(container, app) {
container.lookup('route:application').reopen({
error: function(error, transition, originRoute) {
// Something happens here to prepare the object
// Then we report it to the main application
report(modifiedError);
}
});
@nathanpalmer
nathanpalmer / gist:00d443fa698f67c053c2
Created January 7, 2015 17:16
SpruceMail Pull Request Template
## Links ##
- [Sprintly Story](https://url.to.sprintly.story)
- [Staged Site](http://url.to.staged.site)
## Summary ##
- High level list
- Of major
- Changes
**Notes**: Any additional context here
@nathanpalmer
nathanpalmer / bootstrap-terminal.sh
Last active August 29, 2015 14:11
Bootstrap Terminal.com
# Postgres
source <(curl -s https://gist.githubusercontent.com/nathanpalmer/aa102e03ab3c9432f8c5/raw/718f019bfef9984c4aaf6feaa559809bf014039f/install-postgres.sh)
# Redis
sudo apt-get install redis-server redis-tools -y
# RVM
source <(curl -s https://gist.githubusercontent.com/nathanpalmer/b00226cc57a3eaed3110/raw/ef458d3c21f1350d595cb674737e9eb47f87c79b/install-rvm.sh)
# Other things we need
@nathanpalmer
nathanpalmer / install-rvm.sh
Created December 18, 2014 16:18
Install RVM
#!/usr/bin/env bash
# install rvm
gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable
source /etc/profile
rvm install ruby-2.1.2
@nathanpalmer
nathanpalmer / install-postgres.sh
Last active August 29, 2015 14:08
Install Postgres
#!/usr/bin/env bash
# make sure it's setup as UTF-8 by default
update-locale LANG=C.UTF-8 LC_ALL=C.UTF-8
dpkg-reconfigure locales
# install postgres
apt-get update
apt-get -y install postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3
sed -i '/local all all peer/c\local all all trust' /etc/postgresql/9.3/main/pg_hba.conf
@nathanpalmer
nathanpalmer / test.rb
Created October 24, 2014 20:07
Return statement in exception block
def main_method
puts '1: Start'
some_method_with_block do
puts '2: Inside'
fail 'Something bad happened'
end
puts '3: Finish'
end
def some_method_with_block