Skip to content

Instantly share code, notes, and snippets.

@kirillsulim
kirillsulim / Fsm.java
Created October 4, 2018 14:02
Thread-safe FSM realization draft
package io.su0.universum.util.fsm;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
#!/usr/bin/env python3
# Should be in pre-commit file without .py extension
from subprocess import call
import sys
import os.path as path
HOOK_LIST_NAME = "pre-commit.list"
method: POST
url: http://ya.ru
params:
some-param: bblabla
headers:
X-Some-Header: balbla blabla vla
body: >
{
"just": "some",
"json": 123,
@kirillsulim
kirillsulim / a.py
Last active March 23, 2018 18:51
Algorithm find two numbers sum equals given x
def find_pairs(array, x):
result = []
array = sorted(set(array))
first = 0
last = len(array) - 1
while True:
first_el = array[first]
@kirillsulim
kirillsulim / counter.py
Created March 2, 2018 17:59
Count number of occurrences of a specific digit with order keeping
from collections import Counter
def convert(value):
value = str(value)
cnt = Counter(value)
res = []
for el in cnt:
res.append(el)

#Header Text Google

"yohedacrstqlkinpmf%gxvz",
"eitusanrmocdlpbvqgfhjxy",
#^^^^^^^^^^
@kirillsulim
kirillsulim / saver.py
Created October 4, 2015 07:32
slides saver
from bs4 import BeautifulSoup
import requests
from urllib.request import urlretrieve
r = requests.get("http://www.slideshare.net/slideshow/embed_code/41339705")
soup = BeautifulSoup(r.content, "html.parser")
slides = soup.find_all("div", class_="slide")
@kirillsulim
kirillsulim / after
Last active August 29, 2015 14:24
Welcome to callback hell! This is a little slice of callback hell =) Enjoy! I will rewrite it =)
function notifyServerError() {
swal("Server failed");
};
function hidePost(id) {
$('div[data-post-id=' + id + ']').hide("slow");
};
var update_url = '/news/update_state';