Skip to content

Instantly share code, notes, and snippets.

View aluminiumgeek's full-sized avatar
🚷
🚳

Mikhail Mezyakov aluminiumgeek

🚷
🚳
View GitHub Profile
@aluminiumgeek
aluminiumgeek / gist:6771463
Created September 30, 2013 22:51
My urxvt settings (~/.Xdefaults)
URxvt.perl-ext-common: default,matcher
URxvt.colorUL: #86a2be
URxvt.urlLauncher: firefox
URxvt.font: xft:DejaVu Sans Mono:pixelsize=11
URxvt*foreground: #f2f2f2
URxvt*background: #101010
URxvt.scrollBar:false
! Normal
@aluminiumgeek
aluminiumgeek / gist:6833322
Created October 4, 2013 21:46
My ~/.mplayer/config
ass=1
ssa=1
subcp=utf-8
subfont-text-scale=1.6
vo=xv:port=87
subfont-text-scale=3
@aluminiumgeek
aluminiumgeek / updates_handler.py
Last active January 4, 2016 02:39
Tornado Websocket example for blog
class UpdatesHandler(websocket.WebSocketHandler):
socket_clients = set()
def open(self):
self.socket_clients.add(self)
def on_close(self):
self.socket_clients.remove(self)
@aluminiumgeek
aluminiumgeek / nginx.conf
Last active September 20, 2020 12:01
Nginx forward real client ip
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://upstream_name;
}
@aluminiumgeek
aluminiumgeek / utils.py
Last active January 4, 2016 07:59
Tornado Client IP detection for production and development environments
def get_ip(request):
"""
Возвращает ip из HTTP-заголовков. Если там его нет, возвращает значение
атрибута remote_ip
@param request: экземпляр HTTPRequest
@return: строка, содержащая ip клиента
"""
if 'X-Real-Ip' in request.headers:
@aluminiumgeek
aluminiumgeek / 125.py
Created September 8, 2014 15:37
1, 2, 5 formatter
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Форматирование словоформы "1, 2, 5" (посетитель/посетителя/посетителей)
import random
def choose_word_form(number, form1, form2, default):
mod10 = abs(number) % 10
@aluminiumgeek
aluminiumgeek / cinderella.txt
Last active August 29, 2015 14:14
Word counter
Cinderella
The wife of a rich man fell sick, and as she felt that her end
was drawing near, she called her only daughter to her bedside and
said, dear child, be good and pious, and then the
good God will always protect you, and I will look down on you
from heaven and be near you. Thereupon she closed her eyes and
departed. Every day the maiden went out to her mother's grave,
and wept, and she remained pious and good. When winter came
the snow spread a white sheet over the grave, and by the time the
spring sun had drawn it off again, the man had taken another wife.
@aluminiumgeek
aluminiumgeek / Vagrantfile
Last active June 1, 2017 11:43
Key auth for Vagrant VMs
require_relative '../vagrant/key_authorization'
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/trusty64'
authorize_key_for_root config, '/home/mihail/.ssh/id_dsa.pub', '/home/mihail/.ssh/id_rsa.pub'
{
'db' => '192.168.33.10',
'elasticsearch'=> '192.168.33.11',
'app' => '192.168.33.12'
}.each do |short_name, ip|
@aluminiumgeek
aluminiumgeek / utils.py
Last active February 16, 2016 18:14
Calculate distance between two coordinates (latitude/longitude) in meters
def coords_distance(coords_from, coords_to):
lat1, long1 = coords_from
lat2, long2 = coords_to
degrees_to_radians = math.pi / 180.0
phi1 = (90.0 - lat1) * degrees_to_radians
phi2 = (90.0 - lat2) * degrees_to_radians
theta1 = long1 * degrees_to_radians
@aluminiumgeek
aluminiumgeek / .screenrc
Last active July 22, 2022 08:57 — forked from joaopizani/.screenrc
My .screenrc with comfortable layout and shortcuts
# the following two lines give a two-line status, with the current window highlighted
hardstatus alwayslastline
hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}][%{B}%m/%d %{W}%C%A%{g}]'
# huge scrollback buffer
defscrollback 5000
# no welcome message
startup_message off