Skip to content

Instantly share code, notes, and snippets.

Avatar

C.D. Clark III CD3

View GitHub Profile
View Approx.py
class Approx(object):
def __init__(self,val):
self._val = val
self._epsilon = 0.01
def epsilon(self,epsilon):
self._epsilon = epsilon
return self
def __eq__(self,other):
return abs(other - self._val) <= self._epsilon*abs(other + self._val)/2
@CD3
CD3 / terminal-here.sh
Created Jul 16, 2017
Small script that will open a new terminal in the working directory of the currently focused terminal. Useful with i3.
View terminal-here.sh
#! /bin/bash
ID=$(xprop -root | gawk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')
PID=$(xprop -id $ID | gawk '/_NET_WM_PID\(CARDINAL\)/{print $NF}')
SH=$(basename $SHELL)
ZPID=$(pstree -lpA $PID | sed -n "/$SH/ s/.*$SH(\([0-9]\+\)).*/\1/p")
if [[ -n $ZPID ]]
then
CWD=$(readlink /proc/$ZPID/cwd)