Skip to content

Instantly share code, notes, and snippets.

@mindw
mindw / docker.sh
Last active March 10, 2017 12:25
Docker shortcuts
# clenup all exited containers
docker rm -v $(docker ps -a -q -f status=exited)
$(docker ps -a -q -f status=exited) | xargs -r docker rm -v
# remove dangling images
docker rmi $(docker images -f "dangling=true" -q)
$(docker images -f "dangling=true" -q) | xargs -r docker rmi -v
# remove dangling volumes
docker volume rm $(docker volume ls -qf dangling=true)
@mindw
mindw / list_fix.tex
Last active October 24, 2016 06:55
Fix LaTeX nested too deep error.
% source:
% http://jasonjuang.blogspot.co.il/2016/06/how-to-solve-too-deeply-nested-error.html
% http://www.texnia.com/archive/enumitem.pdf
% http://texdoc.net/texmf-dist/doc/latex/latex2e-help-texinfo/latex2e.pdf
\usepackage{enumitem}
\setlistdepth{20}
\renewlist{itemize}{itemize}{20}
% initially, use dots for all levels
@mindw
mindw / pr.md
Created October 20, 2016 07:05 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

python -c "from random import choice; print ''.join([choice('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%^*(-_=+)') for i in range(32)])"
@mindw
mindw / devops.sh
Last active April 3, 2016 12:46
Installing devops stuff on ubuntu 14.04 trusty
# virtual box
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian trusty contrib" >> /etc/apt/sources.list.d/virtualbox.list'
sudo apt-get update
sudo apt-get install -y dkms virtualbox-5.0
# docker
sudo curl -sSL https://get.docker.com/ | sh
sudo usermod -aG docker vagrant
@mindw
mindw / .bashrc
Last active June 8, 2016 12:33
Ubuntu tweaks
#export GIT_PS1_SHOWDIRTYSTATE=true
#export GIT_PS1_SHOWUNTRACKEDFILES=true
unset GIT_PS1_SHOWDIRTYSTATE
unset GIT_PS1_SHOWUNTRACKEDFILES
# non-printable characters must be enclosed inside \[ and \]
PS1='\[\033[0m\]' # VT100 compat: reset all colors
PS1="$PS1"'\[\033[32m\]' # change color
PS1="$PS1"'\u@\h ' # user@host<space>
PS1="$PS1"'\[\033[33m\]' # change color
@mindw
mindw / prompt.cmd
Created August 25, 2015 11:37
Win Terminals Prompts
REM conemu prompt
$E[32m$E]9;8;"USERNAME"$E\@$E]9;8;"COMPUTERNAME"$E\$S$E[92m$P$E[90m$_$E[90m$$$E[m$S
REM clink prompt
set prompt=$E[32m[%computername%] $d$s$t$_$E[33m$p$_$E[37m$+$g
@mindw
mindw / escape_str.cpp
Created May 20, 2014 07:24
Escape a string for use in any FS using C++11
#include <assert.h>
#include <string>
#include <time.h>
#include <stdlib.h>
#include <vector>
std::string UriDecode(const std::string & src)
{
@mindw
mindw / conf.py
Created May 16, 2014 07:01
Suppressing Duplicate "module index" entry when using Sphinx with numpydoc
html_domain_indices = ['py-modindex']
@mindw
mindw / redirect_out.py
Created February 25, 2014 07:55
redirecting std out/err into files
import logging
logging.basicConfig(filename='example.log',filemode="w", level=logging.DEBUG)
import sys
class StreamToLogger(object):
"""
Fake file-like stream object that redirects writes to a logger instance.
"""
def __init__(self, logger, log_level=logging.INFO):
self.logger = logger