Skip to content

Instantly share code, notes, and snippets.

View RustingSword's full-sized avatar
🤦‍♂️

RustingSword

🤦‍♂️
View GitHub Profile
#!/usr/bin/env python
#
# Copyright 2008-2014 Jose Fonseca
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
#!/usr/bin/python2
#! coding: utf-8
class QuadTree(object):
"""An implementation of a quad-tree.
 
This QuadTree started life as a version of [1] but found a life of its own
when I realised it wasn't doing what I needed. It is intended for static
geometry, ie, items such as the landscape that don't move.
 
@RustingSword
RustingSword / dtw.c
Created August 6, 2014 06:31
constrained dtw
typedef struct point{
double x;
double y;
} point;
double get_distance(const point a, const point b)
{
double xdiff = a.x - b.x;
double ydiff = a.y - b.y;
return xdiff*xdiff + ydiff*ydiff;
#!/usr/bin/python
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
import sys
#plt.rc('text', usetex=True)
#plt.rc('font', **{'family':'monospace','monospace':['Ubuntu Mono'], 'size':16})
#mpl.rcParams['legend.fontsize'] = 10
@RustingSword
RustingSword / .vimperatorrc
Created January 5, 2015 08:23
vimperatorrc + zotero
"3.8.2 (created: 2014/02/13 23:52:43)
map <C-c> :stop<Return>
map <lt> <C-6>
map p <C-z>
map v <C-v>
map <C-s> :stop<Return>
nmap <F5> :set<Space>gui=navigation<Return>
nmap <C-F5> :set<Space>gui=nonavigation<Return>
noremap j 5j
@RustingSword
RustingSword / pm-template.latex
Created February 26, 2015 14:36
chinese template for generating pdf file using pandoc
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$]{$documentclass$}
\usepackage{geometry} % 設定邊界
\geometry{
top=1in,
inner=1in,
outer=1in,
bottom=1in,
headheight=3ex,
headsep=2ex
}
@RustingSword
RustingSword / restore_doumail.js
Last active August 29, 2015 14:21
将“私信”恢复成“豆邮”
// ==UserScript==
// @name 驱逐私信,恢复豆邮
// @namespace http://fanfou.com/lzgxd
// @description 将“私信”恢复成“豆邮”
// @include http://*.douban.com/*
// @version 0.1
// @grant none
// ==/UserScript==
// via http://stackoverflow.com/a/1512889
#!/bin/bash
song=$(echo -n `mocp -Q %song 2> /dev/null`)
artist=$(echo -n `mocp -Q %artist 2> /dev/null`)
if [[ "$song" != "" ]]
then
if [[ "$artist" != "" ]]
then
echo -n "\${color white} Now Playing: \${color green} $song - $artist"
else
echo -n "\${color white} Now Playing: \${color green} $song"
#!/bin/bash
from=$1
shift
notify-send -i "/home/orz/.scripts/notify.png" -- "New Message" "From: $from \n$*" 2 > /dev/null
aplay -q "/home/orz/.scripts/message.wav" &