Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# From https://github.com/ginatrapani/todo.txt-cli/tree/addons/.todo.actions.d/adda
action=$1
shift
[ "$action" = "usage" ] && {
echo " Add and prioritize A:"
curcmd=`basename $0`
@cedricpim
cedricpim / mailcatcher.service
Created January 18, 2016 22:18
Mailcatcher Systemd Service (with rbenv and vagrant)
# /usr/lib/systemd/system/mailcatcher.service
[Unit]
Description=MailCatcher Service
After=network.service vagrant.mount
[Service]
Type=simple
ExecStart=/home/vagrant/.rbenv/shims/mailcatcher --ip 0.0.0.0 --foreground
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
@cedricpim
cedricpim / install_phantomjs.sh
Last active August 29, 2015 14:26
Install PhantomJS 2 on debian/ubuntu
# Install dependencies for PhantomJS
sudo apt-get -y install build-essential g++ flex bison gperf ruby perl \
libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev \
libpng-dev libjpeg-dev python libx11-dev libxext-dev
# Directory to install PhantomJS
cd /usr/local/share
sudo git clone git://github.com/ariya/phantomjs.git
cd phantomjs
sudo git checkout 2.0
@cedricpim
cedricpim / struct_hash_ostruct_class
Last active August 29, 2015 14:23
Struct vs Hash vs OpenStruct vs Class benchmark
require 'benchmark'
require 'ostruct'
require 'memory_profiler'
i = 100000
User = Struct.new(:name, :age)
USER = "User".freeze
AGE = 21
@cedricpim
cedricpim / python2.7.9.sh
Created June 4, 2015 13:49
Python 2.7.10 and Vim problem
brew unlink python
brew install https://raw.githubusercontent.com/Homebrew/homebrew/1681e193e4d91c9620c4901efd4458d9b6fcda8e/Library/Formula/python.rb
brew switch python 2.7.9
@cedricpim
cedricpim / gist:5986a839ff40e6bded86
Last active March 15, 2017 21:33 — forked from zbal/gist:7800423
VirtualBox Guest Additions
# Based on https://gist.github.com/fernandoaleman/5083680
# Start the old vagrant
$ vagrant init ubuntu_saucy
$ vagrant up
# You should see a message like:
# [default] The guest additions on this VM do not match the install version of
# VirtualBox! This may cause things such as forwarded ports, shared
# folders, and more to not work properly. If any of those things fail on
@cedricpim
cedricpim / introrx.md
Last active August 29, 2015 14:08 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns                     on recent CPU
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 µ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 4X memory

#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'