Skip to content

Instantly share code, notes, and snippets.

View nexneo's full-sized avatar

Niket Patel nexneo

View GitHub Profile

Types

A type is a collection of possible values. An integer can have values 0, 1, 2, 3, etc.; a boolean can have values true and false. We can imagine any type we like: for example, a HighFive type that allows the values "hi" or 5, but nothing else. It's not a string and it's not an integer; it's its own, separate type.

Statically typed languages constrain variables' types: the programming language might know, for example, that x is an Integer. In that case, the programmer isn't allowed to say x = true; that would be an invalid program. The compiler will refuse to compile it, so we can't even run it.

build_package_patched() {
# These three patches are included when RVM builds REE
cd source
wget 'https://github.com/wayneeseguin/rvm/raw/master/patches/ree/1.8.7/tcmalloc.patch'
wget 'https://github.com/wayneeseguin/rvm/raw/master/patches/ree/1.8.7/stdout-rouge-fix.patch'
wget 'https://github.com/wayneeseguin/rvm/raw/master/patches/ree/1.8.7/no_sslv2.diff'
patch -p1 < tcmalloc.patch
patch -p1 < stdout-rouge-fix.patch
patch -p1 < no_sslv2.diff
cd ..
@nexneo
nexneo / gobreak.sh
Last active December 16, 2015 19:19 — forked from icholy/gobreak.sh
#!/bin/sh
# Demo http://ascii.io/a/3019
# build with debug flags
go build -gcflags "-N -l" -o out
# find the debugger comments
awk '/\/\/debugger/ { print "break " FILENAME ":" FNR; }' `find $PWD -name "*.go" | xargs` > .breakpoints

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

@nexneo
nexneo / latency.txt
Created May 31, 2012 16:50 — forked from jboner/latency.txt
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
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
Disk seek 10,000,000 ns
module Jobs
module ScheduledJob
def self.included(base)
base.extend(ClassMethods)
end
def perform_with_schedule
Delayed::Job.enqueue self, 0, self.class.schedule.from_now.getutc
perform_without_schedule
end
;; javasound
(import '(javax.sound.sampled AudioSystem Line DataLine DataLine$Info SourceDataLine TargetDataLine AudioFormat))
(defn get-audio-format [samplerate bitsize channels]
(new AudioFormat samplerate bitsize channels true false))
(defn get-source-data-line-info [audioformat]
(new DataLine$Info SourceDataLine audioformat))
(defn get-source-data-line [datalineinfo]