Skip to content

Instantly share code, notes, and snippets.

View startling's full-sized avatar

Lizzie Dixon startling

View GitHub Profile
@startling
startling / error
Created December 27, 2011 01:38
Errors when you `cytoplasm test` under python 3.
^CProcess Process-1:
Traceback (most recent call last):
File "/Users/tim/.pythonbrew/pythons/Python-3.2/lib/python3.2/multiprocessing/process.py", line 259, in _bootstrap
self.run()
File "/Users/tim/.pythonbrew/pythons/Python-3.2/lib/python3.2/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "/Users/tim/Code/cytoplasm_dir/cytoplasm/cytoplasm/server.py", line 81, in serve
httpd.handle_request()
File "/Users/tim/.pythonbrew/pythons/Python-3.2/lib/python3.2/socketserver.py", line 265, in handle_request
fd_sets = select.select([self], [], [], timeout)
@startling
startling / test.py
Created December 27, 2011 01:40
2to3's changes to cytoplasm.test
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
RefactoringTool: Refactored test.py
--- test.py (original)
+++ test.py (refactored)
@@ -1,4 +1,4 @@
-import os, imp, shutil, urllib2
+import os, imp, shutil, urllib.request, urllib.error, urllib.parse
@startling
startling / gist:1522529
Created December 27, 2011 01:51
`cytoplasm test` errors, even after workaround
.....localhost - - [26/Dec/2011 19:48:50] "GET /one.html HTTP/1.1" 200 -
FTraceback (most recent call last):
File "/Users/tim/.pythonbrew/pythons/Python-3.2/lib/python3.2/socketserver.py", line 284, in _handle_request_noblock
self.process_request(request, client_address)
File "/Users/tim/.pythonbrew/pythons/Python-3.2/lib/python3.2/socketserver.py", line 310, in process_request
self.finish_request(request, client_address)
File "/Users/tim/.pythonbrew/pythons/Python-3.2/lib/python3.2/socketserver.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Users/tim/.pythonbrew/pythons/Python-3.2/lib/python3.2/socketserver.py", line 639, in __init__
self.handle()
@startling
startling / gist:1725692
Created February 2, 2012 20:53
errors when installing vim from homebrew-alt
~ » brew install --verbose https://raw.github.com/adamv/homebrew-alt/master/duplicates/vim.rb
/usr/bin/curl -qf#LA Homebrew 0.8.1 (Ruby 1.8.7-249; Mac OS X 10.6.8) https://raw.github.com/adamv/homebrew-alt/master/duplicates/vim.rb -o /Users/tim/Library/Caches/Homebrew/Formula/vim.rb
######################################################################## 100.0%
/usr/local/bin/hg
==> Cloning https://vim.googlecode.com/hg/
Updating /Users/tim/Library/Caches/Homebrew/vim--hg
hg pull
warning: vim.googlecode.com certificate with fingerprint e9:f0:26:b1:ff:27:28:33:81:8e:51:7b:fd:a7:de:df:4c:1e:ee:14 not verified (check hostfingerprints or web.cacerts config setting)
pulling from https://vim.googlecode.com/hg/
searching for changes
def test():
for x in range(10):
def func():
print x
yield func
for f in test():
f()
@startling
startling / gist:1841257
Created February 16, 2012 02:57
toy lispy parser
#!/usr/bin/env ruby
require 'parslet'
class Lispy < Parslet::Parser
rule(:integer) { match('[0-9]').repeat(1) }
rule(:literal) { integer }
rule(:identifier) { match('[^0-9\'"]') >> match('.').repeat(0)}
rule(:atom) { identifier | literal }
rule(:spaces) { match('\s').repeat(1) }
@startling
startling / gist:1858281
Created February 18, 2012 08:44
constructing linked lists iteratively!
# the list so far; `tail` because we're starting at the end.
# None represents the empty list for now
tail = None
items = range(4)
# iterate through `items` backwards
for item in items[::-1]:
tail = (item, tail)
; ModuleID = 'plusequals.c'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.6.8"
define i32 @main(i32 %argc, i8** %argv) nounwind uwtable ssp {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
%3 = alloca i8**, align 8
store i32 0, i32* %1
store i32 %argc, i32* %2, align 4
@startling
startling / colors.py
Created March 11, 2012 06:08
Display 256 colors in your terminal, if it supports it.
import sys
for i, n in enumerate(xrange(232)):
# for each color, print two spaces with that background
sys.stdout.write("\x1b[48;5;%dm " % n)
# and then back to the default color
sys.stdout.write("\x1b[49m")
# every 6 numbers after the first three,
@startling
startling / scoping.io
Created March 14, 2012 02:59
playing with io's do()
# so, because of scoping inside of do(...) I have to do:
Color greyscale := method(
i := intensity
grey := Color clone
grey red := i
grey blue := i
grey green := i
return grey
)