Skip to content

Instantly share code, notes, and snippets.

View roma-guru's full-sized avatar
🌴
In Cyprus

Roman Voropaev roma-guru

🌴
In Cyprus
View GitHub Profile
@roma-guru
roma-guru / capture.sh
Last active October 5, 2022 13:57
Simple screen recorder
#!/bin/zsh
screenlogs_dir=$HOME/Documents/ScreenLogs/$(date "+%Y-%m-%d")
[ ! -d $screenlogs_dir ] && mkdir -p $screenlogs_dir
screen_file=$screenlogs_dir/$(date "+%H-%M").png
/usr/sbin/screencapture -xm $screen_file
# Add to crontab:
# crontab -e
# */30 * * * * /Users/roma/Documents/ScreenLogs/capture.sh
@roma-guru
roma-guru / devenv.sh
Last active December 5, 2021 19:22
Install scripts for dev on mac
#!/bin/zsh
# Sys tools
brew install coreutils cmake git gawk
brew install vim zsh starship zplug
brew install bat ranger direnv fzf exa fd ripgrep
brew install htop glances gotop
# Dev langs
brew install golang rust python node
@roma-guru
roma-guru / Dockerfile
Last active May 8, 2020 10:16
Happy Birthday, Leo! Have great adventures!
from python:3.8-alpine
run apk update && apk add zsh
run pip install ricksay lolcat
shell ["/bin/zsh", "-c"]
env N=10 text="Rick{i}: Urghk, you Leo? It's Rick from Dimension#{i} (the best one btw).\
Congrats on leaving a vagina few decades ago, and all this stuff. \
I've seen your adventures, but they suck, mine are interdimensional! \
But I got you a present ... Here we go..."
@roma-guru
roma-guru / fcgi.py
Created April 6, 2020 10:46
Simplest FCGI app via Flup
def myapp(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Hello World!\n']
if __name__ == '__main__':
from flup.server.fcgi import WSGIServer
WSGIServer(myapp).run()
@roma-guru
roma-guru / wikipedia_scraping.py
Created March 5, 2020 15:05
Here is example of scraping ethnicities in USA from wikipedia article.
import requests
from bs4 import BeautifulSoup
# Load wikipedia page
url = 'https://en.wikipedia.org/wiki/Race_and_ethnicity_in_the_United_States'
page = requests.get(url).content
# Use lxml parser
soup = BeautifulSoup(page,'lxml')
@roma-guru
roma-guru / django.snippets
Created June 11, 2018 14:10
UltiSnips for my python dev.
# Admin
snippet modadm "ModelAdmin register" b
@admin.register(${1:Model})
class $1Admin(admin.ModelAdmin):
list_display = ($2,)
endsnippet
snippet admreg "Model register" b
admin.site.register(${1:Model})
@roma-guru
roma-guru / Vagrantfile
Created September 29, 2017 14:34
Working Vagrant environment for building Telegram desktop client. Based on Ubuntu 12.04. Should be placed under TBuild directory. Then just vagrant up && ./build_debug.sh.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/precise64"
config.vm.box_check_update = false
config.vm.provider "virtualbox" do |vb|
vb.memory = 8068
vb.cpus = 4
@roma-guru
roma-guru / favicon_downloader.py
Created September 1, 2017 04:58
Simple Python script to download favicons from list of domains (first argument). Used for custom Keepass entry icons.
import sys
import bs4
import requests
from urllib.parse import urlparse, urlunparse
def find_icon(domain):
resp = requests.get("http://{}/".format(domain))
page = bs4.BeautifulSoup(resp.text, 'html.parser')
res = "http://{}/favicon.ico".format(domain)
icons = [e for e in page.find_all(name='link') if 'icon' in e.attrs.get('rel')]
@roma-guru
roma-guru / pip_parallel.sh
Created January 26, 2017 22:19
Parallel pip download. Or wait here - https://github.com/pypa/pip/issues/825
# Preloading
cat requirements.txt | xargs -t -n1 -P9 pip install -q --download ./dist
# Installing with parallel native builds
pip install --install-option="--jobs=4" --no-index --find-links=./dist -r ./requirements.txt
@roma-guru
roma-guru / django_log.py
Last active May 4, 2018 11:59
Simpliest Django logging (from High Performance Django book)
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'simple',
},
'file-debug': {