This file contains hidden or 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
class GradeLevel | |
attr_accessor :number | |
def initialize(num) | |
@number = num | |
end | |
def order_index | |
number =~ /K(\d)/ ? $1.to_i : (number.to_i + 2) | |
end | |
end |
This file contains hidden or 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
In a temporary directory: | |
curl -O http://opensource.apple.com/tarballs/gcc/gcc-5666.3.tar.gz | |
tar zxf gcc-5666.3.tar.gz | |
cd gcc-5666.3 | |
mkdir -p build/obj build/dst build/sym | |
gnumake install RC_OS=macos RC_ARCHS='i386 x86_64' TARGETS='i386 x86_64' SRCROOT=`pwd` OBJROOT=`pwd`/build/obj DSTROOT=`pwd`/build/dst SYMROOT=`pwd`/build/sym | |
sudo ditto build/dst / |
This file contains hidden or 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
head -n 500000 larger_file.txt | tail -n 100000 > smaller_file.txt |
This file contains hidden or 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
import random | |
import ModestMaps | |
# import whereami # this script borrows bits from whereami: https://github.com/migurski/whereami | |
# Using rough boundaries of the United States | |
lat_bounds = [32,41.5] | |
lng_bounds = [-116.5,-80] | |
num_of_places = 1000 |
This file contains hidden or 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
# Finding duplicates in a list | |
import collections | |
the_list = [2,2,2,1,1,0] | |
count = collections.Counter(the_list) |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Animated Sparkline</title> | |
<script src="http://mbostock.github.com/d3/d3.js?2.7.2"></script> | |
<style type="text/css"> | |
path { | |
stroke: steelblue; | |
stroke-linecap: round; |
This file contains hidden or 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 sys import argv | |
from time import time | |
from glob import glob | |
from os import stat, kill, getuid | |
from os.path import basename, dirname, join | |
from datetime import datetime | |
from random import choice | |
from signal import SIGTERM | |
if __name__ == '__main__': |
This file contains hidden or 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
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 |
This file contains hidden or 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
var π = Math.PI; // uni_pi = '\u03C0'; | |
console.log(π); | |
// >> 3.141592653589793 |
This file contains hidden or 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
var LambertProjection = function(lat0, lon0, lat1, lat2, xmin, ymin, xmax, ymax) | |
{ | |
var pi = Math.PI, ln = Math.log, pow = Math.pow, | |
sin = Math.sin, cos = Math.cos, tan = Math.tan, | |
atan = Math.atan, sqrt = Math.sqrt; | |
function sec(t) { return 1 / cos(t); } | |
function cot(t) { return 1 / tan(t); } | |
function deg2rad(deg) { return pi * deg / 180; } |