Skip to content

Instantly share code, notes, and snippets.

View artemvang's full-sized avatar
🌚

Artem Sukhodolskyi artemvang

🌚
  • Poland, Kraków
  • 02:28 (UTC +02:00)
View GitHub Profile

Keybase proof

I hereby claim:

  • I am artemvang on github.
  • I am artemvang (https://keybase.io/artemvang) on keybase.
  • I have a public key ASAuqB1S-N_MlBD5pRVslpl583tmftI5U7XyhAeDcCeFMwo

To claim this, I am signing this object:

@artemvang
artemvang / qr-filetransfer.sh
Created December 11, 2019 19:51
qr-filetransfer using bash
#!/bin/sh
TARGET_FILE=$1
PORT=$2
URL=$(ip route get 8.8.8.8 2>/dev/null | awk '{print $7}')
if [ -z "$URL" ]; then
echo "Can not obtain ip address. Probably, you are not connected to wifi"
exit 1
fi
@artemvang
artemvang / server.sh
Created September 10, 2019 19:47
Simple xinetd server for serving static content
#!/bin/bash
base="/home/somebody"
http_send_file() {
local filename="$1"
local temp_file=$(mktemp)
gzip $filename -c > $temp_file
local length=$(stat -c '%s' $temp_file)
@artemvang
artemvang / pewdiepie_minecraft_dmenu.sh
Last active September 9, 2019 14:38
Watch Pewdiepie's minecraft playlist using youtube-dl, jq, dmenu and mpv
youtube-dl -j --flat-playlist "https://www.youtube.com/watch?list=PLYH8WvNV1YEnLCzUDWueIZQXDNhqLKywk" \
| jq '[.id, .title] | @tsv' \
| sed -r 's_^\"(.*)\"$_https://youtube.com/watch?v=\1_g' \
| sed 's/\\t/ -> /g' \
| dmenu -i -l 20 \
| grep -Eo '(http|https)://[a-zA-Z0-9./?=_-]*' \
| xargs -d'\n' -I{} mpv "{}"
@artemvang
artemvang / pdf_watcher.sh
Created September 2, 2019 22:27
Watch for updates in your markown file and automatically reload pdf viewer
#!/bin/bash
STYLESHEET='tufte.css'
FILE=$1
TMPFILE=$(mktemp)
mv $TMPFILE "$TMPFILE.html"
TMPFILE="$TMPFILE.html"
mupdf "${FILE%%.*}.pdf" &
@artemvang
artemvang / kmeans++.py
Created August 8, 2019 11:45
Speed up default kmeans++ initializer in SciPy
import numpy as np
from scipy.cluster.vq import _valid_init_meth
def _kpp(data, k):
dims = data.shape[1] if len(data.shape) > 1 else 1
init = np.zeros((k, dims), dtype=np.float32)
diff = np.zeros((data.shape[0], k, dims), dtype=np.float32)
probs = np.zeros((data.shape[0],), dtype=np.float32)
@artemvang
artemvang / hoxly_parse.sh
Created July 7, 2019 22:13
Parse news.hoxly.com news into json
curl -s https://news.hoxly.com/story/173 | pup 'a.h6, li.fact json{}' | jq '{title: .[0].text, facts: [.[1:][] | {fact: .text[:-2], source: .children[0].href}]}'
@artemvang
artemvang / script.sh
Last active July 1, 2019 10:48
Parse google patents page to json
curl -s https://patents.google.com/patent/WO2016186801A1/en?oq=neural \
| pup 'dd[itemprop="publicationNumber"], span[itemprop="title"]:only-of-type, h2:contains("ID="), article > a, div.abstract, div.description, div[class="claims ocr"], :parent-of(h2:contains("Classifications")) ul, dd[itemprop="inventor"] json{}' \
| jq '{pat_number: .[0].text, title: .[1].text, family_id: .[2].text[3:] | tonumber, pdf_link: .[3].href, abstract: .[4].text, description: [.[5].children[] | .text] | join("\n"), claims: [.[6].children[] | [.children[] | .text] | join("\n")], classifications: [.[7].children[] | [.children[] | .children | .[] | {code: .children[0].text, name: .children[1].text}]], inventors: [.[8:][] | .text]}'
@artemvang
artemvang / parser.py
Last active January 30, 2018 19:57
Ultrafast async IMDB movie keywords parser
import json
import re
import asyncio
import re
import itertools
from bs4 import BeautifulSoup
import aiohttp
OUTPUT_FILE = "output.txt"