Skip to content

Instantly share code, notes, and snippets.

View cprima's full-sized avatar

Christian Prior-Mamulyan cprima

  • Germany
View GitHub Profile
@cprima
cprima / initializing-NitrokeyHSM.sh
Created January 1, 2018 17:18
Initializing the Nitrokey HSM (Ubuntu 16.04)
#!/usr/bin/env bash
#/**
# * A bash script to initialize a Nitrokey HSM in a basic way.
# * Does nothing on a Nitrokey HSM that was ever initialized before.
# * Its main purpose is to validate user input, especially the -so-pin.
# * I wrote it to make me read the docu carefully. ;)
# *
# * What the script does:
# * - uses readline with plain input, and not "enter twice and compare"
# * -- so "secret input" are visible on the screen
@cprima
cprima / srv-salt-vscode.sls
Last active December 25, 2016 08:51
Install Visual Studio Code on Ubuntu (Debian?) with Saltstack
install Visual Studio Code:
cmd.run:
- name: dpkg -i /tmp/code.deb
- unless: dpkg -s code
- require:
- file: /tmp/code.deb
#curl -I https://go.microsoft.com/fwlink/?LinkID=760868
#Location: https://vscode-update.azurewebsites.net/latest/linux-deb-x64/stable
/tmp/code.deb:
@cprima
cprima / An OpenWRT Chaos Calmer collectd custom exec script.md
Last active July 11, 2018 11:53
Scraping custom statistics from a Devolo Powerline adapter

Scraping custom statistics from a Devolo Powerline adapter

THAT moment when you realize that the webinterface of the access point in a Devolo dLAN® 1200+ Powerline gets updated via jQuery from a json file!

ab95b5b2-3dea-11e6-8598-294304c7cc01

curl 'http://10.xxx.yyy.zzz/cgi-bin/htmlmgr?_file=getjson&service=hpdevices'
[{"loc":"local","type":"hp200","name":"dLAN 1200+ WiFi ac","mac":"F4:06:ab:ab:ab:ab","tx":"","rx":"","ustr":"teh remote"},{"loc":"remote","type":"hp200","name":"dLAN 1200+","mac":"F4:06:aa:bb:cc:dd","tx":"85.3125","rx":"254.625","ustr":"teh master"},{}]
@cprima
cprima / south-pole_full-moon.py
Created June 20, 2016 19:29
How long does the moon stay above the horizon at the south pole?
#!/usr/bin/env python
import ephem
sp = ephem.Observer()
sp.lon = 0 * ephem.degree
sp.lat = -89.9 * ephem.degree
sp.elevation = 0
moon = ephem.Moon()
@cprima
cprima / ca2.py
Created October 14, 2015 17:23
Wolfram-style cellular automata (Python recipe) (modified)
#!/usr/bin/env python
"""
A slight adaptation of http://code.activestate.com/recipes/343386-wolfram-style-cellular-automata/
to be called on the command line like
for r in $(seq 0 255); do echo $r; ./ca2.py -w 9 -h 10 -R $r; done
and writing both an image and a textual representation
"""
"""
CellularAutomata.py: Wolfram-style cellular automata in Python