Skip to content

Instantly share code, notes, and snippets.

@andyh
andyh / caprc.rb
Created December 7, 2008 22:31 — forked from topfunky/caprc.rb
# DESCRIPTION: Cap task to setup the current directory as git repository and then create and push to a remote repository via ssh.
#
# INSTALL: Copy to home directory as ~/.caprc
# RUN: cap git:setup scm=t
# If it's a Rails app run
# RUN: cap git:setup scm=t railsapp=t
#
# AUTHOR: Andy Henson (http://www.elaptics.co.uk) based on code by Geoffrey Grosenbach http://peepcode.com
#
=== Epic Snow Leopard Upgrayyyyd Guide ===
Son, you’re now living in the land of 64-bit systems.
That means that some of your 32-bit shit is now broken.
Not all is lost.
== Fixing MySQL weirdness
=== Epic Snow Leopard Upgrayyyyd Guide ===
Son, you’re now living in the land of 64-bit systems.
That means that some of your 32-bit shit is now broken.
Not all is lost.
== Fixing MySQL weirdness
Surround these with : e.g. :calling:
+1
-1
bulb
calling
clap
cop
email
feet
class CreditCard < ActiveRecord::Base
attr_accessible :bank, :benefit_earn_rate, :benefit_type, :benefit_value, :interest, :name, :brand,
:goal_name, :goal_cost, :goal_value
def goal
self.goal_cost.to_f / self.goal_value.to_f
end
end
@andyh
andyh / latency.markdown
Created August 14, 2012 13:28 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@andyh
andyh / 0. nginx_setup.sh
Created August 31, 2012 11:19 — forked from mikhailov/0. nginx_setup.sh
Nginx+Unicorn
# Nginx+Unicorn best-practices congifuration guide.
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
@andyh
andyh / edit.html.erb
Last active December 10, 2015 00:39 — forked from adammcarth/edit.html.erb
<!-- Someone can visit http://localhost:3000/profiles/my-permalink and this page will display (this part is working fine!). -->
<h2>Edit your profile, <%= @user.first_name %>.</h2>
<%= form_for @user, :html => { :class => "form-horizontal"} do |f| %>
<%= f.label :first_name, "Your First Name" %>
<%= f.text_field :first_name %>
<%= f.submit "Update Profile" %>
<% end %>
class AccountsController < ApplicationController
load_and_authorize_resource
# do not need to be logged in for :new or :create
skip_before_filter :authorize_user, only: [:new, :create]
def new
@account.users.build
@account.offices.build
@account.phone_numbers.build
@andyh
andyh / open_uri.rb
Last active December 15, 2015 05:49 — forked from anonymous/open_uri.rb
require 'spec_helper'
require 'open-uri'
it 'sends get request to web.memc to invoke the php script create_user_with_hashed_password - then validates the password in rails' do
password = 'testphp'
open_uri_result = ''
expect do
open("http://web.memc/create_user_with_hashed_password.php?password=#{password}").each do |f|
open_uri_result << f
end