Skip to content

Instantly share code, notes, and snippets.

@stt
stt / bdcff2xml.py
Last active February 18, 2016 22:14
Converts boulder dash common file format files into XML
#!/usr/bin/env python
"""
http://www.elmerproductions.com/sp/peterb/BDCFF/
http://www.gratissaugen.de/erbsen/bdcff.html
"""
from __future__ import print_function
__email__ = 'samuli@tuomola.net'
import re
@stt
stt / PqagWq.markdown
Last active August 29, 2015 14:25
PqagWq
@stt
stt / dnd alignr.markdown
Last active August 29, 2015 14:21
dnd alignr
@stt
stt / run.py
Last active August 29, 2015 14:21
service that scrapes online resources for webapps
from flask import Flask, request, jsonify
from flaskutils import cors
from lxml import html
import os, re, sys
import logging
## config
logging.basicConfig(
@stt
stt / wrappedview.js
Last active August 29, 2015 14:09
Dimensionally agnostic wrapped view for multi-dimensional arrays
// assumes min < max
function wrap(v, min, max) {
if (v < min)
return max - ((min-v) % Math.abs(max-min));
else if (v > max)
return min + ((v-max) % Math.abs(max-min));
else
return v;
}
@stt
stt / gist:dc012899dcd671d4293a
Last active August 29, 2015 14:09
Bookmarklet to find words with most common endings from http://www.suomisanakirja.fi/riimit/-li to use at https://www.name.com/names
function commonEndings(words, endLen) {
endLen = endLen || 5;
var col = {};
words
.filter(function(w){ return w.length==endLen })
.forEach(function(ext) {
words.forEach(function(w) {
if(w.match(ext+"$")) col[ext] = col[ext]+1 || 1;
})
@stt
stt / sshift.py
Created July 20, 2014 15:40
Subtitle shifting script for .sub and .srt
#!/usr/bin/env python
"""
(c)2014, <samuli@tuomola.net>
"""
import sys, re
from datetime import datetime, timedelta
from os.path import isfile
def sub_shift(lines, dt):
for i,l in enumerate(lines):
@stt
stt / designer.html
Created July 4, 2014 23:15
designer
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<link rel="import" href="../paper-toast/paper-toast.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../paper-ripple/paper-ripple.html">
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
@stt
stt / openimgs
Last active August 29, 2015 14:03
bash function where you pipe in a list of image filenames and it open them up in a webbrowser
# put it in .bash_aliases
# generates html from stdin, takes size of batch as argument
function openimgs {
MAX=${1:-6}
TMPL=~/openimgs-template.html
OUTF="openimgs-$$.html"
local IFS=$'\n'
BUF=($(cat -))
local IFS=$' \n'
@stt
stt / gist:743e954296d2b9f52c70
Last active August 29, 2015 14:00
Bookmarklet for easier imageboard browsing
javascript:if(typeof(_4ac)!=='undefined') _4ac.remove();
_4ac=(function() {
var links = [].slice.call(document.querySelectorAll('.file'));
var cur_link = -1;
var expand = true;
function isNext(e) { return e.keyCode == 188 || e.keyCode == 192; };
function isPrev(e) { return e.keyCode == 190 || (e.keyCode == 192 && e.shiftKey); };
function handleKey(e){
if(isPrev(e) || isNext(e)) {
open(cur_link + (isPrev(e)?-1:1));