Skip to content

Instantly share code, notes, and snippets.

@peterdemin
peterdemin / food.txt
Created July 19, 2018 00:31
List of food items
abiyuch
acerola
acorn
agave
agents
agutuk
alfalfa
amaranth
animal
apache
@peterdemin
peterdemin / one_session_per_user.middleware.py
Last active May 8, 2023 17:10
django middleware that disallows concurent user login while allowing such for administrators
from one_session_per_user.models import User, Visitor
from django.contrib.sessions.models import Session
class OneSessionPerUserMiddleware(object):
"""http://stackoverflow.com/a/1814797"""
def process_request(self, request):
if isinstance(request.user, User):
current_key = request.session.session_key
@peterdemin
peterdemin / kibitzr.yml
Last active June 12, 2022 22:22
Bank of America check
checks:
- name: BofA
url: https://www.bankofamerica.com/
form:
- id: onlineId1
creds: bofa.login
- id: passcode1
creds: bofa.password
- id: hp-sign-in-btn
click: true
@peterdemin
peterdemin / diary
Created February 4, 2022 17:19
SH script to append text to a file and synchronize it using git
#!/bin/sh
DIARY_DIR=~/diary
DIARY_FILE=README.md
cd ${DIARY_DIR}
git pull -q
echo >> ${DIARY_FILE}
date >> ${DIARY_FILE}
echo >> ${DIARY_FILE}
@peterdemin
peterdemin / .vimrc
Last active January 15, 2022 17:21
My .vimrc for Python development
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
@peterdemin
peterdemin / .bashrc
Created November 1, 2019 13:43
My bashrc file from NCBI
#!/usr/bin/env bash
# bash history
export HISTFILESIZE=99999
export HISTSIZE=99999
# solarized
export TMUX="screen-256color"
# vim
@peterdemin
peterdemin / twitter-unfollow.js
Created August 17, 2013 12:25
Web browser console command to unfollow everyone on https://twitter.com/following page by issuing onclick() on all "Unfollow" buttons.
$('button span.unfollow-text').parent().each(function(i, a) {a.click();})
@peterdemin
peterdemin / django-tms.md
Last active September 13, 2018 18:09
Django-TMS

Django Text Management System

Motivation

Django templates often contain text/media that doesn't affect application's functionality. These texts belong to product people, but because they are stored in template files, are modified by developers. Such editing is slow and continious delivery pipelines treat it the same way as code changes.

How things used to be

@peterdemin
peterdemin / update_deps.py
Created December 29, 2017 21:08
Build locked python requirements files for multiple environments
#!/usr/bin/env python
"""
Build locked requirements files for each of:
base.in
test.in
local.in
External dependencies are hard-pinned using ==
Internal dependencies are soft-pinned using ~=
".post23423" version postfixes are truncated
@peterdemin
peterdemin / commit-msg
Created December 29, 2017 13:44
Git commit-msg hook, that adds Jira ticket number from branch name to each commit message
#!/bin/sh
ticket=$(git symbolic-ref HEAD | grep -o 'ND-[0-9][0-9]*')
if [ -n "${ticket}" ]; then
grep -qs "^ *${ticket}" "${1}" || (echo >> "${1}" && echo "${ticket}" >> "${1}")
fi