Skip to content

Instantly share code, notes, and snippets.

View andersonfreitas's full-sized avatar

Anderson Freitas andersonfreitas

View GitHub Profile
@andersonfreitas
andersonfreitas / gist:3777173
Created September 24, 2012 17:32
Load jQuery on any page
this.scriptObject=document.createElement('script');
this.scriptObject.type='text/javascript';
this.scriptObject.src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js';
var ssc = document.getElementsByTagName('script')[0];
ssc.parentNode.insertBefore(this.scriptObject, ssc);
@andersonfreitas
andersonfreitas / gist:3789671
Created September 26, 2012 18:23
jruby profile
# [*50..1000].collect {|val| val = val + 10}
# https://github.com/jruby/jruby/wiki/Profiling-jruby
require 'jruby/profiler'
profile_data = JRuby::Profiler.profile do
# code to be profiled:
[*50..1000].collect {|val| val = val + 10}
end
@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

sudo ipfw add 7890 deny ip from news.ycombinator.com to any
@andersonfreitas
andersonfreitas / gist:3801476
Created September 28, 2012 18:44
Unlock file on Mac OS
chflags -R nouchg
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: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
@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: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 / screen.png
Created October 5, 2012 23:36
Math.round vs hack
http://jsperf.com/math-round-vs-hack/3