Skip to content

Instantly share code, notes, and snippets.

@tubaman
tubaman / worker.py
Last active October 9, 2015 13:28
Disco worker that zips up imported modules/packages
#!/usr/bin/env python
"""Disco worker that automatically finds and sends to the nodes all the modules and packages that are used"""
import os
import sys
import shutil
import tempfile
import zipfile
import modulefinder
from inspect import getsourcefile, getmodule
@tubaman
tubaman / keybase.md
Created September 23, 2014 00:24
Keybase proof

Keybase proof

I hereby claim:

  • I am tubaman on github.
  • I am tubaman (https://keybase.io/tubaman) on keybase.
  • I have a public key whose fingerprint is B193 15E6 30FE AEDD AA72 4D30 CF0B C389 E6B1 AEC7

To claim this, I am signing this object:

@tubaman
tubaman / copy_selenium_cookies_to_cookiejar.py
Created July 10, 2015 01:05
copy selenium cookies to cookielib CookieJar
import cookielib
def to_cookielib_cookie(selenium_cookie):
return cookielib.Cookie(
version=0,
name=selenium_cookie['name'],
value=selenium_cookie['value'],
port='80',
port_specified=False,
@tubaman
tubaman / ledgerparser.py
Last active February 27, 2023 16:03
ledgerparser
"""ledger journal parser
We use this to parse the ledger file because we want to preserve the
exact format of the file including spaces, etc. It maps the parsed
transaction to the origin lines of the file.
"""
import ledger
@tubaman
tubaman / attusage.py
Created October 7, 2016 22:34
Parser for AT&T Wireless bill(CSV format)
#!/usr/bin/env python
import logging
import sys
import csv
import pint
ureg = pint.UnitRegistry()
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
@tubaman
tubaman / vncssh
Last active June 27, 2019 22:39
Script to connect from one linux desktop to another using VNC over ssh
#!/bin/bash
# Connect from one linux desktop to another using SSH over VNC
#
# The script works best if you have ssh public key authentication setup with
# an agent so you don't have to type your ssh password 1000 times.
#
# Usage: vncssh remote_servername
#
# What does this do?
# 1. Calculate the right scale factor so the remote desktop resolution will
@tubaman
tubaman / xref
Created August 29, 2019 18:47
Build ctags/cscope automatically
#!/bin/bash
set -o noglob
function addfiles {
NAME="$1"
find $EXCLUDE -name "$NAME" >> cscope.files
}
function autoignore {
@tubaman
tubaman / pwstore.py
Last active June 30, 2021 22:38
Python module to get password data from password-store.org(pass)
"""Python module to get password data from password-store.org(pass)
ex:
from pwstore import pwstore
password, data = pwstore("example.org")
username = data['Username']
"""
import re
@tubaman
tubaman / waitpid
Created June 23, 2020 23:38
waitpid for the linux command line
#!/bin/bash
# Wait for a process(es) to finish by pid
# https://stackoverflow.com/a/41613532
for pid in $@; do
tail --sleep-interval=0.250 --pid=$pid -f /dev/null
done
@tubaman
tubaman / surekillpid
Last active June 23, 2020 23:42
Linux CLI to kill a pid as nicely but surely as possible
#!/bin/bash
# How to try to kill a process
# http://porkmail.org/era/unix/award.html#uuk9letter
# Be as nice as possible before shooting it in the head
# uses waitpid: https://gist.github.com/tubaman/00b792221bd75fbbca61184da3d414ce
options=$(getopt -o v --long verbose -- $@)
[ $? -eq 0 ] || {
exit 1
}