Skip to content

Instantly share code, notes, and snippets.

View davidnorth's full-sized avatar

David North davidnorth

View GitHub Profile
@davidnorth
davidnorth / devtools-immutable-bug.js
Created August 26, 2015 16:29
Enabling redux dev tools causes identity of parts of Immutable state to change when it shouldn't, breaking pure render.
let Immutable = require('immutable'),
devTools = require('redux-devtools').devTools;
let { createStore, applyMiddleware, compose } = require('redux');
let state = Immutable.fromJS({
one: { number: 1 }
});
function reducer(state, action) {
if(action.type === 'ONE') {
upstream unicorn_myapp {
server unix:/data/myapp/shared/sockets/unicorn.sock fail_timeout=0;
}
server
listen 80;
client_max_body_size 4G;
server_name _;
keepalive_timeout 5;
Bluepill.application("<%= app %>", :foreground => false, :log_file => "/data/<%= app %>/shared/log/bluepill.log") do |app|
app.uid = "<%= user %>"
app.gid = "<%= user %>"
app.working_dir = "/data/<%= app %>/current/"
<% if engine.process_names.include? 'unicorn' %>
<% process = engine.process('unicorn') %>
<% port = engine.port_for(process, 1) %>
app.process('unicorn') do |process|
process.pid_file = "/data/<%= app %>/shared/pids/unicorn.pid"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetPerformanceDetailWithDiscountingSYOSExResponse xmlns="http://tessiturasoftware.com/">
<GetPerformanceDetailWithDiscountingSYOSExResult>
<Id>1</Id>
<Title>The Kitchen</Title>
<PerformanceDate><%= @date %></PerformanceDate>
<ZoneMap>259</ZoneMap>
@davidnorth
davidnorth / gist:1140252
Created August 11, 2011 17:35
Custom helper prevents value in template updating
// In controller:
MyApp.MyController = SC.Object.create({
items: [],
total: function(){
// calculate the total value of items
}.property('items.[]')
})
// subclass ContainerView which has an array observer on childViews
MyApp.MyContainerView = SC.ContainerView.extend({
})
// Then in controller, or state chart maybe:
var newView = SC.TextField.create()
containerViewInstance.get('childViews').pushObject(newView);
<%
1.upto(100) do |i|
%>
user_<%= i %>:
email: <%= Faker::Internet.email %>
<% if User.columns.map(&:name).include?("crypted_password") %>
crypted_password: "c9ef770ede786cdb33e02c3432c16151bc727ce3c73ffcff7395eeba82da5fe01383cb30050bfc55ffd3d92afe3c1a400eb0a27c8cc372d5aa7e00e55262e9fd"
salt: "XBzzaBi04ZEQxIPz9VH"
<% end %>
<% end %>
?> a = Order.find(43).adjustments.first
=> #<Adjustment id: 7, order_id: 43, amount: #<BigDecimal:104cdf208,'0.25E1',8(8)>, label: "Shipping", created_at: "2010-09-02 19:23:06", updated_at: "2010-09-02 21:39:12", source_id: 11, source_type: "Shipment", mandatory: nil, frozen: nil, originator_id: 1, originator_type: "ShippingMethod">
?> a.originator_id
=> 1
>> a.originator_id = 3
=> 3
>> a.save!
=> true
>> a.reload
context "#remove_item" do
before do
real_order = Order.create
Fabricate(:line_item, :order => real_order)
controller.stub(:current_order).and_return(real_order)
end
it "should remove an existing line item from the order" do
delete :remove_item, :id => real_order.line_items.first.id
real_order.line_items.count.should == 0
end
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
Rails.env == "production" ? require(c) : load(c)
end