scripts

random scripts
git clone git://parazyd.org/scripts.git
Log | Files | Refs

commit 24c4f622a4f5311abcc5c76c234173be8d56b680
parent 860f0a8df966820bb28a8cd9289638dbe0aabba3
Author: parazyd <parazyd@dyne.org>
Date:   Fri,  1 Sep 2017 10:59:25 +0200

new stuff

Diffstat:
Telem | 0
Robsolete/addrepo.sh -> notinpath/obsolete/addrepo.sh | 0
Robsolete/auphone -> notinpath/obsolete/auphone | 0
Robsolete/beepop -> notinpath/obsolete/beepop | 0
Robsolete/blink.sh -> notinpath/obsolete/blink.sh | 0
Robsolete/bright -> notinpath/obsolete/bright | 0
Robsolete/catfact.py -> notinpath/obsolete/catfact.py | 0
Robsolete/disco -> notinpath/obsolete/disco | 0
Robsolete/dmenu.sh -> notinpath/obsolete/dmenu.sh | 0
Robsolete/img -> notinpath/obsolete/img | 0
Robsolete/ix -> notinpath/obsolete/ix | 0
Robsolete/lock -> notinpath/obsolete/lock | 0
Robsolete/mycosmos -> notinpath/obsolete/mycosmos | 0
Robsolete/pio -> notinpath/obsolete/pio | 0
Anotinpath/obsolete/popup | 2++
Robsolete/powertoptune.sh -> notinpath/obsolete/powertoptune.sh | 0
Robsolete/rotmon -> notinpath/obsolete/rotmon | 0
Robsolete/scream.sh -> notinpath/obsolete/scream.sh | 0
Robsolete/signrelease -> notinpath/obsolete/signrelease | 0
Robsolete/spin -> notinpath/obsolete/spin | 0
Robsolete/startcups.sh -> notinpath/obsolete/startcups.sh | 0
Robsolete/startdwm -> notinpath/obsolete/startdwm | 0
Robsolete/startvbox.sh -> notinpath/obsolete/startvbox.sh | 0
Robsolete/surf.sh -> notinpath/obsolete/surf.sh | 0
Robsolete/torrentnotif.sh -> notinpath/obsolete/torrentnotif.sh | 0
Robsolete/translate -> notinpath/obsolete/translate | 0
Robsolete/updatepw.sh -> notinpath/obsolete/updatepw.sh | 0
Robsolete/weepop.sh -> notinpath/obsolete/weepop.sh | 0
Robsolete/xkcd -> notinpath/obsolete/xkcd | 0
Robsolete/xkcd.py -> notinpath/obsolete/xkcd.py | 0
Robsolete/ydl -> notinpath/obsolete/ydl | 0
Robsolete/ys -> notinpath/obsolete/ys | 0
Robsolete/yt -> notinpath/obsolete/yt | 0
Dobsolete/popup | 2--
Mp | 2++
Mradio | 6++++--
Mwd | 4++--
Mwifi | 2+-
Mxkcd | 18++++++------------
Axlstojson.py | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
40 files changed, 85 insertions(+), 19 deletions(-)

diff --git a/elem b/elem diff --git a/obsolete/addrepo.sh b/notinpath/obsolete/addrepo.sh diff --git a/obsolete/auphone b/notinpath/obsolete/auphone diff --git a/obsolete/beepop b/notinpath/obsolete/beepop diff --git a/obsolete/blink.sh b/notinpath/obsolete/blink.sh diff --git a/obsolete/bright b/notinpath/obsolete/bright diff --git a/obsolete/catfact.py b/notinpath/obsolete/catfact.py diff --git a/obsolete/disco b/notinpath/obsolete/disco diff --git a/obsolete/dmenu.sh b/notinpath/obsolete/dmenu.sh diff --git a/obsolete/img b/notinpath/obsolete/img diff --git a/obsolete/ix b/notinpath/obsolete/ix diff --git a/obsolete/lock b/notinpath/obsolete/lock diff --git a/obsolete/mycosmos b/notinpath/obsolete/mycosmos diff --git a/obsolete/pio b/notinpath/obsolete/pio diff --git a/notinpath/obsolete/popup b/notinpath/obsolete/popup @@ -0,0 +1 @@ +beepop+ \ No newline at end of file diff --git a/obsolete/powertoptune.sh b/notinpath/obsolete/powertoptune.sh diff --git a/obsolete/rotmon b/notinpath/obsolete/rotmon diff --git a/obsolete/scream.sh b/notinpath/obsolete/scream.sh diff --git a/obsolete/signrelease b/notinpath/obsolete/signrelease diff --git a/obsolete/spin b/notinpath/obsolete/spin diff --git a/obsolete/startcups.sh b/notinpath/obsolete/startcups.sh diff --git a/obsolete/startdwm b/notinpath/obsolete/startdwm diff --git a/obsolete/startvbox.sh b/notinpath/obsolete/startvbox.sh diff --git a/obsolete/surf.sh b/notinpath/obsolete/surf.sh diff --git a/obsolete/torrentnotif.sh b/notinpath/obsolete/torrentnotif.sh diff --git a/obsolete/translate b/notinpath/obsolete/translate diff --git a/obsolete/updatepw.sh b/notinpath/obsolete/updatepw.sh diff --git a/obsolete/weepop.sh b/notinpath/obsolete/weepop.sh diff --git a/obsolete/xkcd b/notinpath/obsolete/xkcd diff --git a/obsolete/xkcd.py b/notinpath/obsolete/xkcd.py diff --git a/obsolete/ydl b/notinpath/obsolete/ydl diff --git a/obsolete/ys b/notinpath/obsolete/ys diff --git a/obsolete/yt b/notinpath/obsolete/yt diff --git a/obsolete/popup b/obsolete/popup @@ -1 +0,0 @@ -beepop- \ No newline at end of file diff --git a/p b/p @@ -2,3 +2,5 @@ ff=/usr/bin/firefox exec $ff -no-remote -ProfileManager + +#sudo -u ff firefox -no-remote -ProfileManager diff --git a/radio b/radio @@ -13,6 +13,7 @@ list of radios: 6. YAMMAT 7. KLFM 8. NOPE + 9. Radio Paradise EOM exit 1 } @@ -27,9 +28,10 @@ case "$1" in 3|blurfm) play "http://radio.dyne.org/blurfm02.m3u" ;; 4|auroville) play "http://radio.dyne.org/auroville.mp3.m3u" ;; 5|2f30) play "http://radio.2f30.org:8000/live.mp3" ;; - 6|yammat) play "http://192.240.102.131:9107" ;; - 7|klfm) play "http://klfm.streamradio.com.hr:5000/listen.pls" ;; + 6|yammat) play "http://192.240.102.133:12430/" ;; + 7|klfm) play "http://klfm.streamradio.com.hr:2199/tunein/klfm1.pls" ;; 8|nope) play "http://radionope.streamguys1.com/listen.pls" ;; + 9|paradise) play "http://stream-eu1.radioparadise.com:80/mp3-128" ;; *) usage ;; esac diff --git a/wd b/wd @@ -1,3 +1,3 @@ #!/bin/sh - -exec surf http://rpi/wd +exec surf http://rpi/$(basename $0) +#exec surf http://rpi:8000/$(basename $0) diff --git a/wifi b/wifi @@ -1,6 +1,6 @@ #!/bin/sh -dev=wlan0 +dev=${dev:=wlan0} wpasup=/etc/wpa_supplicant/wpa_supplicant.conf usage() { diff --git a/xkcd b/xkcd @@ -39,11 +39,8 @@ def add_text(image, title, alt, tfont=download_dir+'xkcd.ttf', draw = ImageDraw.Draw(img) lheight_total = line_padding for i in lines: - draw.text((w/2-tfont.getsize(" ".join(i))[0]/2, - lheight_total), - " ".join(i), - font=tfont, - fill=0xffffff) + draw.text((w/2-tfont.getsize(" ".join(i))[0]/2, lheight_total), + " ".join(i), font=tfont, fill=0xffffff) lheight_total += lheight + line_padding lheight_total = line_padding lines = text_wrap(afont, alt, w) @@ -57,11 +54,8 @@ def add_text(image, title, alt, tfont=download_dir+'xkcd.ttf', for i in lines: if not i: continue - draw.text((w/2-afont.getsize(" ".join(i))[0]/2, - lheight_total), - " ".join(i), - font=afont, - fill=0xffffff) + draw.text((w/2-afont.getsize(" ".join(i))[0]/2, lheight_total), + " ".join(i), font=afont, fill=0xffffff) lheight_total += lheight + line_padding img.save(image) @@ -108,8 +102,8 @@ def main(): info = get("https://xkcd.com/"+str(randrange(1, info['num']) + 1)+"/info.0.json").json() title = info['safe_title'] - alt = info['alt'] - num = str(info['num']) + alt = info['alt'] + num = str(info['num']) image = num+search("\.([a-z])+$", info['img']).group() diff --git a/xlstojson.py b/xlstojson.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +import xlrd +import json +import os.path +import sys + +def getColNames(sheet): + rowSize = sheet.row_len(0) + colValues = sheet.row_values(0, 0, rowSize ) + columnNames = [] + + for value in colValues: + columnNames.append(value) + + return columnNames + +def getRowData(row, columnNames): + rowData = {} + counter = 0 + + for cell in row: + rowData[columnNames[counter]] = cell.value + counter +=1 + + return rowData + +def getSheetData(sheet, columnNames): + nRows = sheet.nrows + sheetData = [] + counter = 1 + + for idx in range(1, nRows): + row = sheet.row(idx) + rowData = getRowData(row, columnNames) + sheetData.append(rowData) + + return sheetData + +def getWorkBookData(workbook): + nsheets = workbook.nsheets + counter = 0 + workbookdata = {} + + for idx in range(0, nsheets): + worksheet = workbook.sheet_by_index(idx) + columnNames = getColNames(worksheet) + sheetdata = getSheetData(worksheet, columnNames) + workbookdata[worksheet.name] = sheetdata + + return workbookdata + +def main(): + filename = sys.argv[1] + + if os.path.isfile(filename): + workbook = xlrd.open_workbook(filename, encoding_override="cp1252") + workbookdata = getWorkBookData(workbook) + output = \ + open((filename.replace("xlsx", "json")).replace("xls", "json"), "w") + output.write(json.dumps(workbookdata, sort_keys=True, indent=4, separators=(',', ": "))) + output.close() + print("%s was created" % output.name) + else: + print("Sorry, that was not a valid filename") + + + +main()