Skip to content

Instantly share code, notes, and snippets.

@nragaz
nragaz / controllers.application.js
Created September 1, 2016 19:05
Binding attr=null outputs attr="true"
import Ember from 'ember';
export default Ember.Controller.extend({
value: null,
actual: null,
actions: {
getActual() {
this.set('actual', Ember.$('select option:first-child').val());
}
@nragaz
nragaz / job.md
Created September 23, 2015 17:36 — forked from peterjmit/job.md
Developer @ Apple

Apple Inc | Cupertino, CA

Apple is looking for a web and/or ops focused developer to build and maintain cutting edge web based applications that are used throughout the corporation. You should have a passion for technology and continuous learning/improvement.

We run Symfony2/PHP 5.6/Ember.js apps, write tests (BDD) and deploy to production daily. Our infrastructure is managed with Chef.

If you are interested or have any questions please get in touch! nragaz [at] apple [dot] com

diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb
index 276e4be..fd85fb7 100644
--- a/activerecord/test/cases/attribute_methods_test.rb
+++ b/activerecord/test/cases/attribute_methods_test.rb
@@ -130,23 +130,6 @@ class AttributeMethodsTest < ActiveRecord::TestCase
assert_equal ActiveSupport::TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone
end
end
-
- def test_read_attributes_after_type_cast_on_datetime
@nragaz
nragaz / consumer.rb
Created March 22, 2011 17:33
Consumer class to wrap Active Resource for OAuth
# Example usage:
#
# class Account < ActiveResource::Base
# self.site = "http://localhost:3000"
# end
#
# consumer = Consumer.new( user.access_token, Account )
# consumer.find(1) # => equivalent to Account.find(1), but with OAuth
class Consumer
@nragaz
nragaz / weekday_hours.sql
Created March 16, 2011 03:21
Calculate M-F hours between 2 times in MySQL
@new := reports.downloaded_at,
@old := pages.created_at,
@oldWeek := WEEK(@old, 2),
@newWeek := WEEK(@new, 2),
@weekends := @newWeek - @oldWeek,
@weekendSecs := @weekends * 172800,
@oldWeekSaturday := STR_TO_DATE( CONCAT(DATE_FORMAT(@old, '%X%V'), ' Saturday'), '%X%V %W %h-%i-%s'),
@extraFirstWeekSecs := TIME_TO_SEC( TIMEDIFF(@old, @oldWeekSaturday) ),
@extraFirstWeekSecs := (@extraFirstWeekSecs > 0) * @extraFirstWeekSecs,
@newWeekSaturday := STR_TO_DATE( CONCAT(DATE_FORMAT(@new, '%X%V'), ' Saturday'), '%X%V %W %h-%i-%s'),
@nragaz
nragaz / rails.history.js
Created January 16, 2011 23:43
Add callbacks to remote links in Rails to manage browser history using pageState and replaceState
function historySupport() {
return !!(window.history && window.history.pushState !== undefined);
}
function pushPageState(state, title, href) {
if (historySupport()) {
history.pushState(state, title, href);
}
}
@nragaz
nragaz / unicorn.rb
Created July 12, 2010 03:34
unicorn.rb
# unicorn_rails -c /srv/myapp/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
working_directory (rails_env == 'production' ? "/srv/myapp/current" : `pwd`.gsub("\n", ""))
worker_processes (rails_env == 'production' ? 10 : 4)
preload_app true
timeout 30
if rails_env == 'production'
CURRENT_RUBY = 'ree-1.8.7-2010.02'
RUBY_PATH = "/home/rails/.rvm/rubies/#{CURRENT_RUBY}"
GEM_HOME = "/home/rails/.rvm/gems/#{CURRENT_RUBY}"
ssh_options[:paranoid] = false
ssh_options[:forward_agent] = true
default_run_options[:pty] = true
set :stages, %w(staging production)
@nragaz
nragaz / all.god
Created July 12, 2010 03:16
God configs for starting Resque and Unicorn
PID_DIR = '/srv/myapp/shared/pids'
RAILS_ENV = ENV['RAILS_ENV'] = 'production'
RAILS_ROOT = ENV['RAILS_ROOT'] = '/srv/myapp/current'
BIN_PATH = "/home/rails/.rvm/gems/ree-1.8.7-2010.02/bin"
God.log_file = "#{RAILS_ROOT}/log/god.log"
God.log_level = :info
%w(unicorn resque).each do |config|
God.load "#{RAILS_ROOT}/config/god/#{config}.god"
def rails_gems
gemrc = {
:verbose => true,
:gem => '--no-ri --no-rdoc',
:update_sources => true,
:sources => [
'http://rubygems.org'
]
}
gemrc.merge!(configuration[:rubygems]) if configuration[:rubygems]