Skip to content

Instantly share code, notes, and snippets.

View mlshv's full-sized avatar

Misha mlshv

View GitHub Profile
# simple hexdump function
# it's very similar to hexdump from Black Hat Python, but it runs on Python 3
def hexdump(src, length=16):
result = []
digits = 2
for i in range(0, len(src), length):
s = src[i:i+length]
hexa = ' '.join(["%0*X" % (digits, ord(x)) for x in s])
@mlshv
mlshv / merge_sort_recursive.py
Created April 29, 2017 07:12
Recursive Merge Sort (Python)
def divide(a):
return a[:len(a)//2], a[len(a)//2:]
def merge(a, b):
result = []
while(True):
if len(a) == 0:
result += b
@mlshv
mlshv / set_clipboard.py
Created June 22, 2017 07:03
Python set clipboard with win32clipboard (unicode support)
import win32clipboard
def set_clipboard(text):
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText(text, win32clipboard.CF_UNICODETEXT)
win32clipboard.CloseClipboard()
@mlshv
mlshv / store-card.html
Created April 2, 2018 19:48
ITCFnd. Карточка магазина
<div class="store-card">
<a class="store-card__link" href="#">
<img
class="store-card__image"
src="https://duyt4h9nfnj50.cloudfront.net/resized/64aefca79e5d3f19540955e43e91126f-w550-bf.jpg"
alt=""
/>
<h2 class="store-card__name">Il Patio</h2>
<p class="store-card__order-info">
Заказ от
@mlshv
mlshv / store-card.css
Created April 2, 2018 19:49
ITCFnd. Карточка магазина - CSS
.store-card {
margin-bottom: 48px;
}
.store-card__link {
display: block;
text-decoration: inherit;
color: inherit;
}
.store-card__image {
width: 100%;
@mlshv
mlshv / StoreCard.jsx
Created April 2, 2018 19:53
ITCFnd. Карточка магазина - компонент
import React from 'react';
import styled from 'styled-components';
const Link = styled.a`
display: block;
margin-bottom: 48px;
text-decoration: inherit;
color: inherit;
`;
@mlshv
mlshv / Button.jsx
Created April 2, 2018 20:05
ITCFnd. Кнопка Delivery
import styled from 'styled-components';
const Button = styled.button`
padding: 12px 32px;
line-height: 1;
border: none;
border-radius: 34.5px;
opacity: .9;
color: #fff;
background-color: #a3d200;
@mlshv
mlshv / example.js
Last active March 1, 2019 09:10
single variable example iterator
const currentUser = users.find(u => u.id === currentUserId);
@mlshv
mlshv / example.js
Last active March 1, 2019 09:12
single variable example exception
try {
return someUnsafeAction();
} catch (e) {
console.error(e);
return `Error: ${e.message}`;
}
@mlshv
mlshv / example.js
Last active November 17, 2018 09:15
single variable example for-loop in generator
for (const a of actions) {
watchers.push(yield createWatcher(a))
}