Skip to content

Instantly share code, notes, and snippets.

View andersonfreitas's full-sized avatar

Anderson Freitas andersonfreitas

View GitHub Profile
@andersonfreitas
andersonfreitas / gist:3856171
Created October 9, 2012 02:10
Loading MathJax Dynamically
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://cdn.mathjax.org/mathjax/latest/MathJax.js"; // use the location of your MathJax
var config = 'MathJax.Hub.Config({' +
'extensions: ["tex2jax.js"],' +
'jax: ["input/TeX","output/HTML-CSS"]' +
'});' +
'MathJax.Hub.Startup.onload();';
@andersonfreitas
andersonfreitas / multibyte.py
Created November 23, 2012 20:11
Sublime plugin to convert multibyte strings
# coding: utf-8
import sublime, sublime_plugin
import re
from unicodedata import normalize
class NormalizeSelectionCommand(sublime_plugin.TextCommand):
def run(self, edit):
sels = self.view.sel()
for sel in sels:
selected = self.view.substr(sel)
@andersonfreitas
andersonfreitas / gist:4355992
Last active June 24, 2021 13:29
Installing nmon on Amazon Linux AMI

Installing nmon on Amazon Linux AMI

nmon is an excellent performance monitor for Linux systems.

Since Amazon Linux AMI is compatible with RHEL5, I've downloaded a binary RPM from:

http://pkgs.repoforge.org/nmon/

$ wget http://pkgs.repoforge.org/nmon/nmon-14g-1.el5.rf.i386.rpm
#!/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 / 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'
# 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

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:

@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
}
@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
/* Put your CSS here */
html, body {
margin: 20px;
}