Skip to content

Instantly share code, notes, and snippets.

@aniline
aniline / tmux.conf
Created September 25, 2017 11:33
My .tmux.conf
set-option -g status on
set -g terminal-overrides 'xterm*:smcup@:rmcup@,rxvt*:smcup@:rmcup@'
# Emacs add prefix as well, keep telnet escape as prefix.
unbind-key C-b
set-option -g prefix C-]
set-option -g prefix2 C-x
# Emacs window management keys
unbind-key -T prefix 1
@aniline
aniline / goog_totp.py
Created September 12, 2017 17:51
TOTP like Google Authenticator
import hashlib, hmac, base64, struct, time, math
def GoogleTOTP(s):
msg = int(math.floor(time.time()/30))
hm = hmac.new(base64.b32decode(s), struct.pack('>q', msg), hashlib.sha1).digest()
offs = ord(hm[-1]) & 0xF
code = str(((struct.unpack('>L',hm[offs:offs+4])[0]) & 0x7FFFFFFF) % 1000000).zfill(6)
return code
print GoogleTOTP("")
@aniline
aniline / readclip.py
Created August 7, 2017 06:41
An old script (better here than in Dropbox, dunno what it does).
#!python
import RPi.GPIO as GPIO
import time
import sys
GPIO.setmode(GPIO.BOARD)
bint = 3
@aniline
aniline / lfsr.py
Created March 12, 2017 11:41
Some trials with lfsr.
#!/usr/bin/env python
import sys, time
id = 1234567890
lfsr = 0xDEADBEEF
def lfsrN(lfsr, count):
#0b10101010101
#0x80000417, 0b10000000 00000000 0000 0100 0001 0111
#!/usr/bin/env python
import random, sys
def distribute(parts, value):
total = sum(parts)
min_value = len(parts)
if ((value < min_value) or (value > total)):
return None
cur = [1]*len(parts)
@aniline
aniline / dir615.py
Created November 1, 2016 16:32
Scrape status and stats page off d-link dir-615 hardware ver. T1 Firmware 20.07
#!/usr/bin/env python
#
# DLink DIR-615 HW:T1 FW:20.07 status.
from sys import argv, exit
import urllib as u1
import urllib2 as u2
import bs4
# Router IP
@aniline
aniline / ups.py
Created October 22, 2016 13:24
Collect some stuff form apcupsd.
#!/usr/bin/env python
from subprocess import Popen, PIPE
import urllib2
from time import sleep
p = Popen(['/sbin/apcaccess'], stdout=PIPE, stderr=PIPE)
(o, e) = p.communicate()
status = {}
@aniline
aniline / show_clip.py
Created June 5, 2016 17:12
CLIP desktop notification
#!/usr/bin/env python
import sys, json
from gi.repository import Notify
sys.path.append("paho-mqtt-1.2/src/")
import paho.mqtt.client as mqtt
def _on_connect(client, userdata, rc):
@aniline
aniline / lyahdark.user.js
Created September 6, 2014 14:51
lyahdark.user.js
var bgw = document.getElementsByClassName("bgwrapper")[0];
var fixed_spans = document.getElementsByClassName('fixed');
var hint_boxen = document.getElementsByClassName('hintbox');
bgw.style.backgroundColor = '#000';
bgw.style.color = 'white';
for (i in fixed_spans) {
var fs = fixed_spans[i];
if (fs.style != undefined) fs.style.backgroundColor = '#222';
@aniline
aniline / owa_link_unwrap.user.js
Last active December 28, 2015 11:59
Re-map links to actual target instead of through OWA servers.