Skip to content

Instantly share code, notes, and snippets.

Dan Mirsky mirskiy

Block or report user

Report or block mirskiy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mirskiy
mirskiy / jdiff.sh
Created Apr 2, 2017
Diff json with vimdiff
View jdiff.sh
# Add this to your .bashrc or .bash_aliases
jdiff() {
# Diff json files faster
# Uses python json.dump with sort_keys=True to fix ordering, then vimdiff
if [[ $# -ne 2 ]]; then
echo "syntax: jdiff file1 file2"
return
fi
@mirskiy
mirskiy / django.py
Created Sep 28, 2016
django tricks
View django.py
# model new insance or update
# http://stackoverflow.com/a/35647389
self._state.adding == True creating
self._state.adding == False updating
@mirskiy
mirskiy / RelatedFieldListFilter.txt
Last active Aug 30, 2016
RelatedFieldListFilter vs RelatedOnlyFieldListFilter
View RelatedFieldListFilter.txt
from the source:
class RelatedOnlyFieldListFilter(RelatedFieldListFilter):
def field_choices(self, field, request, model_admin):
pk_qs = model_admin.get_queryset(request).distinct().values_list('%s__pk' % self.field_path, flat=True)
return field.get_choices(include_blank=False, limit_choices_to={'pk__in': pk_qs})
ex if:
class Author(models.Model):
country = models.ForeignKey('Country')
@mirskiy
mirskiy / tmux_install.sh
Last active Dec 26, 2018
Install tmux 2.2 on Ubuntu 14.04 from source
View tmux_install.sh
sudo apt-get update
sudo apt-get install -y libevent-dev libncurses-dev make
wget https://github.com/tmux/tmux/releases/download/2.2/tmux-2.2.tar.gz
tar xvzf tmux-2.2.tar.gz
cd tmux-2.2/
./configure && make
sudo make install
View tmux
# detach others
<prefix> D
# resize
<prefix> :resize[-pane] -(U|D|R|L) [numCells]
View system.sh
1996 sudo hciconfig hci0 up
1997 sudo hidd --connect 00:22:48:86:E6:CA
@mirskiy
mirskiy / cmd.sh
Last active Nov 17, 2016
commanding lines
View cmd.sh
## history
# Quick substitution. Repeat the last command, replacing string1 with string2. Equivalent to ``!!:s/string1/string2/'' (see Modifiers below).
^string1^string2^
# Swap usage
vmstat
# display in hex
echo 'test' | hd
You can’t perform that action at this time.