Skip to content

Instantly share code, notes, and snippets.

View onjin's full-sized avatar

Marek Wywiał onjin

View GitHub Profile
import os
import re
import subprocess
from time import sleep
from threading import Thread
import logging
from logging.handlers import RotatingFileHandler
from libqtile.config import Key, Screen, Group, Drag, Click, Match
from libqtile.command import lazy
@onjin
onjin / settitle
Created February 19, 2015 08:52
set shell title
#!/bin/bash
echo -ne "\033]0;${1}\007"
#!/usr/bin/env python
"""
# nagios configuration
define contact {
contact_name slack
alias Slack
service_notification_period 24x7
host_notification_period 24x7
#!/usr/bin/env python
# encoding: utf-8
"""
$ ./export_confulence_space.py -l http://wiki.some.com -u username -p password -s SPACEKEY
$ ./export_confulence_space.py -l http://wiki.some.com -u username -p password -a # all spaces available for given user
"""
import os
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
@onjin
onjin / gist:1231714
Created September 21, 2011 09:58
.vimrc commons
" where i'm
set number
set cursorline
set nocursorcolumn
" work with .vimrc
map ,v :sp ~/.vimrc<cr> " edit my .vimrc file in a split
map ,e :e ~/.vimrc<cr> " edit my .vimrc file
map ,u :source ~/.vimrc<cr> " update the system settings from my vimrc file
@onjin
onjin / gist:1234533
Created September 22, 2011 10:54
mini gallery
mkdir -p mini; for img in `ls *.jpg`; do convert -fill white -geometry 100x200 -size 100x200 -scale 100x200 $img mini/$img; echo "<a style='display: block; width: 100px; height: 200px; float: left; margin: 10px; border: solid 1pX #ccc' href='$img' onclick='window.open(this.href); return false'><img src='mini/$img' /></a>"; done > gallery.html
google-chrome gallery.html
@onjin
onjin / average_ttfb_ttlb.py
Created October 30, 2012 12:47
Get average TTFB, TTLB for website
import numpy
import urllib2
import time
import sys
if len(sys.argv) < 2:
sys.stout.write( "Usage: %s http://page/ counter\n" % sys.argv[0])
sys.exit(0)
site = sys.argv[1]
@onjin
onjin / auto_notify.sql
Last active December 14, 2015 11:14
pubsub using postgres listen/notify
CREATE OR REPLACE FUNCTION object_notify() RETURNS trigger AS $$
DECLARE
BEGIN
PERFORM pg_notify('object_updated',CAST(NEW.id AS text));
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER object_post_insert_notify AFTER UPDATE ON objects FOR EACH ROW EXECUTE PROCEDURE object_notify();
@onjin
onjin / randomrun.py
Last active December 15, 2015 22:59
Find files recursively using given file extensions and run given command on random 'n' files
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Find files recursively using given file extensions and run given command on random 'n' files:
* python randomrun.py -e mkv,avi,ogm -r vlc -c 4 /some/dir/ # run 4 random moves using vlc
* python randomrun.py -e txt,dat -r cat -c 3 -p /some/dir/ # run cat on 3 random files parallelly
"""
import argparse