Skip to content

Instantly share code, notes, and snippets.

- can we still end up with the stores window coming up too soon?
- fuzzy ranking and cutoff of tag suggestions
- fulltext-based suggestions
- choose *fastest* store in multiplex for read, not *master*
- when accessing slave store, display as read-only and have menu item to emancipate store
-> consequence: master store on s3, slave stores locally for caching and offline access
- per-session global undo/redo - so we can undo the "oh shit I did not mean to do that" moments
- we do really want a comment field, methinks
- change "delete original" to "store a copy", reverse polarity
- make loading store configs from prefs much more robust: individual store config load faults should be insulated, and less verification at config load time - so what if it references a nonexistent folder
@MetalBeetle
MetalBeetle / multipart.py
Created January 28, 2011 20:11
_parse_stream is a generator that produces (name, data, header-dict) tuples. Needs a bit of wrapping to get the stream from the environment, but otherwise done. Doesn't really do any error handling yet.
"""Parser for multipart/form-data."""
import re
import tempfile
import os
class RequestFile:
"""
An uploaded file.
@MetalBeetle
MetalBeetle / particles.py
Created February 2, 2011 13:17
Simulates particles bonking into one another in a hilariously inefficient O(n^2) way. Dependencies: numpy, scipy, pygame
import pygame
import math
import numpy
import random
import scipy
import scipy.spatial
SCREEN_SIZE = 300
clock = pygame.time.Clock()
screen = pygame.display.set_mode((SCREEN_SIZE, SCREEN_SIZE))#, pygame.FULLSCREEN)
<form action="somewhere" method="POST">
<!-- single <input type="text"> row -->
{% render forms.text_row("name", name) %}
<!-- single <input type="text"> row driven by model -->
{% render forms.model_row(model, "name") %}
<!-- entire model as a form -->
{% render forms.model_form(model) %}
</form>
Started up flow development server on port 8000.
Traceback (most recent call last):
File "/Users/zar/Python/flow/utils/template/parser.py", line 201, in parse_template_chunk
node = macro(self, token_contents)
File "/Users/zar/Python/flow/utils/template/macros.py", line 16, in wrapper
return func(parser, *match.groups(), **match.groupdict())
File "/Users/zar/Python/flow/utils/template/macros.py", line 45, in render_macro
return partial(render_node, Expression(expression))
File "/Users/zar/Python/flow/utils/template/parser.py", line 89, in __init__
self.compiled_expression = compile(expression, "<string>", "eval")
Started up flow development server on port 8000.
Traceback (most recent call last):
File "/Users/zar/Python/flow/utils/template/parser.py", line 160, in render_node
return node(params)
File "/Users/zar/Python/flow/utils/template/macros.py", line 110, in for_node
return "".join(map(process_item, items))
File "/Users/zar/Python/flow/utils/template/macros.py", line 107, in process_item
name.set(params, item)
File "/Users/zar/Python/flow/utils/template/parser.py", line 76, in set
raise ValueError("Need more that {} values to unpack.".format(len(self.names)))
@MetalBeetle
MetalBeetle / InvadersMustDie.java
Created March 1, 2011 09:01
A tiny invaders game that fits into 1kB of pack200 jar file.
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferStrategy;
import java.util.Random;
import javax.swing.JApplet;
@MetalBeetle
MetalBeetle / Moo4k.java
Created March 1, 2011 09:06
A tiny space strategy game I wrote for the Java4k competition. Can be played at http://www.java4k.com/index.php?action=games&method=view&gid=325 .
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
@MetalBeetle
MetalBeetle / Main.java
Created March 24, 2011 16:17
BufferedOutputStream Considered Harmful
package bufferedoutputstreamtest;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* Contrary to what you'd expect, this runs with no exception thrown.
* Thanks, BufferedOutputStream!
*/
@MetalBeetle
MetalBeetle / unreliable-swing-modal-dialog-show-hide.java
Created October 17, 2010 16:21
Unreliable Swing modal dialog show/hide, about 1 in 4 times the window stays visible
// This is supposed to show a modal dialog and then hide it again. In practice,
// this works about 75% of the time, and the other 25% of the time, the dialog
// stays visible.
// This always prints
// setVisible(true) about to happen
// setVisible(false) about to happen
// setVisible(false) has just happened
// even when the dialog stays visible.
package modalproblemdemo;