Skip to content

Instantly share code, notes, and snippets.

View robobenklein's full-sized avatar
:electron:
translating thoughts to code

Ben Klein robobenklein

:electron:
translating thoughts to code
View GitHub Profile
@robobenklein
robobenklein / openWebpage.java
Created November 1, 2014 16:48
Open a webpage in the default browser.
import java.awt.Desktop;
import java.net.URI;
import java.net.URL;
import java.net.URISyntaxException;
import java.net.MalformedURLException;
public static void openWebpage(String url) {
try {
try {
openWebpage(new URL(url).toURI());
@robobenklein
robobenklein / sudoku.py
Created November 6, 2014 22:21
Solve a Sudoku Puzzle
#!/usr/bin/env python
print("")
def cross(A, B):
#Cross product of elements in A and elements in B.
return [a+b for a in A for b in B]
digits = '123456789'
rows = 'ABCDEFGHI'
cols = digits
@robobenklein
robobenklein / cookies.js
Last active August 29, 2015 14:09
Get and Set Cookies the easy way.
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
@robobenklein
robobenklein / softwarePhilosophy.txt
Created November 20, 2014 15:32
Robosane Software Philosophy
Robosane aims to provide software that not only "just works," but is enjoyable for both users and developers.
Our programs should never put users, computers, or anything else at risk, and never use coding tactics that make our code unnecessarily hard to understand.
Code can be published under any license, however Robosane encourages developers to Open Source their works.
# This requires the 'beep' command.
beep 658 125
beep 1320 500
beep 990 250
beep 1056 250
beep 1188 250
beep 1320 125
beep 1188 125
beep 1056 250
@robobenklein
robobenklein / serialRead.py
Created March 5, 2015 18:32
This program reads serial input and logs it to file with timestamp.
# -*- coding: utf-8 -*-
'''
This program reads serial input from the 'sport' and logs it to file with timestamp.
It may not be the best code out there but it works for all my intents and purposes.
Credit to Tim and Ben Klein
This code is licensed under WFTPL, http://www.wtfpl.net/txt/copying/
Although it would still be nice to give some kind of credit ;)
@robobenklein
robobenklein / java-version.sh
Created June 25, 2015 23:11
Easily Switch between Webupd8's Java 7 and Java 8 by shell script.
read -p "Which java version should we switch to? 7 or 8? : " action
case $action in
7 ) sudo update-java-alternatives -s java-7-oracle && echo "Switched to Java 7";;
8 ) sudo update-java-alternatives -s java-8-oracle && echo "Switched to Java 8";;
esac
@robobenklein
robobenklein / gpg-agent.sh
Created July 16, 2015 13:27
Shell script to switch between Gnome Keyring and the original GPG Agent for handling GPG keys.
echo "The Gnome Keyring's GPG protocol is not complete."
echo "Choose wether to use the Gnome Agent or the GPG agent to manage the keys."
echo "[help] for more information."
read -p "Should we use [gnome] keyring agent or [gpg] agent? : " action
case $action in
gnome ) sudo dpkg-divert --rename --remove /etc/xdg/autostart/gnome-keyring-gpg.desktop && echo "Gnome Keyring GPG agent ENABLED.";;
gpg ) sudo dpkg-divert --local --rename --divert /etc/xdg/autostart/gnome-keyring-gpg.desktop-disable --add /etc/xdg/autostart/gnome-keyring-gpg.desktop && echo "Gnome Keyring GPG agent DISABLED.";;
help ) echo "Some versions of Gnome Keyring hijack the connection to GPG Agent (they intercept all the communication between gpg or gpgsm and gpg-agent) by setting the GPG_AGENT_INFO environment variable to point to the Gnome Keyring process. Gnome Keyring then filters all communication with gpg-agent. See http://wiki.gnupg.org/GnomeKeyring for more info why.";;
esac

Keybase proof

I hereby claim:

  • I am robobenklein on github.
  • I am robobenklein (https://keybase.io/robobenklein) on keybase.
  • I have a public key ASABZwYqZ2MXHKEUy9PIrMb2fTyYEH2qP6WJ6YIudju9lwo

To claim this, I am signing this object: