Skip to content

Instantly share code, notes, and snippets.

View bak1an's full-sized avatar
🇺🇦

Anton Baklanov bak1an

🇺🇦
View GitHub Profile
@bak1an
bak1an / log_db_queries.py
Created December 8, 2011 14:05
django decorator for logging db queries
# simple decorator for logging out django db queries
# just put it along with other decorators before view or
# db-loading stuff. than go to your console and see whats going on.
# example:
#
# @log_db_queries
# @login_required
# def your_view(request, args...):
# your stuff
def log_db_queries(f):
@bak1an
bak1an / watch_for_size_change.sh
Created December 15, 2011 10:32
bash function to watch if file size was changed for some period
#!/bin/bash
# function takes 2 arguments
# $1 - file to watch for changes
# $2 - how long to watch in seconds
# it echoes "0" if file size was not changed during watching
# and "1" if file does not exist or file size was changed
# example:
@bak1an
bak1an / biggest_backages.py
Created January 21, 2012 23:30
script to show biggest packages at your rpm-based system
#!/usr/bin/python
# script to show biggest packages at your rpm-based system
# just run it like 'python biggest_packages.py | less'
import subprocess
packages = {}
process = subprocess.Popen(r"rpm -qa --queryformat '%{size}|%{name}-%{version}-%{release}\n'",
@bak1an
bak1an / ls_path.sh
Created January 26, 2012 16:55
do ls for every directory in given path
#!/bin/bash
# Example of usage && output:
# $ls_path.sh /home/bak1an/Music
# drwxr-xr-x 6 root root 4.0K May 30 2011 /home
# drwxr-xr-x 226 bak1an bak1an 24K Jan 26 16:08 /home/bak1an
# drwxr-xr-x 112 bak1an bak1an 12K Nov 7 17:51 /home/bak1an/Music
path="$1";
while [[ $path ]]; do
@bak1an
bak1an / set_cookies.js
Created April 20, 2012 10:34
bookmarklet that allows quickly set cookies from http headers
javascript:if (document.location=="about:blank" || document.location=="chrome://newtab/") alert("go to target site first"); else { (function (a){var cs=a.split(';');for (var c in cs){ if (cs[c]!='') document.cookie = cs[c]+"; path=/; domain=."+document.location.host.replace(/www\./i,'')+";";}})(prompt("----------------- cookies string ---------------","name=value; name2=value2;")); }
@bak1an
bak1an / gist:3169858
Created July 24, 2012 13:14
PS1 with git status
# put git-completion.bash and git-prompt.sh from contrib/completion to SOMEDIR
for f in $SOMEDIR/*; do source $f; done
GIT_PS1_SHOWDIRTYSTATE=true
export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[31m\]$(__git_ps1)\[\033[00m\]\[\033[01;34m\] \$\[\033[00m\] '
@bak1an
bak1an / maybe.py
Created August 30, 2012 21:44
lol, kind of Maybe in python
# found here http://stackoverflow.com/a/8507440
class Maybe():
def andThen(self, action): # equivalent to Haskell's >>=
if self.__class__ == _Maybe__Nothing:
return Nothing
elif self.__class__ == Just:
return action(self.value)
def followedBy(self, action): # equivalent to Haskell's >>
@bak1an
bak1an / .gitconfig
Last active July 28, 2022 03:28
~/.gitconfig
[user]
name = Anton Baklanov
email = antonbaklanov@gmail.com
[core]
editor = vim
[merge]
tool = kdiff3
[color]
ui = true
status = auto
@bak1an
bak1an / terminalrc
Created November 30, 2012 12:51
xfce terminal tango color scheme
# put it to ~/.config/Terminal/terminalrc
# found here http://blogs.n1zyy.com/andrew/2009/02/02/tango-color-scheme-for-xfce-terminal/
[Configuration]
ColorForeground=White
ColorBackground=#323232323232
ColorPalette1=#2e2e34343636
ColorPalette2=#cccc00000000
ColorPalette3=#4e4e9a9a0606
ColorPalette4=#c4c4a0a00000
#!/usr/bin/env ruby
# encoding: utf-8
#
# This file, gist, is generated code.
# Please DO NOT EDIT or send patches for it.
#
# Please take a look at the source from
# http://github.com/defunkt/gist
# and submit patches against the individual files
# that build gist.