Skip to content

Instantly share code, notes, and snippets.

View ykarikos's full-sized avatar
🏡
Working from home

Yrjö Kari-Koskinen ykarikos

🏡
Working from home
  • Digitaalinen asuntokauppa DIAS
  • Helsinki
  • X @ykarikos
View GitHub Profile
@ykarikos
ykarikos / csvsum.py
Created December 24, 2011 16:38
Count together the CSV rows' last columns and use the first n rows as the key
#!/usr/bin/python
# Count together the CSV rows' last columns and use the first n rows as the key.
# Use cut to crop the key space, e.g.
# $ cut -d\; -f 3-4,8 | csvsum.py
import sys
sums = {}
@ykarikos
ykarikos / smtpToMaildir.pl
Created March 22, 2012 12:31
SMTP Listener that writes everything in a Maildir
#!/usr/bin/perl -w
#
# smtpToMaildir.pl (C) 2009 Yrjö Kari-Koskinen <ykk@peruna.fi>
#
# This program is licensed under Version 2 of the GPL.
# The perl package dependencies can be satisfied with the following
# Debian/Ubuntu packages: libmail-box-perl libnet-smtp-server-perl
use strict;
@ykarikos
ykarikos / gist:2405068
Created April 17, 2012 10:08
Git log analysis
# List amount of commits in git repository per month and author
git log --pretty='format:%ad %ae' --date=short | sed 's/@.*//'| cut -b -7,11- |sort |uniq -c |awk '{ printf "%s %30s ", $2, $3; count=int($1/2); for(i=0; i<count; i++) { printf "*" } printf "\n"; }'
# List amount of commits on different times of day
git log --pretty='format:%ad' --date=iso | cut -b 12-13|sort |uniq -c|awk '{ printf "%s %30s ", $2, $3; count=int($1/2); for(i=0; i<count; i++) { printf "*" } printf "\n"; }'
# Find inhumane commit times
git log --pretty='format:%ad %ae %s' --date=iso | egrep -v "^2012-[0-9-]* ([12]|0[7-9])"
@ykarikos
ykarikos / gist:2411905
Created April 18, 2012 08:00
Hide Trello board-widgets
javascript:(function(){$(".board-widgets").hide();$("#board").css("width","98%");})();
@ykarikos
ykarikos / transpose.py
Created May 28, 2012 07:32
Transpose utf-8 string columns as rows and vice versa
#!/usr/bin/python
#
# transpose.py (C) 2012 Yrjo Kari-Koskinen <ykk@peruna.fi>
#
# This program is licensed under Version 2 of the GPL.
#
# Transpose utf-8 string columns as rows and vice versa
# You might need to set PYTHONIOENCODING=utf_8 before calling transpose.py
import sys
@ykarikos
ykarikos / png2svg.sh
Created June 7, 2012 22:17
Convert png to svg using imagemagick and potrace
#!/bin/bash
if [ "$1" == "" ]; then
echo Usage: $0 pngfile
exit 0;
fi
FILE=`basename $1 .png`
if [ ! -e $FILE.png ]; then
@ykarikos
ykarikos / gist:3511914
Created August 29, 2012 12:41
Imperative Java Shit
private String getCustomerKeys(List<Customer> customers) {
StringBuilder keys = new StringBuilder();
if (customers != null) {
for (Customer customer: customers) {
if (keys.length() > 0) {
keys.append(", ");
}
keys.append(customer.customerKey.toString());
}
return keys.toString();
@ykarikos
ykarikos / label.bst
Created September 12, 2012 12:51
BibTeX bibliography style `label'
% BibTeX bibliography style `label'
% Modified from the `alpha' style
% Changes:
% * New entry labelkey added. If it is present, it will be used as the
% label. Otherwise the alpha style label is used.
% * The first line of the bibliography will contain only the label.
% * The command \textsc will be removed from the beginning of the labelkey
% for sorting (see the sortifysc function).
% * New entries url and ref added. If url is nonempty it will be typeset
@ykarikos
ykarikos / charFrequency.py
Last active December 10, 2015 16:58
Count character frequencies
#!/usr/bin/python
# charFrequency.py (C) 2013 Yrjo Kari-Koskinen <ykk@peruna.fi>
#
# This program is licensed under Version 2 of the GPL.
#
# Use PYTHONIOENCODING=utf_8 environment variable to read and write utf8 to files.
import sys, unicodedata
def letter(l):
@ykarikos
ykarikos / random-letters.py
Last active December 14, 2015 01:38
Select random letters according to the distribution of letters in Finnish language
#!/usr/bin/python
# Select random letters according to the distribution of letters in Finnish language:
# https://docs.google.com/spreadsheet/ccc?key=0AiZHeDrg3BuddFZfTXVnclQ5UWNkaGVuWmdVT3dzMEE&usp=sharing
# Ignore the uncommon letters c, z, w, q, x and ao
import random
from itertools import repeat
from collections import Counter