Skip to content

Instantly share code, notes, and snippets.

View prideout's full-sized avatar
🎯
Focusing

Philip Rideout prideout

🎯
Focusing
View GitHub Profile
@prideout
prideout / gist:1987871
Created March 6, 2012 18:16
Embed a VTE terminal
#!/usr/bin/env python
import sys
try:
import gtk
except:
print >> sys.stderr, "You need to install the python gtk bindings"
sys.exit(1)
@prideout
prideout / gist:2126890
Created March 19, 2012 20:36
generate SVG
from xml.etree import ElementTree as etree
from functools import partial
Circle = partial(etree.Element, 'svg:circle')
c = Circle(cx='100', cy='200', fill='red')
etree.tostring(c)
# <svg:circle cx="100" cy="200" fill="red" />
@prideout
prideout / gist:2429789
Created April 20, 2012 15:41
wolfram alpha stuff
ParametricPlot3D[{(3+cos(v)) * cos(u),(3+cos(v)) * sin(u), sin(v)},{u,0,2pi},{v,0,2pi}]
@prideout
prideout / wombat.py
Created May 22, 2012 02:33
Calling Python from Tcl
#!/usr/bin/python
import itertools as it
class pi_computing_device(object):
def __init__(self, iterations):
self.n = iterations
def compute_pi(self):
coefficients = it.cycle((1, -1))
@prideout
prideout / SimulateMouse.py
Created May 22, 2012 22:45
use libxdo to simulate the mouse
#!/usr/bin/python
from ctypes import *
import time, random
import os
CURRENTWINDOW = 0
# nm -D /usr/lib64/libxdo.so.2 | grep mouselocation
# http://python.net/crew/theller/ctypes/tutorial.html#passing-pointers-or-passing-parameters-by-reference
@prideout
prideout / JSON-validating-formatting
Created May 24, 2012 18:38
one-line JSON validator
python -c "import json,sys; print json.load(sys.stdin)" < input.txt
cat unformatted.json | python -m json.tool > formatted.json
@prideout
prideout / parse-rib-stats.py
Last active December 1, 2015 05:49
dump all files that a RIB touches
# prman -statsfile FOO.xml BAR.rib
from lxml import etree
root = etree.parse('stats.xml').getroot()
print root.xpath("//set[@name='fileLog']/member/text()")
@prideout
prideout / steal-server.el
Created February 21, 2013 18:54
Steal the emacs server from another session and relabel its frame
(defun steal-server()
(interactive)
(shell-command "emacsclient -e '(set-frame-name \"STOLEN\")'")
(server-force-delete)
(server-start)
(set-frame-name "SERVER")
)
@prideout
prideout / texturegen.md
Last active February 4, 2022 07:11
Papers about infinitely large textures / point sets.

Image Quilting can be used to synthesize a large texture from a tiny texture; it was coined in Efros 2001, which introduced the idea of a cutting a minimum cost path through a tile to make the seams less discernable. ("Image Transfer" is also discussed in this paper, which is less interesting to me.)

Wang Tiles were popularized in Cohen 2003. These make it possible to apply image quilting over an infinite region, by baking out a small set of orientable tiles. (They can also be used for generating maze-like structures, which is somewhat orthogonal to the image quilting stuff.)

Wang Tiles can also be used to generate aperioidic tilings of blue noise (or point samples), and they can even be applied in a recursive manner, which allows for infinite zoom; see Kopf 2006, as well as [this excelle

@prideout
prideout / ScopeExit.cpp
Created December 1, 2015 05:52
automatically execute code when the scope ends
template <typename F>
struct ScopeExit {
ScopeExit(F f) : f(f) {}
~ScopeExit() { f(); }
F f;
};
template <typename F>
ScopeExit<F> MakeScopeExit(F f) {
return ScopeExit<F>(f);