Skip to content

Instantly share code, notes, and snippets.

View DanielleSucher's full-sized avatar

Danielle Sucher DanielleSucher

View GitHub Profile
@jamesgary
jamesgary / gist:5504200
Last active February 27, 2017 12:46
How to Talk to Developers - Ben Orenstein (@r00k) - RailsConf 2013

How to Talk to Developers

Ben Orenstein (@r00k)

Obey Law of Demeter

  • Reduces coupling
  • Enables refactoring

Throw something weird at people to keep their attention. Bored people don't learn anything, so focus on entertainment over being informative.

Write like a newspaper

@zmaril
zmaril / softwarehelpskill.md
Last active August 3, 2021 04:52
I want to write software that helps kill people.

I want to write software that helps kill people.

Please, before you call the police and get my github account put on lockdown, allow me a moment to explain. What I really want to do is work on projects that advance the human condition and improve people's lives. I've been in a mad dash to learn how to program for the past four or five years exactly because I realized how much good I could do for the world with a computer.

@rogerleite
rogerleite / Gemfile
Last active December 14, 2015 14:38
Tail call optimization in Ruby
source 'https://rubygems.org'
gem "method_source", "~> 0.8.1"
@mislav
mislav / procs-vs-lambda.md
Last active March 26, 2021 18:34
Jim Weirich on the differences between procs and lambdas in Ruby

Jim Weirich:

This is how I explain it… Ruby has Procs and Lambdas. Procs are created with Proc.new { }, lambdas are created with lambda {} and ->() {}.

In Ruby 1.8, proc {} creates lambda, and Ruby 1.9 it creates procs (don't ask).

Lambdas use method semantics when handling parameters, procs use assignment semantics when handling parameters.

This means lambdas, like methods, will raise an ArgumentError when called with fewer arguments than they were defined with. Procs will simply assign nil to variables for arguments that were not passed in.

@domenic
domenic / promises.md
Last active March 31, 2024 14:07
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

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 = git@github.com: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:

@codeswimmer
codeswimmer / NSNumber+Ranges.m
Created July 22, 2012 02:31 — forked from pcperini/NSNumber+Ranges.m
Quick Ranges from NSNumbers
// .h
@interface NSNumber (Ranges)
- (NSRange)to:(NSNumber *)rangeEnd;
- (BOOL)isInRange:(NSRange)range;
@end
// .m
@implementation NSNumber (Ranges)
@jboner
jboner / latency.txt
Last active May 6, 2024 07:06
Latency Numbers Every Programmer Should Know
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
The point of sore or milk in hot cream. Any
Such matters. Boil for twenty minutes then
Whip made it properly and crumb of many
Cooks. Bake the public. Make the point. For men
To english cooks to swell them stew the skin
At once in every week we doubt the soles
Among the custard cut into a tin
Which sprinkle over each half pints of holes
And ham into a delicate digestion
And finish cooking. See page. Lemonade
@scottwb
scottwb / application_controller.rb
Created February 17, 2012 06:12
Get a list of all the filters on a given Rails 3 controller.
# Add these methods to your ApplicationController. Then, any controller
# that inherits from it will have these methods and can programmatically
# determine what filters it has set.
class ApplicationController < ActionController::Base
def self.filters(kind = nil)
all_filters = _process_action_callbacks
all_filters = all_filters.select{|f| f.kind == kind} if kind
all_filters.map(&:filter)
end