diff --git a/bin/SimpleWebPage b/bin/SimpleWebPage index 6c24e87..8912613 120000 --- a/bin/SimpleWebPage +++ b/bin/SimpleWebPage @@ -1 +1 @@ -../web_serving/SimpleWebPage.py \ No newline at end of file +../web/SimpleWebPage.py \ No newline at end of file diff --git a/bin/clockcurses b/bin/clockcurses deleted file mode 120000 index 41a087b..0000000 --- a/bin/clockcurses +++ /dev/null @@ -1 +0,0 @@ -../clockcurses.py \ No newline at end of file diff --git a/bin/clockcurses b/bin/clockcurses new file mode 100755 index 0000000..5d55c7f --- /dev/null +++ b/bin/clockcurses @@ -0,0 +1,175 @@ +#!/usr/bin/python +import curses +import os,sys +import time,datetime +import math +import signal +from optparse import OptionParser + + +def termsize(): + rows, columns = os.popen('stty size', 'r').read().split() + return (int(rows),int(columns)) + +def centerpoint(ry,rx): + r=int(round(min(ry/1.5,rx/1.5))-1) + return (int(round(ry/2)),int(round(rx/2)),r) + +def saddstr(win,y,x,s): + try: + win.addstr(y,x,s) + except: + pass + +def drawcircle(win,cy,cx,r): + precision=360 + for a in range(precision): + alpha=2.0*math.pi*a/precision + dy=int(round(cy-float(r)*math.cos(alpha))) + dx=int(round(cx+2.0*float(r)*math.sin(alpha))) + saddstr(win,dy,dx,'.') + return + +def drawline(win,cy,cx,a,s,r,char): + prec=2 + for l in range(r*prec): + if l>s: + ly=int(round(cy-float(l)*math.cos(a)/prec)) + lx=int(round(cx+2.0*float(l)*math.sin(a)/prec)) + saddstr(win,ly,lx,char) + + return + +def drawdigit(win,y,x,d): + s=' ' + if d=='0': + s='0000 00 00 0000' + if d=='1': + s=' 1'*5 + if d=='2': + s='222 22222 222' + if d=='3': + s='333 3 33 3333' + if d=='4': + s='4 4 4444 4 4' + if d=='5': + s='5555 555 5555' + if d=='6': + s='66 6 6666 6666' + if d=='7': + s='777 7 7 7 7' + if d=='8': + s='8888 88888 8888' + if d=='9': + s='9999 9999 9 99' + if d==':': + s=' . . ' + drawsplitstr(win,y,x,s) + return + +def drawsplitstr(win,y,x,st): + ls=list(st) + for r in range(5): + rs=3*r + saddstr(win,y+r,x,ls[rs]+ls[rs+1]+ls[rs+2]) + return + +def drawdigital(win,y,x,t): + if options.seconds: + if t.tm_sec&1: + hrs=list('%02d:%02d:%02d' % (t.tm_hour, t.tm_min, t.tm_sec)) + else: + hrs=list('%02d %02d %02d' % (t.tm_hour, t.tm_min, t.tm_sec)) + else: + if t.tm_sec&1: + hrs=list('%02d:%02d' % (t.tm_hour, t.tm_min)) + else: + hrs=list('%02d %02d' % (t.tm_hour, t.tm_min)) + for c in range(len(hrs)): + drawdigit(win,y,x+4*c,hrs[c]) + +def readinput(win): + try: + input=win.getch() + if input in [ord(x) for x in ['x','X','q','Q']]: + return "x" + except: + return "" + return "" + +class timer_struct: + """ Class for storing timer. """ + def __init__(self,h,m,s): + self.tm_hour=int(h) + self.tm_min=int(m) + self.tm_sec=int(s) + +def main(): + stdscr=curses.initscr() + curses.curs_set(0) + start_t=time.time() + try: + #rows,columns = termsize() + while (1): + rows,columns = stdscr.getmaxyx() + cy,cx,r = centerpoint(rows,columns) + stdscr.clear() + t=time.localtime() + if options.timer: + t_new=time.time()-start_t + t_m, t_s = divmod(t_new, 60) + t_h, t_m = divmod(t_m, 60) + else: + t_s=float(t.tm_sec) + t_m=float(t.tm_min) + t_h=float(t.tm_hour) + alphas=math.pi*t_s/30.0 + alpham=math.pi*t_m/30.0 + alphas/60.0 + alphah=math.pi*t_h/6.0 + alpham/12.0 + if options.seconds: + drawline(stdscr,cy,cx,alphas,1,r/2,'s') + drawline(stdscr,cy,cx,alpham,1,int(round(r*0.8)/2),'m') + drawline(stdscr,cy,cx,alphah,1,int(round(r*0.5)/2),'HH') + stdscr.addstr(cy,cx,'o') + drawcircle(stdscr,cy,cx,r/2) + for h in range(12): + drawline(stdscr,cy,cx,math.pi*h/6.0,r,1+r/2,'O') + if options.timer: + drawdigital(stdscr,1,1,timer_struct(t_h,t_m,t_s)) + drawdigital(stdscr,7,1,t) + else: + drawdigital(stdscr,1,1,t) + stdscr.refresh() + #time.sleep(options.refresh) + signal.signal(signal.SIGALRM, readinput) + signal.alarm(int(options.refresh)) + userinput=readinput(stdscr) + if userinput=="x": + curses.nocbreak() + stdscr.keypad(0) + curses.endwin() + sys.exit(0) + + except KeyboardInterrupt: + curses.nocbreak() + stdscr.keypad(0) + #curses.echo() + + curses.endwin() + +usage='''Usage: %prog [options] + +Display a clockface +''' +parser=OptionParser(usage=usage) +parser.add_option("-s",action="store_true",dest="seconds",default=False, + help="Show seconds [%default]") +parser.add_option("-r",type="int",dest="refresh",default=3, + help="Refresh rate in seconds [%default]") +parser.add_option("-t",action="store_true",dest="timer",default=False, + help="Timer instead of current time [%default]") +global options +(options,args)=parser.parse_args() + +main() + diff --git a/bin/foldermenu b/bin/foldermenu index 02a2a2f..81e09ce 120000 --- a/bin/foldermenu +++ b/bin/foldermenu @@ -1 +1 @@ -../foldermenu.py \ No newline at end of file +../files/foldermenu.py \ No newline at end of file diff --git a/bin/highbeam b/bin/highbeam index 6775694..affbe20 120000 --- a/bin/highbeam +++ b/bin/highbeam @@ -1 +1 @@ -../highbeam \ No newline at end of file +../reporting/highbeam \ No newline at end of file diff --git a/bin/numberDL b/bin/numberDL index d547a51..922e3c6 120000 --- a/bin/numberDL +++ b/bin/numberDL @@ -1 +1 @@ -../numberDL \ No newline at end of file +../web/numberDL \ No newline at end of file diff --git a/bin/sqlite3ncsv b/bin/sqlite3ncsv index a3f13db..a012a69 120000 --- a/bin/sqlite3ncsv +++ b/bin/sqlite3ncsv @@ -1 +1 @@ -../sqlite3ncsv \ No newline at end of file +../tsv/sqlite3ncsv \ No newline at end of file diff --git a/bin/tmuxssh b/bin/tmuxssh index a4b7327..59daf4d 120000 --- a/bin/tmuxssh +++ b/bin/tmuxssh @@ -1 +1 @@ -../tmuxssh \ No newline at end of file +../web/tmuxssh \ No newline at end of file diff --git a/clockcurses.py b/clockcurses.py deleted file mode 100755 index 5d55c7f..0000000 --- a/clockcurses.py +++ /dev/null @@ -1,175 +0,0 @@ -#!/usr/bin/python -import curses -import os,sys -import time,datetime -import math -import signal -from optparse import OptionParser - - -def termsize(): - rows, columns = os.popen('stty size', 'r').read().split() - return (int(rows),int(columns)) - -def centerpoint(ry,rx): - r=int(round(min(ry/1.5,rx/1.5))-1) - return (int(round(ry/2)),int(round(rx/2)),r) - -def saddstr(win,y,x,s): - try: - win.addstr(y,x,s) - except: - pass - -def drawcircle(win,cy,cx,r): - precision=360 - for a in range(precision): - alpha=2.0*math.pi*a/precision - dy=int(round(cy-float(r)*math.cos(alpha))) - dx=int(round(cx+2.0*float(r)*math.sin(alpha))) - saddstr(win,dy,dx,'.') - return - -def drawline(win,cy,cx,a,s,r,char): - prec=2 - for l in range(r*prec): - if l>s: - ly=int(round(cy-float(l)*math.cos(a)/prec)) - lx=int(round(cx+2.0*float(l)*math.sin(a)/prec)) - saddstr(win,ly,lx,char) - - return - -def drawdigit(win,y,x,d): - s=' ' - if d=='0': - s='0000 00 00 0000' - if d=='1': - s=' 1'*5 - if d=='2': - s='222 22222 222' - if d=='3': - s='333 3 33 3333' - if d=='4': - s='4 4 4444 4 4' - if d=='5': - s='5555 555 5555' - if d=='6': - s='66 6 6666 6666' - if d=='7': - s='777 7 7 7 7' - if d=='8': - s='8888 88888 8888' - if d=='9': - s='9999 9999 9 99' - if d==':': - s=' . . ' - drawsplitstr(win,y,x,s) - return - -def drawsplitstr(win,y,x,st): - ls=list(st) - for r in range(5): - rs=3*r - saddstr(win,y+r,x,ls[rs]+ls[rs+1]+ls[rs+2]) - return - -def drawdigital(win,y,x,t): - if options.seconds: - if t.tm_sec&1: - hrs=list('%02d:%02d:%02d' % (t.tm_hour, t.tm_min, t.tm_sec)) - else: - hrs=list('%02d %02d %02d' % (t.tm_hour, t.tm_min, t.tm_sec)) - else: - if t.tm_sec&1: - hrs=list('%02d:%02d' % (t.tm_hour, t.tm_min)) - else: - hrs=list('%02d %02d' % (t.tm_hour, t.tm_min)) - for c in range(len(hrs)): - drawdigit(win,y,x+4*c,hrs[c]) - -def readinput(win): - try: - input=win.getch() - if input in [ord(x) for x in ['x','X','q','Q']]: - return "x" - except: - return "" - return "" - -class timer_struct: - """ Class for storing timer. """ - def __init__(self,h,m,s): - self.tm_hour=int(h) - self.tm_min=int(m) - self.tm_sec=int(s) - -def main(): - stdscr=curses.initscr() - curses.curs_set(0) - start_t=time.time() - try: - #rows,columns = termsize() - while (1): - rows,columns = stdscr.getmaxyx() - cy,cx,r = centerpoint(rows,columns) - stdscr.clear() - t=time.localtime() - if options.timer: - t_new=time.time()-start_t - t_m, t_s = divmod(t_new, 60) - t_h, t_m = divmod(t_m, 60) - else: - t_s=float(t.tm_sec) - t_m=float(t.tm_min) - t_h=float(t.tm_hour) - alphas=math.pi*t_s/30.0 - alpham=math.pi*t_m/30.0 + alphas/60.0 - alphah=math.pi*t_h/6.0 + alpham/12.0 - if options.seconds: - drawline(stdscr,cy,cx,alphas,1,r/2,'s') - drawline(stdscr,cy,cx,alpham,1,int(round(r*0.8)/2),'m') - drawline(stdscr,cy,cx,alphah,1,int(round(r*0.5)/2),'HH') - stdscr.addstr(cy,cx,'o') - drawcircle(stdscr,cy,cx,r/2) - for h in range(12): - drawline(stdscr,cy,cx,math.pi*h/6.0,r,1+r/2,'O') - if options.timer: - drawdigital(stdscr,1,1,timer_struct(t_h,t_m,t_s)) - drawdigital(stdscr,7,1,t) - else: - drawdigital(stdscr,1,1,t) - stdscr.refresh() - #time.sleep(options.refresh) - signal.signal(signal.SIGALRM, readinput) - signal.alarm(int(options.refresh)) - userinput=readinput(stdscr) - if userinput=="x": - curses.nocbreak() - stdscr.keypad(0) - curses.endwin() - sys.exit(0) - - except KeyboardInterrupt: - curses.nocbreak() - stdscr.keypad(0) - #curses.echo() - - curses.endwin() - -usage='''Usage: %prog [options] - -Display a clockface -''' -parser=OptionParser(usage=usage) -parser.add_option("-s",action="store_true",dest="seconds",default=False, - help="Show seconds [%default]") -parser.add_option("-r",type="int",dest="refresh",default=3, - help="Refresh rate in seconds [%default]") -parser.add_option("-t",action="store_true",dest="timer",default=False, - help="Timer instead of current time [%default]") -global options -(options,args)=parser.parse_args() - -main() - diff --git a/chr2pix b/files/chr2pix similarity index 100% rename from chr2pix rename to files/chr2pix diff --git a/foldermenu.py b/files/foldermenu.py similarity index 100% rename from foldermenu.py rename to files/foldermenu.py diff --git a/highbeam b/reporting/highbeam similarity index 100% rename from highbeam rename to reporting/highbeam diff --git a/sqlite3ncsv b/sqlite3ncsv deleted file mode 100755 index 92ce223..0000000 --- a/sqlite3ncsv +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -help() { -echo 'Sqlite3NCSV: view sqlite3 DB with ncsv. - Usage: sqlite3ncsv [FILE] [TABLE/QUERY/-l] - - first argument: sqlite3 file - second, optional argument: - TABLE: If not given, first in schema used. - QUERY: If the second argument contains spaces, it is assumed to be a query. - -l: List table names - ' -} -[[ "$1" == "-h" ]] && { - help; exit -} -[[ -f "$1" ]] || { - help; exit -} - -sqlfile="$1" -[[ "$2" == "-l" ]] && { - sqlite3 "$sqlfile" "SELECT name FROM sqlite_master WHERE name NOT LIKE 'sqlite_%'" - exit -} - -[[ -z "$2" ]] && { - table=$( sqlite3 "$sqlfile" "SELECT name FROM sqlite_master WHERE name NOT LIKE 'sqlite%' LIMIT 1;" ) -} || { - table="$2" -} -[[ "$table" = "${table% *}" ]] && { - query="SELECT * FROM $table;" -} || { - query="$table" -} - -sqlite3 -header -separator ' ' -nullvalue NA "$sqlfile" "$query" | ncsv - diff --git a/web_serving/SimpleWebPage.py b/web/SimpleWebPage.py similarity index 100% rename from web_serving/SimpleWebPage.py rename to web/SimpleWebPage.py diff --git a/web_serving/droopy b/web/droopy similarity index 100% rename from web_serving/droopy rename to web/droopy diff --git a/web_serving/droopysend b/web/droopysend similarity index 100% rename from web_serving/droopysend rename to web/droopysend diff --git a/web_serving/index.php b/web/index.php similarity index 100% rename from web_serving/index.php rename to web/index.php diff --git a/numberDL b/web/numberDL similarity index 100% rename from numberDL rename to web/numberDL diff --git a/tmuxssh b/web/tmuxssh similarity index 100% rename from tmuxssh rename to web/tmuxssh diff --git a/web_serving/webserver.py b/web/webserver.py similarity index 100% rename from web_serving/webserver.py rename to web/webserver.py