Skip to content

Instantly share code, notes, and snippets.

@iivvoo
iivvoo / gist:1216877
Created September 14, 2011 15:30
queue stress testing
from google.appengine.ext import webapp
from google.appengine.ext import db
from google.appengine.api.taskqueue import Task, Queue
from google.appengine.ext import deferred
import datetime
import random
def generate_random(l=8):
@iivvoo
iivvoo / migrate_filer.py
Created July 12, 2012 11:41
migrate "traditional" image fields to FilerImageField
# encoding: utf-8
from django.core.management.base import BaseCommand
##
## FancyImageModel is a plugin model holding a ImageField called "oldimage" and
## FilerImageField "image". It removed duplicates based on the basename of the original
## image. This may or may not work for you.
from imageplugin.models import FancyImageModel
@iivvoo
iivvoo / gist:3349141
Created August 14, 2012 13:13
opposite axes
def test_opposites(self):
""" "scores" may contain values for opposite attribute values -
make sure the winner wins """
scores = {'Realistic': [8],
'Investigative': [7],
'Artistic': [6],
'Social': [2],
'Enterprising': [1],
'Conventional': [3]}
@iivvoo
iivvoo / gist:6824444
Created October 4, 2013 11:20
django-simple-captcha configuration
CAPTCHA_FONT_SIZE=30
CAPTCHA_NOISE_FUNCTIONS = ('captcha.helpers.noise_dots',)
CAPTCHA_LETTER_ROTATION = (-10,10)
from wheelcms_axle.auth import lr, local_roles
from quanza_ci.organization import OrganizationType, Membership
from quanza_ci.roles import employee
def org_lr(obj, request=None):
if Membership.objects.filter(user=request.user, organization=obj.instance).exists():
return [employee]
return []
lr.register(local_roles, [OrganizationType], org_lr)
@iivvoo
iivvoo / keybase.md
Last active August 29, 2015 14:00
keybase.md

Keybase proof

I hereby claim:

  • I am iivvoo on github.
  • I am iivvoo (https://keybase.io/iivvoo) on keybase.
  • I have a public key whose fingerprint is 3605 78AB 672C F459 3972 B796 9A30 7449 CF67 40A8

To claim this, I am signing this object:

old-style
- name: Run buildout {{buildout}}
command: $venv/bin/buildout -N -c $buildout
chdir=$dest
new-style with {{}}
- name: Run buildout {{buildout}}
command: "{{venv}}/bin/buildout -N -c {{buildout}}"
{"error":"{{case_clause,{{badmatch,{error,eacces}},\n [{couch_file,init,1,[{file,\"couch_file.erl\"},{line,314}]},\n {gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,304}]},\n {proc_lib,init_p_do_apply,3,\n [{file,\"proc_lib.erl\"},{line,239}]}]}},\n [{couch_server,handle_info,2,[{file,\"couch_server.erl\"},{line,442}]},\n {gen_server,handle_msg,5,[{file,\"gen_server.erl\"},{line,604}]},\n {proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,239}]}]}","reason":"{gen_server,call,\n [couch_server,\n {open,<<\"dick_cdb\">>,\n [{user_ctx,\n {user_ctx,null,\n [<<\"_admin\">>],\n <<\"{couch_httpd_auth, default_authentication_handler}\">>}}]},\n infinity]}"}
class EmberDateField(serializers.DateField):
def to_internal_value(self, value):
value = value.split('T', 1)[0]
return super().to_internal_value(value)
def to_representation(self, value):
res = super().to_representation(value)
# XXX This is a hack - assumes CET timezone, which is 1 hour
import time
import pprint
from empyrean.api import IPCAPI
from keys import address, passphrase
api = IPCAPI("/home/ivo/.ethereum/geth.ipc")
res = api.personal.unlockAccount(address, passphrase)