Skip to content

Instantly share code, notes, and snippets.

#
# 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
@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;'
@nolar
nolar / hostland-refunds.txt
Last active December 17, 2015 06:38
Как hostland.ru деньги возвращает :-) Изначально было оплачено 1728 руб за год, потреблено ≈6.5 мес, к возврату по математике причитается ≈800 руб.
Здравствуйте.
С условиями возврата Вы можете ознакомиться здесь:
http://hostland.ru/about_money#money_back
На вашем абонентском счете сейчас 1277.17 руб.,
из них 708.02 руб. - денежные бонусы ООО Хостланд, которые не возвращаются.
Оплата 29-10-2012 была произведена пластиковой картой через Masterbank.
При этом ООО Хостланд за свой счет оплатил комиссию в размере 3,5% в Masterbank при осуществлении перевода,
эти денежные средства будут удержаны (1728*3,5%=60,48руб.).
@nolar
nolar / .bashrc
Created July 27, 2012 18:22
Virtualenv automatic activation
#
# Finds the closest virtualenv root directory, starting from $1, and going up to the root.
# If the target directory is not specified as an argument, current directory is used.
# Prints the virtualenv path found, or nothing otherwise.
#
function venv_find () {
# The cycle is just for the case with broken root folder detection - never do more than N iterations.
venv_root=${1:-"."}
venv_found=""
for (( i=100; i > 0; i-- )); do
@nolar
nolar / gist:2844428
Created May 31, 2012 16:06
Accidentially found in code
class marva
{
static $l;
static $x;
/**
* Инициализирует на странице
*
* @static
* @param string|false $l параметр l марвы
@nolar
nolar / mturk-create.py
Created August 11, 2011 09:49
MTurk HIT initiation
import datetime
import boto.mturk.connection
import boto.mturk.question as mtq
import boto.mturk.qualification as mtqu
mt = boto.mturk.connection.MTurkConnection(aws_access_key_id='xxx', aws_secret_access_key='yyy')
text_en = '''Hello!
I am test text message to be translated from English to Russian.
If you ask me, I was born in a mind of a crazy web developer,
who tests the MTurk API to start a very promising service later.