Skip to content

Instantly share code, notes, and snippets.

View imrehg's full-sized avatar
🐒
Chaos Monkey

Gergely Imreh imrehg

🐒
Chaos Monkey
View GitHub Profile
@imrehg
imrehg / copycmd.sh
Last active May 29, 2017 14:47
system copier for resin devices
#!/bin/bash
# Copy everything up intil resin-data (mmcblk0p6 usually)
# and send it over the ssh connection, compressed
DEVICE=/dev/mmcblk0
PARTITION=mmcblk0p5
# Get partition end position in blocks
FSSIZE=$(/sbin/fdisk -l -o Device,End ${DEVICE} | grep ${PARTITION} | awk '{ print $2 }')
# Copy data, compress, and send over STDOUT
/bin/dd if=/dev/mmcblk0 conv=sync,noerror bs=512 status=none count=${FSSIZE} | gzip -c
#!/bin/bash
set -o pipefail
# Help function
function update-resin-supervisor-help {
cat << EOF
Wrapper to run supervisor agent updates on resin distributions.
$0 <OPTION>
Options:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCa2kIKfTdOWTX99jUNw0gGHEBguyJE5F6NDfLpsjCLvQn0WZ9TEUS+WQy9a348yg3LwAAwtevu6pSTPpiWDUtaA/xjcDD/mxzCVRsqkJoM48RrFW594qI5c8Z/GsQJTXq7NI+ViyjznIETPtVk9bXCMikGyQ1yD/RnbBMBlRlraQFrltu1vzWe7Bm+6VSFBcb82MmuqomppOkZmH9N+7K1FSh+WJz+nB0c0nivTbsCHtIKiRq/ttu06odhr/DY0d6RXxJLP54azKRah9AjqH/6vVFJaRF7Pai4C5+9NtOYhU7/xLhpORUsgqtW1yzbKHCreI5XvzbWlRRJEtmubprb greg@nostromo
@imrehg
imrehg / handover.py
Last active July 14, 2016 06:16
Example of a script being able to hand-over to a second instance of itself
"""
Python `hand-over` strategy example
"""
import os
import sys
import socket
SOCKFILE = "/tmp/handover.sock"
# Check for this script already running
@imrehg
imrehg / dangerous_erase.sh
Created June 3, 2016 09:40
Disk eraser script
#!/bin/bash
# From http://unix.stackexchange.com/questions/72216/fast-way-to-randomize-hd
DISK="/dev/sda"
SIZE=`fdisk -l | grep "${DISK}" | awk '{print $5}'`
echo "Erasing ${DISK} (size ${SIZE} bytes)"
read -p "Are you sure? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
@imrehg
imrehg / autotest.js
Created May 27, 2016 12:39
Telemetry
AUTOBAHN_DEBUG = true;
var https = require('https');
https.globalAgent.options.rejectUnauthorized = false;
var autobahn = require('autobahn');
var connection = new autobahn.Connection({
url: 'wss://ingest.epeakgears.com:1337/ws'
, realm: 'xyala'
});
@imrehg
imrehg / example.ino
Created May 14, 2016 08:34
OCTeleShield telemetry example
#include <SPI.h>
#include <Adafruit_MAX31855.h>
// Example creating a thermocouple instance with hardware SPI (Uno/Mega only)
// on a given CS pin.
#define CS1 2
#define CS2 3
Adafruit_MAX31855 th1(CS1);
Adafruit_MAX31855 th2(CS2);
@imrehg
imrehg / leisure.py
Created February 25, 2016 08:23
Leisure vs Money plotting
#!/usr/bin/env python
"""
Leasure vs Money
Inspiration
Tweet by Stanford Econ Policy https://twitter.com/SIEPR/status/702637668883152896
Data sources
* GDP per capita PPP: : World Bank http://data.worldbank.org/indicator/NY.GDP.PCAP.PP.CD?display=default
* GDP per capita current USD: World Bank http://data.worldbank.org/indicator/NY.GDP.PCAP.CD/countries?display=default
* Working hours: OECD.stat https://stats.oecd.org/Index.aspx?DataSetCode=ANHRS
@imrehg
imrehg / PKGBUILD
Created November 26, 2015 08:46
pps-tools package for ArchLinux
# Maintainer: Gergely Imreh <[email protected]>
pkgname=pps-tools-git
pkgver=r17.0deb9c7
pkgrel=1
pkgdesc="User-space tools for LinuxPPS and kernel header"
arch=('armv7h')
url="https://github.com/ago/pps-tools"
license=('GPL2')
groups=()
depends=()
@imrehg
imrehg / telemetry-receive.js
Last active November 11, 2015 09:57
Telemetry with Arduino Yun
var autobahn = require('autobahn');
var connection = new autobahn.Connection({
url: 'ws://octv-versus.ddns.net:8080/ws',
realm: 'octv1'}
);
connection.onopen = function (session) {
// SUBSCRIBE to a topic and receive events