Skip to content

Instantly share code, notes, and snippets.

View lukaszb's full-sized avatar

Lukasz Balcerzak lukaszb

  • Warsaw
View GitHub Profile
@lukaszb
lukaszb / imports.py
Created October 29, 2012 16:45
Imports python object from given path
def import_obj(obj_path):
"""
Returns object from the given path.
For example, in order to get function located at
``os.path.abspath``:
abspath = import_obj('os.path.abspath')
#!/usr/bin/env python
"""
I couldn't register at www.freesound.org so I wrote this little script to make
downloading sounds from their site easy.
Usage
-----
getfreesound.py URL
@lukaszb
lukaszb / adb logcat
Created July 18, 2012 14:36
APK creation
07-18 17:00:36.059 1691 1691 D dalvikvm: GC_EXPLICIT freed 16K, 15% free 2743K/3203K, paused 1ms+1ms
07-18 17:00:36.071 253 258 I SubMicro: sdv/00 0a 92
07-18 17:00:41.087 496 496 D dalvikvm: GC_EXPLICIT freed 133K, 17% free 2876K/3463K, paused 1ms+2ms
07-18 17:00:42.635 722 722 I CecSS : Start key listening
07-18 17:00:42.635 722 722 I CecSS : [CecSourceService] onStartCommand: action=action_Interval
07-18 17:00:45.063 3370 3370 D AndroidRuntime:
07-18 17:00:45.063 3370 3370 D AndroidRuntime: >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
07-18 17:00:45.063 3370 3370 D AndroidRuntime: CheckJNI is OFF
07-18 17:00:45.171 3370 3370 D AndroidRuntime: Calling main entry com.android.commands.pm.Pm
07-18 17:00:45.207 1662 1668 D dalvikvm: GC_EXPLICIT freed 4K, 17% free 2669K/3203K, paused 1ms+0ms
@lukaszb
lukaszb / alaruby.py
Created November 20, 2011 20:39
Ruby-like string interpolation in Python
import sys
import unittest
import jinja2
# sys._getframe works on CPython and PyPy. Not tested elsewhere
rs = lambda text: text.format(**sys._getframe(1).f_locals)
def rj(text):
template = jinja2.Template(text)
@lukaszb
lukaszb / fetchtopdomains.py
Created September 28, 2011 19:43
Top domains fetcher
"""
This script fetches page from wikipedia, parses it, and outputs
top domain names in json format.
TODO: Need to add unicode versions of internationalized codes...
"""
import json
import urllib2
from lxml.html import fromstring
@lukaszb
lukaszb / gist:1007169
Created June 3, 2011 21:03
username & email extractor for VCS & RhodeCode
def author_email(author):
"""
returns email address of given author.
If any of <,> sign are found, it fallbacks to regex findall()
and returns first found result or empty string
Regex taken from http://www.regular-expressions.info/email.html
"""
import re
r = author.find('>')
@lukaszb
lukaszb / progressbar.py
Created May 19, 2011 09:03
Simple Python Progressbar
# encoding: UTF-8
import sys
import datetime
class ProgressBarError(Exception):
pass
class AlreadyFinishedError(ProgressBarError):
pass
[user]
name = <user.name>
email = <user.email>
[merge]
tool = vimdiff
[color]
ui = auto
[color "branch"]
current = yellow reverse
# Setup some colors to use later in interactive shell or scripts
export COLOR_NC='\e[0m' # No Color
export COLOR_WHITE='\e[1;37m'
export COLOR_BLACK='\e[0;30m'
export COLOR_BLUE='\e[0;34m'
export COLOR_LIGHT_BLUE='\e[1;34m'
export COLOR_GREEN='\e[0;32m'
export COLOR_LIGHT_GREEN='\e[1;32m'
export COLOR_CYAN='\e[0;36m'
export COLOR_LIGHT_CYAN='\e[1;36m'