[gpetrie] $ ruby -v
ruby 1.9.3p429 (2013-05-15 revision 40747) [x86_64-darwin11.4.2]
[gpetrie] $ ruby wunderground.rb
Current temperature in Cedar Rapids is: 77.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: gpl-3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu | |
MAINTAINER Code Climate <[email protected]> | |
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list | |
RUN apt-get update | |
RUN apt-get upgrade -y | |
RUN apt-get install -y curl libssl-dev libssl0.9.8 autoconf build-essential | |
RUN mkdir -p /app/vendor/ruby-1.9.3 && cd /app/vendor/ruby-1.9.3 && curl "https://s3.amazonaws.com/heroku-buildpack-ruby/ruby-1.9.3.tgz" -s -o - | tar zxf - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Core Data is great but automatic migrations can be tricky. Migrations can take a long time, which could | |
result in [your app being terminated](http://stackoverflow.com/questions/13333289/core-data-timeout-adding-persistent-store-on-application-launch) | |
if it is happening on the main thread during application launch. Performing migrations on a background | |
thread is also a [bad idea](http://stackoverflow.com/a/2866725/503916), meaning your application really | |
needs to be able to fully launch *without a Core Data stack whatsoever* in order to safely migrate. | |
This can be a huge change to make to an existing app. | |
If you're really only using Core Data as a cache, you don't actually *need* to perform a migration. | |
Simply check if the existing store is compatible with your managed object model and if so, delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
Use the latest version of the copycopter_client
gem:
gem 'copycopter_client', '2.0.0'
Export your published drafts from copycopter.com:
RAILS_ENV=production bundle exec rake copycopter:export
This will create a config/locales/copycopter.yml
file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "spec_helper" | |
# :draper_with_helpers is necessary for the Draper objects | |
# to access real helpers, including URL helpers, in the spec. | |
describe MyDecorator, "#foo", :draper_with_helpers do | |
# This is necessary for the spec itself to use URL helpers | |
# like some_path(). | |
include Rails.application.routes.url_helpers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# List all keys stored in memcache. | |
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place. | |
require 'net/telnet' | |
headings = %w(id expires bytes cache_key) | |
rows = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code is unsafe to use in a multithreaded environment. | |
object A { | |
def foo = "foo" | |
B.bar | |
} | |
object B { | |
def bar = "bar" | |
A.foo |