Skip to content

Instantly share code, notes, and snippets.

@iley
iley / switchout.sh
Created March 25, 2012 08:18
Change output device in pulseaudio
#!/usr/bin/env bash
sinks=($(pacmd list-sinks | grep index | \
awk '{ if ($1 == "*") print "1",$3; else print "0",$2 }'))
inputs=($(pacmd list-sink-inputs | grep index | awk '{print $2}'))
[[ ${sinks[0]} = 0 ]] && swap=${sinks[1]} || swap=${sinks[3]}
pacmd set-default-sink $swap &> /dev/null
for i in ${inputs[*]}; do pacmd move-sink-input $i $swap &> /dev/null; done
from random import random, seed
from contextlib import nested
seed(31337)
k = 0.5
with nested(open('in.txt'), open('out1.txt', 'w'), open('out2.txt', 'w')) as \
(inp, out1, out2):
for line in inp.readlines():
if random() > k:
class Yoba(object):
def __init__(self, name):
self.name = name
y = Yoba('YOBA')
def hello(self):
print "PRIVET ETO %s" % self.name
Yoba.hello = hello
@iley
iley / PKGBUILD
Created October 5, 2012 15:37
kbdd 0.6.2 pkgbuild
pkgname=kbdd
pkgver=0.6.2
pkgrel=1
pkgdesc="Simple daemon and library to make per window layout."
arch=('i686' 'x86_64')
url="https://github.com/qnikst/kbdd"
license=('GPL3')
depends=()
source=("https://github.com/downloads/qnikst/$pkgname/$pkgname-$pkgver.tar.bz2")
md5sums=('961d7d8f78674b4d6ce250fb4732bf0f')
@iley
iley / gist:4006261
Created November 3, 2012 06:16
twmn debian control file
Package: twmn
Version: 2012.08.25
Architecture: amd64
Maintainer: Ilya Strukov <[email protected]>
Depends: libboost-program-options1.49.0, libboost-system1.49.0, libdbus-1-3, libqtcore4, libqtgui4, libqt4-network
Priority: optional
Description: A notification system for tiling window managers.
@iley
iley / ffi_hello.c
Created November 15, 2012 06:58
libffi hello world
#include <stdio.h>
#include <ffi.h>
#include <assert.h>
int main() {
ffi_cif cif;
int rc;
const char *fmt = "string=%s, integer=%d\n";
const char *str = "hello";
@iley
iley / tmux-link.pl
Created November 22, 2012 06:15
Script to link tmux windows between sessions
SRC=XCompose bashrc gitconfig i3 i3status.conf inputrc mplayer oh-my-zsh \
perldb perltidyrc racketrc sbclrc screen screenrc ssh/config taskrc tmux.conf \
xinitrc zshrc psqlrc pentadactylrc Xdefaults Xmodmap zsh fonts.conf config/redshift.conf
DST=$(addprefix $(HOME)/.,$(SRC))
TWMN_DIR=$(HOME)/.config/twmn
SSH_CONN_DIR=$(HOME)/.ssh/connections
.PHONY: all links rvm submodule ssh_conn
all: links submodule vim
@iley
iley / send_books.pl
Last active December 10, 2015 19:38
Script to send books from a directory to kindle e-mail
#!/usr/bin/env perl
use Cwd 'abs_path';
use File::Basename;
use strict;
use warnings;
my $to = '[email protected]';
my $path = abs_path($0);
my $mutt_cfg = dirname($path) . "/robot.muttrc";
# vim:filetype=i3conf
set $mod Mod4
set $mybin /home/iley/bin
set $wallpaper /home/iley/wallpaper.jpg
force_xinerama yes
# font for window titles. ISO 10646 = Unicode
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1