Skip to content

Instantly share code, notes, and snippets.

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

# First add a rule for all local traffic to port 80 to go into pipe 1
# 100 is the rule number which will be used for referencing the rule later
sudo ipfw add 100 pipe 1 ip from 127.0.0.1 to 127.0.0.1 dst-port http
# To display the rule use
# sudo ipfw show 100
# configure the settings of the pipe as you please
# 50kbit/s bandwidth
sudo ipfw pipe 1 config bw 50Kbit
# 200ms lag
@rozza
rozza / SomeAbstractClass.java
Created July 11, 2014 11:24
Abstract class with a static member that can't be called
package org.example;
public abstract class SomeAbstractClass {
SomeAbstractClass(){}
/**
* The name of the SomeAbstractClass instance.
*
* @return the name
diff --git a/README.md b/README.md
index 713bf92..6747aaa 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ monocle straightens out event-driven code using Python's generators.
It aims to be portable between event-driven I/O frameworks, and
currently supports Twisted and Tornado.
-It's for Python 2.5 and up; the syntax it uses isn't supported
+It's for Python 2.5 and up (pre 2.7 builds require orderedict); the syntax it uses isn't supported
@rozza
rozza / runner.py
Created July 30, 2010 14:25
saves and restores sys.stdout
import sys
class ResultPlugin(object):
"""
Captures the TestResult object for later inspection.
nose doesn't return the full test result object from any of its runner
methods. Pass an instance of this plugin to the TestProgram and use
``result`` after running the tests to get the TestResult object.
"""
from django.conf import settings
from django.http import HttpResponseRedirect
def secure_required(func):
"""
Decorator makes sure URL is accessed over https.
Use with `SecureRequiredMiddleware` to ensure only decorated urls are
accessed via https
"""
def wrap(request, *args, **kwargs):
from django.http import HttpResponseRedirect
class SecureRequiredMiddleware(object):
def process_response(self, request, response):
"""
Ensures that any non decorated secure_required urls redirect if accessed
via https (only GET requests returning 200's are redirected to HTTP urls)
"""
@rozza
rozza / (ab)using fixtures in migrations
Created October 13, 2010 09:10
An example of using fixtures in south migrations
from django.core import serializers
widgets = serializers.deserialize('json', open('widget/fixtures/widgets.json'))
for widget_data in widgets:
widget = orm.Widget()
for k,v in widget_data.object.__dict__.items():
if k.startswith('_'):
continue
setattr(widget, k, v)
widget.save()
@rozza
rozza / gist:968114
Created May 12, 2011 07:44
current_user proxy for flask example
from flask import session, g
current_user = LocalProxy(get_user) # Global access to the current user
def get_user():
"""
A proxy for the User model
Is used as a `LocalProxy` so is context local.
Uses the `g` object to cache the `User` instance which prevents
@rozza
rozza / django_template_test.py
Created May 18, 2011 07:50
mongoengine/issues/166
# -*- coding: utf-8 -*-
from django.conf import settings
import unittest
from mongoengine import *
from django.template.defaultfilters import length
from django.template import Context, Template