Skip to content

Instantly share code, notes, and snippets.

Simon Jenny simonjenny

View GitHub Profile
@simonjenny
simonjenny / igit
Created Mar 13, 2019
Git all in one..
View igit
#!/bin/bash
if [ -z "$1" ]
then
echo "Commit Reason is empty"
exit 0
fi
~/Development/./clean.sh
git add .
git commit -m "$1"
git push
@simonjenny
simonjenny / lego.sh
Last active Mar 13, 2019
Find Lego building instructions by set number from the command line and open the PDF in the default browser
View lego.sh
#!/usr/bin/env bash
URL=$(curl --silent "https://www.lego.com//service/biservice/search?fromIndex=0&locale=en-US&onlyAlternatives=false&prefixText=${1}" | jq -r '.products[0].buildingInstructions[0].pdfLocation')
[[ -x $BROWSER ]] && exec "$BROWSER" "$URL"
path=$(which xdg-open || which gnome-open || which open) && exec "$path" "$URL"
echo "Error: Can't find default browser"
View rip
#!/bin/bash
rawout=$(handbrake-cli -i /dev/dvd --main-feature -t 0 2>&1 >/dev/null)
count=$(echo $rawout | grep -Eao "Chapter [0-9]+" | wc -l)
divider=$(( $count/4 ))
current=1
target=4
for i in $(seq $divider)
do
@simonjenny
simonjenny / phone
Created Jan 19, 2018
Fairytale Phone - Next Thing Co C.H.I.P Version
View phone
#!/usr/bin/python
import CHIP_IO.GPIO as GPIO
import math, sys, os
import subprocess
import socket
GPIO.setup("XIO-P7", GPIO.IN);
GPIO.setup("XIO-P6", GPIO.IN);
View create-a-pi.sh
#!/bin/bash
command -v pv >/dev/null 2>&1 || { echo "Dieses Script benötigt das Programm pv." >&2; exit 1; }
# Shell Script for creating a pi sd card iwth the latest Rasbian
# Author <simon.jenny@me.com> Simon Jenny
#
# -------------------------------------------
if [ "$1" == "" ]; then
echo "Drive Folder Parameter missing!"
echo "Usage : create-a-pi DRIVE (eg /dev/disk2)"
echo "Here are all your mounted drives:"
@simonjenny
simonjenny / server
Last active Aug 29, 2015
Server for Realtime Data API form Sentinel
View server
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
from SocketServer import ThreadingMixIn
import json
import Adafruit_BMP.BMP085 as BMP085
import threading
import argparse
import re
import cgi
class LocalData(object):
@simonjenny
simonjenny / report
Last active Aug 29, 2015
Report Data
View report
import requests
import json
import Adafruit_BMP.BMP085 as BMP085
from ConfigParser import SafeConfigParser
parser = SafeConfigParser()
parser.read('/boot/pi-fi/config.txt')
sensor = BMP085.BMP085(mode=BMP085.BMP085_ULTRAHIGHRES)
data_json = json.dumps({'sentinel' : parser.get('Sentinel', 'uuid') , 'temp' : sensor.read_temperature(), 'pressure' : sensor.read_pressure(), 'altitude' : sensor.read_altitude()})
@simonjenny
simonjenny / register
Last active Aug 29, 2015
Register a sentinel
View register
import requests
import json
import socket
import uuid
import re
from ConfigParser import SafeConfigParser
parser = SafeConfigParser()
parser.read('/boot/pi-fi/config.txt')
@simonjenny
simonjenny / sentinel.sh
Last active Aug 29, 2015
Sentinel Install
View sentinel.sh
#!/bin/bash
UUID=$(cat /proc/sys/kernel/random/uuid)
cd
apt-get remove --auto-remove --purge libx11-.* -y
apt-get update && apt-get upgrade -y
apt-get install git build-essential python-dev python-smbus i2c-tools python-pip -y
pip install requests
@simonjenny
simonjenny / clone
Last active Aug 29, 2015
Simple DD Clone Script with progress Bar (Requires pv)
View clone
#!/bin/bash
# Shell Script for cloning images to sd cards
# Author <simon.jenny@me.com> Simon Jenny
# http://makerblog.ch
#
# -------------------------------------------
if [ "$1" == "" ] || [ "$2" == "" ]; then
echo "Parameter missing!"
You can’t perform that action at this time.