Skip to content

Instantly share code, notes, and snippets.

View andersonfreitas's full-sized avatar

Anderson Freitas andersonfreitas

View GitHub Profile
@andersonfreitas
andersonfreitas / strip_comments.py
Created November 18, 2015 00:24 — forked from amerberg/strip_comments.py
A script to remove comments from LaTeX source
import ply.lex, argparse, io
#Usage
# python stripcomments.py input.tex > output.tex
# python stripcomments.py input.tex -e encoding > output.tex
def strip_comments(source):
tokens = (
'PERCENT', 'BEGINCOMMENT', 'ENDCOMMENT', 'BACKSLASH',
'CHAR', 'BEGINVERBATIM', 'ENDVERBATIM', 'NEWLINE', 'ESCPCT',
# Check style:
proof:
echo "weasel words: "
sh bin/weasel *.tex
echo
echo "passive voice: "
sh bin/passive *.tex
echo
echo "duplicates: "
perl bin/dups *.tex

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

@andersonfreitas
andersonfreitas / .gitignore
Last active August 29, 2015 14:01 — forked from wrobstory/.gitignore
Up and Down the Python Data and Web Visualization Stack
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/

How to Ruby Debug with Pow

Below are steps I followed to get ruby debugger ruby-debug running with Pow. Based on info from this thread basecamp/pow#43 and this blog post http://flochip.com/2011/04/13/running-pow-with-rdebug/

1) Update your Gemfile

Assuming you're writing your app in Ruby 1.9 and using Bundler, just add the dependency to your development gems:

# Build Passes
curl -d "room_id=ourRoom&from=BuildBot&message=Build+Status:+Passing&color=green" https://api.hipchat.com/v1/rooms/message?auth_token=AUTH_TOKEN_HERE&format=json
# Build Fails
curl -d "room_id=ourRoom&from=BuildBot&message=Build+Status:+Failing&color=red&notify=1" https://api.hipchat.com/v1/rooms/message?auth_token=AUTH_TOKEN_HERE&format=json
@andersonfreitas
andersonfreitas / Gemfile
Created February 5, 2013 01:26 — forked from soffes/Gemfile
source 'https://rubygems.org'
# The latest version of Ruby
ruby '2.0.0'
# The lastest version of Rails
gem 'rails', '3.2.11'
# Postgres
gem 'pg'
#!/usr/bin/tclsh8.5
#
# Usage: git-unmerged branch1 branch2
#
# Shows all the non-common commits in the two branches, where non-common
# commits means simply commits with a unique commit *message*.
proc getlog branch {
lrange [split [exec git log $branch --oneline] "\n"] 0 400
}
@andersonfreitas
andersonfreitas / object-watch.js
Created October 4, 2012 01:36 — forked from eligrey/object-watch.js
object.watch polyfill
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@andersonfreitas
andersonfreitas / gist:3789796
Created September 26, 2012 18:47 — forked from sandinist/gist:1659881
forward-delete in IRB and ZSH

iTerm2

  • Go to iTerm > Preferences... > Keys
  • Add a Global Shortcut Key
  • Type the delete key as Shortcut
  • Select Send Hex Codes as Action and type 0x004
  • Click on OK and you're good to go

zsh