Skip to content

Instantly share code, notes, and snippets.

:%! xmllint --format -
@jvorcak
jvorcak / autoreload-ipython.py
Created March 7, 2016 08:37
ipython autoreload
%load_ext autoreload
%autoreload 2
console.log('%c WARN %c This is just wrong! ', 'background: #B99508; color: white', 'background: #FFF8DC');
@jvorcak
jvorcak / inject-angular-service.js
Created September 25, 2015 11:26
Inject angular service from a console
var service = angular.element(document.body).injector().get('someService')
@jvorcak
jvorcak / gist:0dfff10a2f95e1bf2a0f
Created September 18, 2015 07:56
Mysql: update a value with incrementing number
mysql> select @i := 0;
mysql> update bar set c = (select @i := @i + 1);
@jvorcak
jvorcak / gist:7f6acdd090990608afd6
Created July 17, 2015 14:05
Get all tables names in a Django project
from django.db import connection
tables = connection.introspection.table_names()
seen_models = connection.introspection.installed_models(tables)
[model._meta.db_table for model in seen_models]
@jvorcak
jvorcak / gist:108314398eae466f384d
Created September 4, 2014 14:24
Automatically set attributes in a class
class User(object):
def __init__(self, **kwargs):
self.name = None
self.__dict__.update(kwargs)
u = User(name="Jan")
ffmpeg -f x11grab -r 30 -s 1280x800 -i :46991 -b 30k -qscale 1 -s 1280x800 -r 15 -ar 44100 -f flv capture.flv
@jvorcak
jvorcak / gist:6060613
Created July 23, 2013 07:56
How to change author of old commits
git filter-branch --commit-filter 'if [ "$GIT_AUTHOR_NAME" = "Jan Vorcak" ];
then export GIT_AUTHOR_NAME="Jan Vorcak"; export GIT_AUTHOR_EMAIL=jan@example.com;
fi; git commit-tree "$@"'
@jvorcak
jvorcak / gist:6060153
Created July 23, 2013 05:54
Colorcolumn in Vim
:hi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
:set cursorcolumn