Skip to content

Instantly share code, notes, and snippets.

View boxmein's full-sized avatar

Johannes Kadak boxmein

View GitHub Profile
#!/usr/bin/env python3
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)
# wish it was that easy with people ;)
def turn_led_on():
GPIO.output(17, 1)
@boxmein
boxmein / janar.java
Last active March 8, 2016 20:30
janarile multithreaded queue thing
import java.lang.Runnable;
import java.net.Socket;
import java.util.concurrent.atomic.AtomicBoolean;
public class InputListenerThread implements Runnable {
private Socket socket;
private AtomicBoolean closing;
public InputListenerThread(Socket s, AtomicBoolean cl) {
@boxmein
boxmein / consolidate_logs.rb
Last active January 4, 2016 22:14
Ruby script to naively consolidate a bunch of HexChat logs. You can figure out date order etc yourself. Mwahahahah
#!/usr/bin/env ruby
# Ruby script to consolidate all my log folders
require 'thread'
PREFIX="/home/#{`whoami`}/.config/hexchat/logs/"
FOLDERS=["freenode", "freenode over znc", "poke_freenode"]
file_q = Queue.new
threads = []
@boxmein
boxmein / square.py
Created December 24, 2015 18:11
from your input, generates a square with offset letters
#!/usr/bin/env python3
# weird script
import sys
inp = input("> ")
sep = ' '
for i in range(len(inp)):
print(sep.join(inp[i:]) + sep + sep.join(inp[0:i]))
# box2@box:~ $ python3 Desktop/untitled.py
# > VAPORWAVE
@boxmein
boxmein / relaybox.py
Last active February 28, 2016 11:15
Multi-server single-file no-dependency asynchronous self-updating extensible Python IRC relay bot. (Alright, the config is in a separate file...)
#!/usr/bin/env python3
# encoding: utf8
#
# IRC Relay bot
# -------------
#
# by boxmein 2015-12-09. license at the end of this file.
#
# Can relay between multiple servers and channels. Relay links can be defined
# live or during configuration.
@boxmein
boxmein / condition_code_to_icon.py
Created October 31, 2015 00:41
Map Yahoo! / YQL weather condition codes to FreeDesktop icon names
def condition_code_to_icon(code):
if 0 <= code <= 2: return 'weather-severe-alert'
elif 3 <= code <= 4: return 'weather-storm'
elif 5 <= code <= 8 or 13 <= code <= 18 or code == 35 or 41 <= code <= 43 or code == 46: return 'weather-snow'
elif 9 <= code <= 12 or code == 40 or code == 45 or code == 47: return 'weather-showers'
elif 19 <= code <= 22: return 'weather-fog'
elif 23 <= code <= 25: return 'weather-overcast'
elif code == 27 or code == 29: return 'weather-few-clouds-night'
elif code == 28 or code == 30: return 'weather-few-clouds'
elif code == 31 or code == 33: return 'weather-clear-night'
@boxmein
boxmein / porn.rb
Created October 24, 2015 16:35
get yourself some spicier ascii art
#!/usr/bin/env ruby
require 'net/http'
Net::HTTP.get_print URI("http://www.asciipr0n.com/pr0n/pinups/pinup#{( rand * 48 ).to_i}.txt")
@boxmein
boxmein / echelon.py
Last active April 18, 2022 21:39
Python script to calculate row echelon matrices from non-row echelon matrices (for Gaussian elimination, say)
#!/usr/bin/env python3
# encoding: utf-8
# Row Echelon Calculator
# (for Gaussian Elimination)
# INPUT:
# Matrix of any dimensions in the following form:
# input := { row, "\n" }, ".\n"
# row := { num, " " }
# num := <float>
@boxmein
boxmein / scrape-definitions.rb
Last active September 18, 2015 16:51
quick script to scrape definitions off of the Oxford Learner's Dictionary
#!/usr/bin/env ruby
# encoding: utf-8
# Dictionary Scraper
# sends a GET request to a dictionary, then scrapes the response with Nokogiri
# and returns the result
# usage: cat wordlist.txt | ruby scrape-definitions.rb 1>words.txt # 2>errors.txt
require 'open-uri'
require 'thread'
require 'nokogiri'
@boxmein
boxmein / scrape-users.rb
Created September 12, 2015 18:35
Quick script to scrape all the users of http://thepowdertoy.co.uk . Note: the admin of that site is handing out IP bans left and right!
require 'net/http'
require 'thread'
# If a request fails we queue it for later
$fail_queue = Queue.new
# Total # of accounts
accounts = 144903
# Amount of threads and piles of work
N = 4