Skip to content

Instantly share code, notes, and snippets.

View zemlanin's full-sized avatar
💭
wandering aimlessly

Anton Verinov zemlanin

💭
wandering aimlessly
View GitHub Profile
@zemlanin
zemlanin / euler14.py
Created December 15, 2014 11:44
euler14
# extra short
M=k=L=0
while k<1e6:
n=k=k+1;l=1
while n>1:n=[n/2,3*n+1][n%2];l+=1
if l>L:M,L=k,l
print M
# short and fast
r={1:1};k=L=M=0
@zemlanin
zemlanin / push.sh
Created August 14, 2014 16:14
push.sh
# send message to your devices via pushover.net API
# add next two or three lines to .bashrc/.zshrc to use this script
# export PUSHOVER_APP="your pushover.net app token"
# export PUSHOVER_USER="your pushover.net user key"
# # optional:
# export PUSHOVER_DEVICE="default device"
# USAGE: push <message> [-d=<device>]
# OPTIONS:
@zemlanin
zemlanin / yop.sh
Created August 14, 2014 16:08
yop.sh
# send yo to your devices via Yo API
# add next line to .bashrc/.zshrc to use this script
# export YO_APP="your justyo.co app token"
# USAGE: yop [link]
__yop(){
local link=$1
local api_url="http://api.justyo.co/yoall/"
@zemlanin
zemlanin / keybase.md
Created May 9, 2014 20:51
keybase.md

Keybase proof

I hereby claim:

  • I am zemlanin on github.
  • I am zem (https://keybase.io/zem) on keybase.
  • I have a public key whose fingerprint is 69AE 19AE 14E2 31E1 E727 CD27 B3A7 3ED8 9342 526F

To claim this, I am signing this object:

@zemlanin
zemlanin / regex.alf.nu_solution.md
Last active August 8, 2016 06:54
regex.alf.nu

Solutions for regex.alf.nu (easy mode)

  1. Warmup (207)

     foo
    
  2. Anchors (208)

     k$
    
  3. Ranges (202)

@zemlanin
zemlanin / euler59.py
Last active December 28, 2015 18:19
Project Euler 59
import itertools, string, operator, requests
cypher = map(int, requests.get('https://projecteuler.net/project/cipher1.txt').text.split(','))
for pwd in itertools.product(string.ascii_lowercase, repeat=3):
phrase = ''.join(itertools.imap(lambda x,y: chr(operator.xor(x, y)), cypher, itertools.cycle(map(ord, pwd))))
if 'the' in phrase.lower() and 'and' in phrase.lower() and ' ' in phrase:
print phrase, '\n|\n+->\t', ''.join(pwd), '\n'
@zemlanin
zemlanin / md5_prompt.sh
Created April 6, 2013 12:25
zsh's prompt background color
# Генерируем цвет фона prompt'а, основываясь на md5-сумме hostname (только первые 2 шестнадцатеричные цифры)
export TERM=xterm-256color
__colorcode=$(
(
echo "ibase=16"; hostname | md5sum | cut -c1-2 | tr "[:lower:]" "[:upper:]"
) | bc | awk '{printf "[48;5;%dm", $1}' # Перед "[" стоит ESC-символ, который не отображается в браузере
)
@zemlanin
zemlanin / p.sh
Last active December 15, 2015 20:59
python quick calculation in zsh
# add this file to your ~/.zshrc file and restart zsh
# or just run "curl https://gist.github.com/zemlanin/5322437/raw/p.sh >> ~/.zshrc; exec zsh"
#
# input:
# p 2+4 4.0/3 _0+_1
#
# and get output like:
# _0> 6
# _1> 1.3333333333333333
# _2> 7.333333333333333
@zemlanin
zemlanin / fonts.conf
Last active December 15, 2015 20:49 — forked from robotslave/gist:4633393
Emoji in Ubuntu
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<!--
1. Download the Symbola font:
http://users.teilar.gr/~g1951d/Symbola707.zip
2. unzip the file and put Symbola.ttf (and any of the other fonts that strike your fancy)
in your ~/.fonts/ directory
3. run `fc-cache -f`. You can check to make sure the new fonts
@zemlanin
zemlanin / .gitignore
Created December 13, 2012 14:14
.zshrc
.DS_Store