Skip to content

Instantly share code, notes, and snippets.

@campaul
campaul / gist:71f32a577fe39c388c31
Last active August 29, 2015 14:09
Potential Octave Stack Operations

Interrupt State

000 00 : HALT (wait for interrupt)
000 01 : IDT[HIGH] <- R0
000 10 : IDT[LOW] <- R0
000 11 : IENABLE <- R0 // 1 bit for each device, so IENABLE 0 disables interrupts

Function Operations

001 00 : CALL
001 01 : RET
001 10 : TRAP

@campaul
campaul / gist:56ec0703428e5f644291
Created December 10, 2014 00:06
Potential Distro JSON Format
distros = {
'Ubuntu': {
'12.04': {
'Desktop': {
'i386': {
'DVD': {
'torrent': 'foo',
'magnet': 'bar',
'direct': 'baz',
'project': 'quux'
@campaul
campaul / gist:983ce9daee4b6fb1057a
Created January 10, 2015 05:08
What the import function looks like now
def import_photos(self, path, notify=None, imported=None,
copy_photos=True, delete_originals=False):
photo_list = self.discover(path)
progress = Progress(len(photo_list))
for photo in photo_list:
if notify:
notify(os.path.basename(photo.raw_path))
## this...
original_filename = os.path.basename(
os.path.splitext(photo.raw_path)[0]
)
file_ext = os.path.splitext(photo.raw_path)[1]
## could be...
file_name, file_ext = os.path.splitext(os.path.basename(photo.raw_path))
Python 3.4.2 (default, Jan 12 2015, 11:38:40)
[GCC 4.9.2 20141224 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def foo(x=[]):
... x.append('1')
... return x
...
>>> foo()
['1']
>>> foo()
@campaul
campaul / game.go
Created March 6, 2015 04:42
Centered player example
package main
import (
"fmt"
"github.com/nsf/termbox-go"
)
func tbPrint(x, y int, fg, bg termbox.Attribute, msg string) {
for _, c := range msg {
termbox.SetCell(x, y, c, fg, bg)
@campaul
campaul / mason_jar_port_tube.js
Last active August 29, 2015 14:17
Mason Jar Port Tube
function main() {
return union(
// The tube
difference(
cylinder({r:16, h:28, fn:100}),
cylinder({r:15, h:28, fn:100})
),
// The flange
difference(
cylinder({r:20, h:2, fn:100}),
import mock
print(mock.MagickMock() == mock.ANY)
print(mock.ANY == mock.MagickMock())
@campaul
campaul / gtk_example.py
Last active August 29, 2015 14:27
Off main thread GTK example
# Inverted version of the first example from https://wiki.gnome.org/Projects/PyGObject/Threading
# GTK runs in the spawned thread instead of the other way around.
import threading
import time
from gi.repository import GLib, Gtk, GObject
# yay hacks
@campaul
campaul / resume.tex
Last active October 2, 2015 23:37
LaTeX source for my resume.
\documentclass[margin, 11pt]{res}
\usepackage{enumitem}
\usepackage{setspace}
\setlength{\oddsidemargin}{-.125in}
\setlength{\topmargin}{-.125in}
\setlength{\textheight}{10in}
\begin{document}