Skip to content

Instantly share code, notes, and snippets.

View haard's full-sized avatar

Fredrik Håård haard

View GitHub Profile
from argparse import ArgumentParser
from configparser import ConfigParser
import pprint
def main():
# Read file config
fparser = ConfigParser()
fparser.read('config.conf')
config = {'some.key': 'some_value'} # Hard-coded default
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@haard
haard / gist:8639666
Created January 26, 2014 21:23
Use hggit and hgapi to push a hg repo to a git mirror
branch_mapping = [('default', 'master')]
target = "git+ssh://git@github.com/haard/test"
repo = hgapi.Repo(path)
for hgb, gb in branch_mapping:
repo.hg_command('bookmark', '-r', hgb, gb)
repo.hg_command("--config", "paths.default=" + target, "--config", "extensions.hggit=", "push")
@haard
haard / battery.py
Last active November 27, 2016 22:48
Batteries included: Download, unzip and parse in 13 lines - http://blaag.haard.se/Batteries-included--Download--unzip-and-parse-in-13-lines/
import zipfile, urllib, csv, os, codecs
def get_items(url):
filename, headers = urllib.urlretrieve(url)
try:
with zipfile.ZipFile(filename) as zf:
csvfiles = [name for name in zf.namelist()
if name.endswith('.csv')]
for item in csvfiles:
with zf.open(item) as source: