This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate iron; | |
use iron::prelude::*; | |
macro_rules! response { | |
( $( $x:expr ),* ) => { | |
{ | |
Ok(Response::with(($( | |
$x, | |
)*))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generates a new unique filename if the provided filename already exists, | |
# otherwise just return the provided filename. | |
# Usage: python unique.py name/of/file | |
import os | |
import sys | |
def increment(filename): | |
last = filename.split()[-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Simple HTTP proxy in Rust. Hard coded to proxy rust-lang.org. | |
*/ | |
extern crate hyper; | |
use std::io::Read; | |
use hyper::Client; | |
use hyper::header::Connection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Samples a color from the screen and prints the hex value to the terminal. | |
# Usage: `python color_picker.py` and then click somewhere to sample. | |
from gi import require_version | |
require_version('Gdk', '3.0') | |
require_version('Gtk', '3.0') | |
from gi.repository import Gdk | |
from gi.repository import Gtk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mock | |
print(mock.MagickMock() == mock.ANY) | |
print(mock.ANY == mock.MagickMock()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file was my first attempt at using libraw with ctypes. For a more | |
# complete project check out https://github.com/photoshell/rawkit | |
# Usage: python raw_develop.py some/raw/file.cr2 some/destination/file.ppm | |
from ctypes import * | |
import sys | |
libraw = cdll.LoadLibrary('libraw.so.10') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
NewerOlder