Skip to content

Instantly share code, notes, and snippets.

View boxmein's full-sized avatar

Johannes Kadak boxmein

View GitHub Profile
@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 / 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 / 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 / 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 / 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) {
#!/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 / Key.js
Created February 1, 2017 15:02
A list of Protractor.js key constants
// Protractor keys
// Extracted from https://github.com/SeleniumHQ/selenium/blob/d943ee2950e25a2f4a3492058107cfd005d6f7fd/javascript/node/selenium-webdriver/lib/input.js#L44
const Key = {
NULL: '\uE000',
CANCEL: '\uE001', // ^break
HELP: '\uE002',
BACK_SPACE: '\uE003',
TAB: '\uE004',
CLEAR: '\uE005',
RETURN: '\uE006',
@boxmein
boxmein / converter.js
Last active February 7, 2017 21:17
Convert Node.js buffers from equals representation to Unicode
const convert = x => x.split(" ").map(e => e.split("=")[1].replace(/, /g, "")).map(e => String.fromCharCode(parseInt(e))).join("");
// Usage:
convert("0=65, 1=66, 2=66, 3=65"); // "ABBA"
@boxmein
boxmein / start_webpack.sh
Created January 24, 2018 16:29
Number parsing bug
#!/bin/bash
~> webpack --env.numerical 5 --env.commitId 12180e3
# outputs { numerical: 5, commitId: 12180000 }
~> webpack --env.numerical 5 --env.commitId "12180e3" [255]
# outputs { numerical: 5, commitId: 12180000 }
~> webpack --env.numerical 5 --env.commitId "12180e3" --env.TEST_STRING test [255]
# { numerical: 5, commitId: 12180000, TEST_STRING: 'test' }
@boxmein
boxmein / lopp.html
Created February 25, 2018 21:07
Script to parse Startup Estonia data and output a HTML file.
</body>
</html>