Skip to content

Instantly share code, notes, and snippets.

View andersonfreitas's full-sized avatar

Anderson Freitas andersonfreitas

View GitHub Profile
@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
@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: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 / screen.png
Created October 5, 2012 23:36
Math.round vs hack
http://jsperf.com/math-round-vs-hack/3
@andersonfreitas
andersonfreitas / gist:3841648
Created October 5, 2012 18:49
Test terminal colors
for i in {0..255} ; do
printf "\x1b[38;5;${i}mcolour${i}\n"
done
@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:3830035
Created October 3, 2012 21:38
blocking distractions
function block() {
if ! [ "$1" = "" ] ; then
case $1 in
on)
sudo ipfw add 7890 deny ip from news.ycombinator.com to any
sudo -s "echo '127.0.0.1 facebook.com' >> /etc/hosts"
sudo -s "echo '127.0.0.1 www.facebook.com' >> /etc/hosts"
;;
off)
sudo ipfw del 7890
import sublime, sublime_plugin
class ReturnToVintageCommandModeListener(sublime_plugin.EventListener):
def on_activated(self, view):
if view.settings().get("is_widget") is None:
view.run_command('exit_insert_mode')
@andersonfreitas
andersonfreitas / gist:3801476
Created September 28, 2012 18:44
Unlock file on Mac OS
chflags -R nouchg
sudo ipfw add 7890 deny ip from news.ycombinator.com to any