Skip to content

Instantly share code, notes, and snippets.

View pschwede's full-sized avatar
💭
Brainstorming...

Peter Schwede pschwede

💭
Brainstorming...
View GitHub Profile
#nanojam Nuclear Pilot
if ¬t
// World init
player = {pos: xy(32,32), vel: xy(0,0), acc: 0.01}
landing = {pos: xy(32, 32)}
// Player
sprayOn = 0

Keybase proof

I hereby claim:

  • I am pschwede on github.
  • I am pschwede (https://keybase.io/pschwede) on keybase.
  • I have a public key whose fingerprint is 88C7 BA17 B793 BF47 D82F 326D EFBC 00FF 3636 8FDB

To claim this, I am signing this object:

@pschwede
pschwede / space-bpm.sh
Last active September 7, 2016 21:19
Measure BPM using just one line in Bash
read -p"Hit Space key at each beat (8x): " -n2; /usr/bin/time -f '%e' -- bash -c "read -n6" |& awk '/\./ {printf("%f\n", 6*60/$0)}'
@pschwede
pschwede / rainbowcursor.py
Created October 10, 2015 16:51
Freqently modifies XFCE4 Terminal config to present a different cursor color.
#!/usr/bin/env python
"""Freqently modifies XFCE4 Terminal config to present a different cursor
color."""
from colorsys import hsv_to_rgb
import ConfigParser
import time
@pschwede
pschwede / drinkalert.sh
Created October 1, 2015 07:59
Reminder to drink a glass every two hours.
#!/bin/bash
### Remind me to drink a glass every two hours.
# WHO recommends 3 Liters per day. I am abound 16 hours awake. My glass can hold 0.4 Liters.
# 400ml / (3l / 16h) = 2.133h; which would include a factor of savety of 1.07 ;)
###
while true; do
notify-send "drink a drink";
sleep $(echo "7200 - 3600*("$(date +%k)" % 2) - 60*("$(date +%M)") - "$(date +%S) | bc)
@pschwede
pschwede / iterable variable
Last active July 7, 2016 12:37
R example to show how to access a set of named variables e. g. generated by an iterable in a loop using paste() and assign().
# This is an example to show how to access a set of variables named e. g. by an iterable during an iteration.
#
# BE WARNED: The following coding strategy is not easy to debug!
#
# Some like to generate variables, rather than having just one list of all data sets.
# That way you get an introspectable object for each data set – which particularly eases debugging in RStudio.
# To create variables in a loop or other generative iterations R provides paste(), assign() and get().
# * With paste(), you can concatenate strings. (Use it to compose variable names.)
# * With assign(), you can give variables a value using their name in a string and of course the value you give.
# * With get() you can access such named variables using the sting.
#!/usr/bin/env python3
"""
(c) 2015 pschwede
Solutions to 5 problems every programmer should be
able to solve in less than 1 hour.
"""
# https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour # noqa
from itertools import product
@pschwede
pschwede / to_value
Last active August 29, 2015 14:16
Convert strings to the value they represent. Written in Python. Can anyone do faster?
def to_value(string):
"""Converts a string to the value it represents.
If a non-string has been given, it stays as it is.
Examples:
>>> to_value("foobar")
"foobar"
>>> to_value(12345)
12345
>>> to_value("12345")
@pschwede
pschwede / diff_circo
Last active August 29, 2015 14:15
Diff recursively though all subfolders and then plot identity relation with circo (graphviz, dot)
#!/bin/bash
#
# ========================================
# Diff recursively and then render the identity relation between the files using graphviz circo.
# ========================================
#
# Go to a folder with your subdirectories you want to compare, then call "diff_circo".
#
# Copyright (c) 2015, Peter Schwede pschwede@posteo.de
#
@pschwede
pschwede / shutdown.sh
Created June 29, 2013 20:02
a universal shutdownf or all freedesktops
#!/bin/bash
zenity --question --text='Shutdown?' && dbus-send --system --print-reply --dest='org.freedesktop.ConsoleKit' /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop