Skip to content

Instantly share code, notes, and snippets.

View blaxter's full-sized avatar

Jesús García Sáez blaxter

  • Zaragoza, Spain
View GitHub Profile
@blaxter
blaxter / gist:81318
Created March 18, 2009 19:02
~/.gitconfig
[user]
name = adsdsad
email = sdad
[alias]
ci = commit
co = checkout
st = status
diffindex = diff-index -p -M -b -w --color HEAD
@blaxter
blaxter / aptana.rake
Created March 26, 2009 09:14
rake aptana:aptana task for generating both .loadpath and .projects file to load a rails project into eclipse aptana IDE
namespace :aptana do
RAILS_APPDIR = RAILS_ROOT.sub("/config/..","")
LIBS = %w{rails activerecord actionmailer actionpack
actionwebservice activeresource activesupport}
def project_name
Pathname.new(RAILS_APPDIR).basename.to_s
end
@blaxter
blaxter / vimrc
Created April 3, 2009 19:16
~/.vimrc
runtime! macros/matchit.vim
runtime! debian.vim
colorscheme torte
syntax on
:highlight Normal guibg=Black guifg=White
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
@blaxter
blaxter / irbrc
Created April 9, 2009 15:49
~/.irbrc
require 'irb/completion'
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
IRB.conf[:AUTO_INDENT] = true
IRB.conf[:PROMPT_MODE] = :SIMPLE
n addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
@blaxter
blaxter / readlog.rb
Created July 17, 2012 15:13
readlog.rb for android adb logcat
#!/usr/bin/ruby
RED = "\033[0;31m"
RESET = "\033[0m"
YELLOW = "\033[0;33m"
C = "\033[0;35m"
trap("INT") { puts; exit! 127 }
def stamp line
@blaxter
blaxter / nmea
Created July 17, 2012 15:17
Nmea info
=== GGA - Global Positioning System Fix Data ===
Time, Position and fix related data for a GPS receiver.
------------------------------------------------------------------------------
11
1 2 3 4 5 6 7 8 9 10 | 12 13 14 15
| | | | | | | | | | | | | | |
$--GGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx*hh<CR><LF>
------------------------------------------------------------------------------
@blaxter
blaxter / retry decorator
Created December 12, 2012 20:09
retry decorator for python like the ruby one
class retry(bject):
"""
Decorator to retry function calls in case they raise exceptions
times - retries times (0 means only called once, like this decorator was
not used at all)
sleep - sleep time to wait aftera failure
debug - whether print to stdout info or not
"""
def __init__(self, times=1, sleep=0, debug=False):
self.times = times
@blaxter
blaxter / pymodules.py
Created January 24, 2013 17:25
Create symlinks for python modules installed in /usr/share/pyshared in /usr/lib/pymodules/python2.7/
import os
def touch(fname, times=None):
with file(fname, 'a'):
os.utime(fname, times)
def create_pyshare_symlinks(package):
base_subdir = '/'.join(package.split('.'))
base_from = '/usr/share/pyshared/' + base_subdir
base_to = '/usr/lib/pymodules/python2.7/' + base_subdir
@blaxter
blaxter / log_decorator.py
Last active December 14, 2015 04:48
log method decorator
import logging
def log_method(fun):
"""
Example output (it will depend of you logging setup, obviously):
2013-02-25 16:13:58+0100 [-] DEBUG:root:--> Foo.update_bar
2013-02-25 16:13:58+0100 [-] DEBUG:root:<-- Foo.update_bar (0.052)
"""
def with_logging(self, *args, **kwargs):
method_name = '%s.%s' % (self.__class__.__name__, fun.__name__)