Skip to content

Instantly share code, notes, and snippets.

View ento's full-sized avatar

ento

View GitHub Profile
@ento
ento / test
Created June 27, 2013 12:15
clone & push test
initial version
# -*- coding: utf-8 -*-
import threading
from nose.tools import eq_
import celery
from celery._state import _get_current_app
eq_('3.0.22', celery.__version__)
eq_('default', _get_current_app().main)
@ento
ento / index.html
Last active July 25, 2016 00:40
Userstyle bookmarklet maker
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="./style.css"/>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.1/underscore-min.js"></script>
</head>
<body>
<div class="form-group">
@ento
ento / gist:6375397
Created August 29, 2013 08:04
Iterate through logs captured by nosetest's logcapture plugin
import logging
from nose.plugins import logcapture
def iter_captured_logs(pluck=None):
handler = get_nose_log_handler()
# need to call `format` in order to let it compose the `message` attr for us
format = handler.format
for r in handler.buffer:
format(r)
#!/bin/bash -e
# These need to be set.
#export EC2_HOME="/path/to/ec2-api-tools"
#export AWS_ACCESS_KEY='XXXXXXXXXXXXXXXXXXXX'
#export AWS_SECRET_KEY='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
#export PATH="$PATH:${EC2_HOME}/bin"
ami_id='ami-123abc12'
availability_zone='eu-west-1a'
keypair="[email protected]"
@ento
ento / print_addressbook_members.py
Last active September 30, 2017 17:38
Print some properties of members of your Mac AddressBook.
# -*- coding: utf-8 -*-
'''
Print some properties of members of your Mac AddressBook.
https://developer.apple.com/library/mac/documentation/userexperience/Reference/AddressBook/Miscellaneous/AddressBook_Constants/Reference/reference.html#//apple_ref/doc/uid/TP40003952-CH3g-SW6
$ pip install -U pyobjc-core
$ pip install -U pyobjc
'''
from collections import OrderedDict
from Foundation import NSDate, NSDateFormatter
@ento
ento / gist:6696347
Created September 25, 2013 07:44
is_picklable(obj)
import cPickle as pickle
def pickle_recursively(obj, depth=0):
pad = ' ' * depth
if isinstance(obj, dict):
print pad, 'dict', obj.__class__
for k, v in obj.iteritems():
print pad, k
pickle_recursively(v, depth + 1)
@ento
ento / test_serialization.py
Last active December 23, 2015 21:29
Test result serialization when CELERY_ALWAYS_EAGER = True
# -*- coding: utf-8 -*-
import cPickle as pickle
from nose.tools import *
from celery import Celery
celery = Celery()
celery.conf.CELERY_ALWAYS_EAGER = True
@ento
ento / gist:6727935
Created September 27, 2013 12:35
Remove ruby tag
sed -i 's/<ruby>\([^<]\+\)<rp>[^<]\+<\/rp><rt>[^<]\+<\/rt><rp>[^<]\+<\/rp><\/ruby>/\1/g' text/*.html
@ento
ento / fv-demo.txt
Created October 22, 2013 11:02
emacs evals useful for demonstrating FV: highlights lines beginning with a dot.
# Local Variables:
# eval: (hi-lock-mode 1);
# eval: (unhighlight-regexp "^.*\\(?:^\\.\\).*$");
# eval: (highlight-lines-matching-regexp "^\\." 'hi-yellow);
# eval: (text-scale-adjust 7);
# eval: (end-of-buffer);
# End:
-------------------------------