Skip to content

Instantly share code, notes, and snippets.

View reflechant's full-sized avatar

Roman Gerasimov reflechant

  • Amsterdam
View GitHub Profile
@reflechant
reflechant / dict-client.py
Last active February 2, 2017 08:35
A simple command-line client for Yandex.Translate service
#!/usr/bin/env python3
# A simple command-line client for Yandex.Translate.
# You may pass translate direction as command line parameter e.g. "./dict-client.py fr-en"
# Default translate direction is from English to Russian.
#!/usr/bin/env python3
import requests
import sys
@reflechant
reflechant / binary-clock-patterns.py
Last active January 13, 2016 20:33
This program draws patterns to remember if you have bought a binary watch (for example from 01theone.com)
#!/usr/bin/env python
from Tkinter import *
master = Tk()
w = Canvas(master, width=150, height=930)
#for n in range(1,61):
n = 1
for x in ( 3,6,12,24,48,7,14,28,56,15,30,60,5,10,20,40,21,42 ):
i = 0
@reflechant
reflechant / pswd-gen.lua
Created January 13, 2016 20:31
Command-line strong password generator (the only parameter is password length, default is 8)
math.randomseed(os.time())
length = arg[1] or 8
for i = 1, length do
io.stdout:write( string.char(math.random(33,126)) )
end
print()
io.read()
#!/usr/bin/env python3
import requests
import sys
import datetime as dt
SECRET_KEY = "get it yourself @ yandex"
p = { "Одинцово" : "s9600721",
"Голицыно": "s9602265",
@reflechant
reflechant / freq.py
Last active January 24, 2016 19:49
Generate 440Hz (note A) wave file on Windows with Python
import mmap
import winsound as ws
import struct as st
from math import sin, cos, radians
from random import randint
# in RIFF format (and therefore in WAVE) ALL NUMBERS ARE LITTLE ENDIAN
FILE_SIZE = 44100*10+44 # bytes
@reflechant
reflechant / crc32.py
Last active August 10, 2016 07:15
Get CRC32 checksum of a file
#!/usr/bin/env python
import sys
import zlib
def main():
with open(sys.argv[1], 'rb') as f:
data = f.read()
print(hex(zlib.crc32(data)))
@reflechant
reflechant / rasp.py
Last active August 10, 2016 07:35
Консольный клиент для сервиса Яндекс.Расписания
#!/usr/bin/env python3
import requests
import sys
import datetime as dt
SECRET_KEY = """ Ключ можно получить здесь: https://tech.yandex.ru/rasp/raspapi/ """
p = {"Белорусский вокзал": "s2000006",
"Шереметьево": "s9600213"
set nocompatible
autocmd FileType python set expandtab
syntax on
" set number
set tabstop=4
set autoindent
set shiftwidth=4
" set cursorline
set showmatch
@reflechant
reflechant / ethernet_raw.c
Last active June 27, 2017 10:59
Receiver MAC level packets from network
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <errno.h>
#include <string.h>
#include <inttypes.h>
#include <linux/if_packet.h>
#include <linux/if_ether.h>
// #include <netpacket/packet.h>
@reflechant
reflechant / parallel_benchmark.go
Last active August 29, 2017 21:17
unfinished benchmark of parallel calculation in Go (trying to rewrite https://habrahabr.ru/post/336684/)
package main
import (
"math"
"time"
"fmt"
)
type Point struct {
x float64