Skip to content

Instantly share code, notes, and snippets.

View timlinquist's full-sized avatar

Tim Linquist timlinquist

View GitHub Profile
@timlinquist
timlinquist / magic_numbers.http.status.rb
Created August 25, 2011 04:41
Are HTTP Status codes magic numbers?
if provider.save
render :json=>provider.to_json, :status=>200
else
render :json=>provider.errors.to_json, :status=>400
end
tail -f /data/merb_background/current/log/production.log
~ Connecting to database...
~ Parent pid: 28754
merb : merb_background_production : worker (port 5100) ~ Starting Mongrel at port 5100
merb : merb_background_production : worker (port 5100) ~
merb : merb_background_production : worker (port 5100) ~ FATAL: Could not bind to 5100. It was already in use
merb : merb_background_production : worker (port 5100) ~
merb : merb_background_production : worker (port 5101) ~ Starting Mongrel at port 5101
merb : merb_background_production : worker (port 5101) ~
merb : merb_background_production : worker (port 5101) ~ FATAL: Could not bind to 5101. It was already in use
@timlinquist
timlinquist / caching.erb
Created September 8, 2011 00:01
ERB caching
<% cache(:client=> @client.id, :store => @store.id, :action => local_assigns[:cache_action] || "prices_mobile") do %>
<div id='nav'>Testing ERB</div>
<% end %>
@timlinquist
timlinquist / caching.haml
Created September 8, 2011 00:03
haml caching
- cache(:client=> @client.id, :store => @store.id, :action => local_assigns[:cache_action] || "prices_mobile") do
%nav
Testing HAML
@timlinquist
timlinquist / associations.rb
Created September 27, 2011 18:04
Factory girl bug
#stubs :unit association and returns Array
before( :each ) do
@store = create :store
4.times { create :unit, :unit_ownership => @store }
end
#creates necessary relationship between store and units
before( :each ) do
@store = create :store
unit1, unit2, unit3, unit4 = create(:unit), create(:unit), create(:unit), build(:unit)
@timlinquist
timlinquist / download_repo.txt
Created September 28, 2011 21:24
Download speed for repo
** [xx.xx.xxx.xx :: out] Receiving objects: 99% (86987/87533), 228.11 MiB | 487 KiB/s
** [xx.xx.xxx.xx :: out] Receiving objects: 99% (86987/87533), 229.30 MiB | 611 KiB/s
** [xx.xx.xxx.xx :: out] Receiving objects: 99% (86987/87533), 229.98 MiB | 649 KiB/s
** [xx.xx.xxx.xx :: out] Receiving objects: 99% (86987/87533), 230.42 MiB | 642 KiB/s
** [xx.xx.xxx.xx :: out] Receiving objects: 99% (86987/87533), 231.08 MiB | 610 KiB/s
** [xx.xx.xxx.xx :: out] Receiving objects: 99% (86987/87533), 231.70 MiB | 595 KiB/s
** [xx.xx.xxx.xx :: out] Receiving objects: 99% (86987/87533), 232.60 MiB | 621 KiB/s
** [xx.xx.xxx.xx :: out] Receiving objects: 99% (86987/87533), 233.01 MiB | 642 KiB/s
** [xx.xx.xxx.xx :: out] Receiving objects: 99% (86987/87533), 233.63 MiB | 679 KiB/s
** [xx.xx.xxx.xx :: out] Receiving objects: 99% (86987/87533), 234.35 MiB | 703 KiB/s
@timlinquist
timlinquist / build_bug.txt
Created November 21, 2011 19:46
Build creates a record for defined associations in the database
bundle exec rspec spec/models/client_spec.rb -l 14
Run filtered including {:line_number=>14}
F
Failures:
1) Client should not create the associated object (industry)
Failure/Error: lambda{
count should not have changed, but did change from 4 to 5
# ./spec/models/client_spec.rb:15
@timlinquist
timlinquist / backbone_bp.markdown
Created December 12, 2011 18:44
Backbone best practices

General

  • User activity should manipulate data, not modify markup : Let backbone handle updating the view when an action takes place with something like an observer.

Models (use a model when your problem is inline with the items below)

  • Works with attributes (properties of the object)
  • Automatically triggers data change events ie delete, update, etc
  • Can use custom methods
  • Can use javascript properties to reference other objects (even Collections; composition?)
require 'eventmachine'
require 'em-http'
c = 4
urls = DATA.readlines.map {|s| s.strip }
pending = urls.size
before = Time.now
puts "urls: #{pending}"
puts "concurrency: #{c}"
@timlinquist
timlinquist / github_clone_url_regex.java
Created January 9, 2012 19:46
Valid clone urls for jenkins github hook plugin
private static final Pattern[] URL_PATTERNS = {
Pattern.compile("git@(.+):([^/]+)/([^/]+).git"),
Pattern.compile("https://[^/]+@([^/]+)/([^/]+)/([^/]+).git"),
Pattern.compile("git://([^/]+)/([^/]+)/([^/]+).git"),
Pattern.compile("ssh://git@([^/]+)/([^/]+)/([^/]+).git")
};