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 / loadmodel.py
Created October 31, 2012 07:31
Моделирование нагрузки
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Лабораторная работа №2 по курсу "Компьютерное моделирование"
# тема "Моделирование загрузки компьютерной системы"
# выполнил ст.3 к. ФIОТ, гр. IO-03 Веринов Антон
# Вариант: 3 задачи, 1 ядро; ГП, ВП, ISA, COM
from random import gauss, random
from operator import attrgetter, ne
@zemlanin
zemlanin / main.cpp
Created October 31, 2012 07:33
Win32 Multithreading
#include <windows.h>
#include <iostream>
#include <string>
#include <vector>
#include "mathskills.h"
using namespace std;
using namespace mathskills;
DWORD WINAPI ThreadOne(LPVOID lpParameter)
@zemlanin
zemlanin / cm3.tree.py
Created November 11, 2012 08:28
Генерация дерева состояний
# -*- coding: utf-8 -*-
from collections import namedtuple
def f_t(k = None, mu = None):
if k:
return 'const('+str(k)+')'
elif mu:
return 'gauss('+str(mu)+')'
DEVICES = 'CPU, NBr1, SBr1, ISA1, COM, ISA2, USB, ATA, VGA, SBr2, RAM, GPU, NBr2'
@zemlanin
zemlanin / cm3tree.visualize.py
Created November 15, 2012 21:27
Graph visualization
def visualize(node, edges, done = [], depth = ()):
# Edge = namedtuple('Edge', 'source, dest')
paths = [e for e in edges if getattr(e, 'source') == node]
for edge in paths:
for d in depth:
if not d:
print '│',
else:
print ' ',
# is current path last in source's paths
@zemlanin
zemlanin / stats.py
Created December 7, 2012 15:47
ØMQ Queue model
import zmq, os
times = {}
reaction = {}
done = {}
number_of_tasks = 1.0
mean = lambda l: sum(l)/len(l)
def actuality(t):
@zemlanin
zemlanin / .gitignore
Created December 13, 2012 14:14
.zshrc
.DS_Store
@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 / 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 / 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 / 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'