This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc xdbg { } { puts $::errorInfo }; # This must be the first proc and be as simple as possible so we are always able to debug | |
# Define required globals | |
set ::xhelpMsgs [dict create] | |
set ::xVerbosity INFO | |
# Define the verbosity levels (based on python logging levels: https://verboselogs.readthedocs.io/en/latest/readme.html ) | |
set ::verbosityLevel [dict create] | |
dict append ::verbosityLevel NOTSET 0 ;# When a logger is created, the level is set to NOTSET (note that the root logger is created with level WARNING). This level isn?t intended to be used explicitly, however when a logger has its level set to NOTSET its effective level will be inherited from the parent logger. | |
dict append ::verbosityLevel DEVDBG 5 ;# Way too verbose for regular debugging, but nice to have when someone is getting desperate in a late night debugging session and decides that they want as much instrumentation as possible! :-) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SOURCE ME | |
# DOES NOT WORK WITH ELEMENTS CONTAINING SPACES!!!! | |
# Limited use. Use a real scriptting language!?!? | |
# Ex: | |
# declare -a cmplxArr='([0]="preffoo" [1]="bar" [2]="foo" [3]="prefbaz" [4]="baz" [5]="prefbar" [6]="pref with spaces" [7]="pref | |
# with | |
# new line" [8]=" | |
# pref with new line before")' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Plots tank damage per tier/level | |
# Each dot is mean of tank types in that tier | |
# Each tank type is a seperate line graph | |
# Inspired from here https://matplotlib.org/examples/user_interfaces/embedding_in_tk.html | |
# Good example of manipulating dataframes and creating stand alone application with Tk. | |
import matplotlib | |
matplotlib.use('TkAgg') | |
from numpy import arange, sin, pi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Being able to automate windows tasks with autoit is cool but it would be even cooler if we could: | |
# 1) run it with python (py is much easier and familiar than the autoit script language) | |
# 2) with cygwin (so we can do all our linux/bash/vim cleverness in a familiar work environment) | |
# | |
# Here is some info on how I got it set up on my new windows laptop. | |
# Some interesting reading on autoit functionality direclty from windows DLLs: https://stackoverflow.com/questions/23768184/programmatically-rotate-monitor | |
# Functions for win32api http://timgolden.me.uk/pywin32-docs/contents.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! python | |
# To run this double click it in Windows File Explorer | |
# Notes: | |
# Some interesting reading on autoit functionality direclty from windows DLLs: https://stackoverflow.com/questions/23768184/programmatically-rotate-monitor | |
# Functions for win32api http://timgolden.me.uk/pywin32-docs/contents.html | |
# Directly calling the DLLs w/ ctypes: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getsystemmetrics | |
import time | |
import win32com.client |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gvim_arg() { | |
local clip servername && local $*; # declare possible named variables | |
local file_chars clip_file_check extra_stuff line_num find_str cmds cmd cmd1 cmd2 | |
export cmds=() | |
export file_chars='[-a-zA-Z0-9\$\.\/_]' | |
#(>&2 echo "Clip: $clip" ) | |
# Get rid of non-file name charecters | |
clip_file_check=$( echo "$clip" | perl -ne '/($ENV{"file_chars"}+)/ && print("$1");' ) | |
extra_stuff=$( echo "$clip" | perl -ne '/$ENV{"file_chars"}+(.*)/ && print("$1");' ) | |
if [[ $extra_stuff =~ ^(:[0-9]+) ]]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bits2signed( val, width ): | |
'''Convert a value into its signed counterpart given a particular bit width''' | |
shift=width-1 | |
max_val=(2**width)-1 | |
if val > max_val: | |
raise ValueError('The value provided (%s) is greater than the bit width can represent(2^%s=%s)'%(val,width,max_val)) | |
sign_bit_mask=1<<shift | |
magn_bit_mask=(1<<shift)-1 | |
return -(val&sign_bit_mask) | (val&magn_bit_mask) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source_file=`pwd`/${BASH_SOURCE[0]} | |
source_root=$( readlink -f $( dirname $source_file ) ) | |
# Setup so we can easily search the codebase with csearch/cindex | |
# Make sure csearch and cindex are installed first | |
if type cindex >/dev/null 2>&1; then | |
export CSEARCHINDEX=$source_root/.csearchindex.local | |
if [[ ! -f $CSEARCHINDEX ]]; then | |
cindex $source_root |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import pandas, os, re | |
import fix_yahoo_finance as yf # Might need to "> pip install fix_yahoo_finance" | |
stocks=["SPY","QQQ"] # Array of stocks to plot | |
bgn_date='2014-06-12' # Set the date range | |
end_date='2018-09-28' | |
fig,ax = plt.subplots() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple history function like bash history but for python interactive/repl. | |
def history( num=0 ): | |
import readline | |
len = readline.get_current_history_length() | |
if( num>0 ): | |
num=len-num | |
for i in range(num,len): | |
print( i,readline.get_history_item(i + 1) ) | |
# Later attemps at the same thing: Cygwin setup of Python REPL |