Skip to content

Instantly share code, notes, and snippets.

View andersonfreitas's full-sized avatar

Anderson Freitas andersonfreitas

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andersonfreitas
andersonfreitas / derivative.js
Created April 18, 2014 17:43
derivative in js
function derivative(f) {
var h = 0.001;
return function(x) { return (f(x + h) - f(x - h)) / (2 * h); };
}
console.log(" cos(2) = " + Math.cos(2));
console.log("-sin(2) = " + Math.sin(2));
console.log("(d cos/dx)(2) = " + derivative(Math.cos)(2));
function f(x) { return Math.pow(x, 3) + 2 * x + 1; };
@andersonfreitas
andersonfreitas / gist:9425873
Created March 8, 2014 05:40
CentOS "Development Tools" for OpenGL
sudo yum groupinstall "Development Tools"
sudo yum install mesa*
sudo yum install libXrandr*
sudo yum install libXext*
sudo yum install libX11*
sudo yum install libXi*
sudo rpm -ivH http://pkgs.repoforge.org/cmake/cmake-2.8.8-1.el6.rfx.i686.rpm
/* Put your CSS here */
html, body {
margin: 20px;
}
@andersonfreitas
andersonfreitas / migrate.sh
Last active December 17, 2015 14:29
Move from MySQL to Percona using Homebrew
brew update
mysqldump --all-databases -u root -p > full_backup.sql
mysql.server stop
brew remove mysql
rm -rf /usr/local/var/mysql
@andersonfreitas
andersonfreitas / mp4du.sh
Last active December 15, 2015 17:29
Length of a folder with MP4 files
mp4sum() {
TOTAL=0
for x in $1/*.mp4
do
size=`mp4box -std -diso $x | grep 'TimeScale="1000"' | awk 'BEGIN{FS="\""};{ print $8 }'`
TOTAL=`expr $TOTAL + $size / 1000`
done
x='obase=60;'$TOTAL
print $x | bc
}

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
}