Skip to content

Instantly share code, notes, and snippets.

View satyrius's full-sized avatar

Anton Egorov satyrius

  • Tallinn, Estonia
View GitHub Profile
@satyrius
satyrius / docker_clean.sh
Last active August 29, 2015 14:04
Drop stopped Docker containers and and untagged images
#!/bin/bash -e
docker ps -a -q | xargs docker rm
docker images | grep '^<none>' | awk '{print $3}' | xargs docker rmi
@satyrius
satyrius / export.sh
Created April 21, 2015 16:06
Export initial process environment
for v in $(xargs --null --max-args=1 < /proc/1/environ); do export $v; done
@satyrius
satyrius / install.sh
Last active September 29, 2015 17:08 — forked from asenchi/notes.md
Homebrew formula for VIM with python interpreter support
brew install python --framework
mkdir ~/Library/Frameworks/
cd ~/Library/Frameworks/
ln -s /usr/local/Cellar/python/2.7.5/Frameworks/Python.framework .
brew install -v https://gist.github.com/satyrius/1635076/raw/vim.rb
@satyrius
satyrius / install.sh
Created February 28, 2012 08:36
Dotfiles installation
cd $HOME
git clone git@github.com:satyrius/dotfiles.git .dotfiles
cd .dotfiles
for f in $(ls); do df="../.$f"; rm $df; ln -s "$(pwd)/$f" $df; done;
cd $HOME
rm .README.dm
@satyrius
satyrius / exercise-24.go
Last active December 26, 2015 07:09
A Tour of Go. Exercise: Loops and Functions. As a simple way to play with functions and loops, implement the square root function using Newton's method. In this case, Newton's method is to approximate Sqrt(x) by picking a starting point z and then repeating: To begin with, just repeat that calculation 10 times and see how close you get to the an…
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := 1.0
for i := 1; i <= 10; i++ {
@satyrius
satyrius / exercise-48.go
Created October 23, 2013 06:29
A Tour of Go. Advanced Exercise: Complex cube roots. Let's explore Go's built-in support for complex numbers via the complex64 and complex128 types. For cube roots, Newton's method amounts to repeating: Find the cube root of 2, just to make sure the algorithm works. There is a Pow function in the math/cmplx package.
package main
import (
"fmt"
"math"
"math/cmplx"
)
func Cbrt(x complex128) complex128 {
z := complex128(1)
@satyrius
satyrius / .tmux.conf
Last active June 20, 2016 09:39
My Tmux configuration
set-window-option -g mode-keys vi
set-option -g status-keys vi
# Start windows and panes at 1, not 0
set -g base-index 1
setw -g pane-base-index 1
# title
set -g set-titles on
set -g set-titles-string "#T"
@satyrius
satyrius / Dockerfile
Created March 28, 2016 16:41
Python 2.7 minimal Docker image (with psycopg2, nginx and supervisor)
FROM debian:jessie
ENV PYENV_ROOT=/opt/pyenv PATH=/opt/pyenv/shims:/opt/pyenv/bin:$PATH LANG=en_US.UTF-8
RUN set -x \
&& echo "LANG=$LANG" > /etc/default/locale \
&& echo "$LANG UTF-8" > /etc/locale.gen \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get update -qq \
&& apt-get install -y locales \
&& apt-get install -y \
libpq5 \
0x65BAC2D81034ac52523fB88EfB62C2a888A756c4
@satyrius
satyrius / exercise-44.go
Created October 23, 2013 06:25
A Tour of Go. Exercise: Fibonacci closure. Let's have some fun with functions. Implement a fibonacci function that returns a function (a closure) that returns successive fibonacci numbers.
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
var a, b int
return func() int {
a, b = b, a + b