Skip to content

Instantly share code, notes, and snippets.

View kstep's full-sized avatar
🗺️

Konstantin Stepanov kstep

🗺️
View GitHub Profile
#!/usr/bin/python
# encoding: utf-8
import sys, os, itertools as it
try:
root = sys.argv[1]
except IndexError:
root = os.getcwd()
@kstep
kstep / gist:982872
Created May 20, 2011 13:20
List torrent file
perl -ne 'while (/(?:name|pathl)(\d+):/gc) { $n = $1; /(.{$n})/gc; print "$1\n"; }'
@kstep
kstep / imgur.py
Last active August 10, 2024 22:25
#!/usr/bin/python
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib2
import simplejson
import sys
try:
input_file = open(sys.argv[1], 'rb')
@kstep
kstep / gist:1615974
Created January 15, 2012 14:15
Me and My Shadow pkgbuild for ArchLinux
# Maintainer: Konstantin Stepanov <[email protected]>
pkgname=meandmyshadow
pkgdesc='Puzzle/platform game written by Luka Horvat.'
url='http://meandmyshadow.sourceforge.net/index.html'
pkgrel=1
pkgver=0.2
arch=('i686' 'x86_64')
provides=('meandmyshadow')
source=("$pkgname-$pkgver-src.tar.gz::https://sourceforge.net/projects/$pkgname/files/0.2/$pkgname-$pkgver-src.tar.gz/download")
@kstep
kstep / Pearlwall.pm
Created January 15, 2012 14:45
Perl-based language to describe iptables rules
use strict;
package Pearlwall;
use base 'Exporter';
our @EXPORT = qw(iface port net mode oneof from to filter mangle nat raw flush with by user group marked list forwarding chain record on off);
my $_table = '';
my $_dry_run = 0;
BEGIN {
@kstep
kstep / xrandrconf.sh
Created March 9, 2012 18:44
autoconfigure displays layout with xrandr
#!/bin/sh
case "$1" in
left-of|right-of|above|below|same-as) D=$1 ;;
*) D=left-of ;;
esac
xrandr | awk -v dir=$D 'out { gsub("[^0-9.]", "", $2); print "--output " out " --mode " $1 " --rate " $2 pout; pout=" --" dir " " out; out=0 } / connected/ { out=$1 }' | xargs xrandr
@kstep
kstep / html.py
Created August 15, 2012 13:12
Simple Python HTML template DSL
__all__ = []
def export(value):
__all__.append(value.__name__)
return value
import sys
module = sys.modules[__name__]
class Context(object):
@kstep
kstep / ptml.py
Created August 29, 2012 18:03
Simple Python HTML template DSL (improved Python 3 version)
#
# Python Template Markup Language
# Simple Python DSL for HTML and (a little) CSS templating.
#
# Example:
#
# from ptml import *
#
# with html5 as out:
# with head:
@kstep
kstep / gist:8599679
Created January 24, 2014 15:39
Simple player with "mplayer" and current song notifications.
mplayer -vo null -playlist playlist.m3u -loop 0 -shuffle | awk -F ': ' '/^ title: / { title=$2; gsub(/'\''/, "&\\\\&&", title) } /^ artist: / { artist=$2; gsub(/'\''/, "&\\\\&&", artist) } /^Starting playback/ { system("notify-send -i /usr/share/icons/oxygen/22x22/actions/media-playback-start.png Playing '\''" artist " — " title "'\''") }'
ACTION=="add", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem", DRIVERS=="usb-storage", GOTO="automount_go"
ACTION=="remove", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem", DRIVERS=="usb-storage", RUN{program}+="/bin/rmdir /media/%E{AUTOMOUNT_NAME}"
GOTO="automount_end"
LABEL="automount_go"
PROGRAM="/usr/local/bin/automount-helper.py $number", GROUP="disk", TAG+="systemd", ENV{AUTOMOUNT_NAME}="$result{1}", ENV{SYSTEMD_WANTS}="usb-mount@$result{2}.service"
LABEL="automount_end"