Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
class ChangeIgnoredToBoolean < ActiveRecord::Migration | |
# we should have been using boolean vs string for a flag instead of a string | |
def up | |
# preserve existing data | |
@saved_ignored_state = Message.all.map(&:ignored) | |
change_column(:messages, :ignored, :boolean, :default => false) | |
Message.reset_column_information | |
Message.all.each_with_index do |message,index| | |
message.update_attribute(:ignored,@saved_ignored_state[index] == 'true') | |
end |
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 |
#!/bin/bash | |
# License: Public Domain. | |
# Author: Joseph Wecker, 2012 | |
# | |
# -- DEPRICATED -- | |
# This gist is slow and is missing .bashrc_once | |
# Use the one in the repo instead! https://github.com/josephwecker/bashrc_dispatch | |
# (Thanks gioele) | |
# | |
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile? |
Locate the section for your github remote in the .git/config
file. It looks like this:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:joyent/node.git
Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:
I googled around, especially with site:news.ycombinator.com
for backup recommendations.
Here are notes on the top hits.
= simple_form_for @portfolio do |f| | |
= f.input :title, label: 'Portfolio Title' | |
= f.simple_fields_for :assets do |assets_form| | |
.duplicatable_nested_form | |
= assets_form.association :stock | |
= assets_form.input :amount, :input_html => { min: 0 } | |
= link_to 'Remove', '', :class => 'destroy_duplicate_nested_form' | |
= assets_form.input :id, as: :hidden |
module MyApp | |
class Application < Rails::Application | |
# ... | |
config.exceptions_app = self.routes | |
config.action_dispatch.rescue_responses.merge!( | |
"RDS::ResourceNotFound" => :not_found, | |
) | |
# ... | |
end |
# http://www.rdoc.info/github/costan/smartcard/master/Smartcard | |
require 'smartcard' | |
class SmartCardAdapter | |
# scope of the smart-card connection; valid values are :system, :user, and :terminal | |
# (see the SCARD_SCOPE_ constants in the PC/SC API) | |
def connect(scope = :system) | |
@context = Smartcard::PCSC::Context.new(scope) | |
end | |