Skip to content

Instantly share code, notes, and snippets.

@nolar
nolar / conn_pool.py
Created February 14, 2022 10:25 — forked from luqmansen/conn_pool.py
Simple Object Pool pattern to Create Connection Pool
from datetime import datetime
from multiprocessing import Lock
import mysql.connector
USER = "root"
PASSWD = "admin"
HOST = 'localhost'
DB = "db_test"
@nolar
nolar / bash-profile-d-pyenv.sh
Created May 22, 2020 08:24
Fixing a slow pyenv `cd` with multiple virtualenvs.
#!/usr/bin/env bash
# Special virtualenvs must be in PATH strictly after pyenv. Hence, add it before!
if which pyenv >/dev/null 2>&1 ; then
for name in power __user__ __z__ ; do
if pyenv prefix "$name" >/dev/null 2>&1 ; then
export PATH="$(pyenv prefix "$name")/bin:$PATH"
fi
done
fi
@nolar
nolar / _cov.sh
Created May 24, 2019 18:38
Ad-hoc script to replay code coverage over the whole git history (used in https://github.com/zalando-incubator/kopf/pull/72)
#!/bin/bash
set -eux
unset E2E # e2e covers everything, but this is not a fair coverage.
first=981e664e39955f38d9a279af24ee5be77c7e9a3e
last=b6e3ec407f46d8db0f1c5c15fce41359ac76ebf1 # or upstream/master
# Master-only commits (i.e. where "master" branch was on merges).
# These ones are fast, since it walks "first parent" way only
while read -r rev; do
@nolar
nolar / pyenv-virtualenv-speedup.sh
Created January 16, 2019 14:52
Speed up the pyenv-virtualenv with 10+ venvs
# FIXME: pyenv-virtualenv is increadibly slow with ~10 virtualenvs.
# FIXME: because of the injection to $PROMPT_COMMAND: _pyenv_virtualenv_hook.
# FIXME: because it calls `pyenv sh-activate` on every prompt, which is slow.
if which pyenv >/dev/null; then eval "$(pyenv init --no-rehash - )"; fi
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi
# This is a replacement hook for the pyenv-virtualenv, which triggers only on demand,
# and stays inactive on other cases -- to save the time on prompt generation.
__pyenv_local_file=.python-version
@nolar
nolar / atom-0.75.0-block-cursor.patch
Created July 22, 2016 09:10 — forked from execjosh/atom-0.75.0-block-cursor.patch
Block Cursor for Atom v0.75.0
--- a/Atom.app/Contents/Resources/app/src/cursor-view.js
+++ b/Atom.app/Contents/Resources/app/src/cursor-view.js
@@ -19,7 +19,12 @@
"class": 'cursor idle'
}, (function(_this) {
return function() {
- return _this.raw(' ');
+ return _this.div({
+ outlet: 'cursorValue',
+ 'style': 'visibility:hidden;'
// Рецепт, как скачать всё состояние биржи WT от https://vk.com/smee_again
// 1. открываем Google Chrome, заходим на ЛЮБУЮ страницу webtransfer (должны быть залогинены)
// 2. заходим в Меню -> Просмотр -> Разработчикам -> Консоль Javascript
// 3. вставляем сюда ВСЁ вот это, жмём ENTER, и ждём несколько секунд:
var PERPAGE=100500,
WT_URL = 'https://webtransfer-finance.com/ru/account/ajax_user/applications_table/1/', // «Дать кредит»
//WT_URL = 'https://webtransfer-finance.com/ru/account/ajax_user/applications_table/2/', // «Получить кредит»
CSV_SEPARATOR=';'; // если в Excel криво отображается табличка, то заменить на «,»
$.post(WT_URL, {"per_page": PERPAGE, "offset": 0, "search": "", "filter": "", "order[id]": "desc"}, function(r) {
var csvContent = [ // это названия столбцов в файле. Можно переименовывать по вкусу:
@nolar
nolar / Chrome Anywhere.workflow
Created April 20, 2015 17:54
Opens Chrome window on current desktop (useful with hotkeys). If input is turned on, open all selected URLs in the tabs.
on run {input, parameters}
tell application "Google Chrome"
make new window
if input is not {} then
repeat with URL in input
open location URL
end repeat
end if
<?xml version="1.0"?>
<root>
<item>
<name>Change F19 to switch language in VMware, Parallels, VirtualBox</name>
<item>
<name style="important">First, remap CapsLock to F19 (code 80) in PCKeyboardHack.</name>
</item>
<item>
#
# Print all possible candidates for virtualenv relative to the directory $1.
# Used in venv_find() for every directory starting from the current and up to the root.
#
function venv_candidates () {
echo $1
echo $1/.venv
echo $1/VENV
echo $1/ENV
echo $1.venv
--- WindowlistScreenlet.py.orig 2008-10-27 22:31:14.000000000 +0300
+++ WindowlistScreenlet.py 2008-10-27 23:52:14.000000000 +0300
@@ -28,6 +28,8 @@
import screenlets
from screenlets import DefaultMenuItem
from screenlets.options import BoolOption
+from screenlets.options import StringOption
+from screenlets.options import IntOption
import cairo
import gtk