Skip to content

Instantly share code, notes, and snippets.

View supairish's full-sized avatar
🏂
Shreddin

Chris Irish supairish

🏂
Shreddin
View GitHub Profile
@ilyakatz
ilyakatz / active_admin.rb
Created August 12, 2014 17:35
Custom default order order in active_admin
# initializers/active_admin.rb
module ActiveAdmin
class OrderClause
alias_method :initialize_old, :initialize
alias_method :valid_old?, :valid?
alias_method :to_sql_old, :to_sql
def initialize(clause)
if clause.class == String
initialize_old(clause)

Ember data conventions

Model

App.Customer = DS.Model.extend({
  firstName:attr('string'),
  address:belongsTo('address')
});
@hauntedhost
hauntedhost / hookup_container_example.js
Created September 9, 2014 22:36
Ember.js HookupContainer mixin
// mixins/hookup_container.js
App.HookupContainer = Ember.Mixin.create({
// https://github.com/tehviking/giffindor/issues/1#issuecomment-51066764
hookupContainer: function() {
this.container = SoftLacrosse.__container__;
}.on('init'),
});
// components/my_component.js
App.MyComponent = Ember.Component.extend(
@davetapley
davetapley / pending_fail.rb
Created January 23, 2015 18:01
Pending failing rspec tests
#!/usr/bin/ruby
require 'pty'
cmd = ARGV.first
begin
PTY.spawn( cmd ) do |stdin, stdout, pid|
begin
stdin.each do |line|
@jamesarosen
jamesarosen / upgrading.md
Last active August 29, 2015 14:21
Upgrading to ember-qunit 0.3.2

Recently, I upgraded from ember-qunit 0.3.1 to 0.3.2. The main reason I wanted to upgrade was to take advantage of a new way of writing component tests.

Previously, there was no way to test how the component was actually used. A component test could instantiate a component and poke at its internals, but that isn't how we use components. We use them declaratively in templates. The old style also meant it was difficult to test block templates and impossible to test block parameters.

I really wanted the new test style, but it wasn't easy to get there. The following are my upgrade notes.

Gotcha: moduleForComponent Requires Three Arguments

Many of my old component tests looked like

export default Ember.Component.extend({
interval: 1000,
timer: null,
startTimer() {
const timer = Ember.run.later(this, () => {
this.sendAction('tick');
this.startTimer();
}, this.get('interval'));
this.set('timer', timer);
},
require 'right_aws'
namespace :utils do
namespace :attachments do
task :initialize_s3 => :environment do
s3_config = YAML.load_file(File.join(File.dirname(__FILE__), '/../../config/amazon_s3.yml'))
s3_config = s3_config[RAILS_ENV].to_options
@s3 = RightAws::S3.new(s3_config[:access_key_id], s3_config[:secret_access_key])
end
module PaperclipMigrations
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def add_paperclip_fields(table, prefix)
add_column table, "#{prefix}_file_name", :string
add_column table, "#{prefix}_content_type", :string
# Include this in your RAILS_ROOT/test/test_helper.rb
class ActionController::TestCase
def better_cookies
cookies = {}
Array(@response.headers['Set-Cookie']).each do |cookie|
key = nil
details = cookie.split(';').inject({}) do |fields, cookie_field|
pair = cookie_field.split('=').map {|val| Rack::Utils.unescape(val.strip)}
key = pair.first unless key
#Tasks have been added to fully maintain nginx, unicorn, redis, memcached, start resque workers and run any command on any server in the farm.
#<pre>
#cap nginx:restart # Restart Nginx.
#cap nginx:start # Start Nginx.
#cap nginx:status # Status of Nginx.
#cap nginx:stop # Stop Nginx.
#cap nginx:tail_error # Tail the Nginx error logs.
#cap unicorn:reload # reload your unicorn servers.
#cap unicorn:restart # restart your unicorn servers.
#cap unicorn:start # start your unicorn servers.