I hereby claim:
- I am stevejalim on github.
- I am stevejalim (https://keybase.io/stevejalim) on keybase.
- I have a public key whose fingerprint is B2A9 6BCD F133 CD6B 4CE6 087E EEE6 B419 4EB8 B898
To claim this, I am signing this object:
import imp | |
from functools import partial | |
from mock.mock import _patch, _get_target, DEFAULT | |
class PatchWithReload(_patch): | |
def __init__(self, module_to_reload, *args, **kwargs): | |
self.module_to_reload = module_to_reload | |
super(PatchWithReload, self).__init__(*args, **kwargs) |
""" | |
Utilities for working with bulk data and batches. | |
""" | |
import itertools | |
def batches(items, batch_size=500): | |
""" | |
Given an iterable of items and a batch size, yield individual lists | |
of items of maximum length `batch_size`. |
I hereby claim:
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
This is a simple python script that can be used to 'listen' to the Twitter Stream API, tracking certain words, and then forwarding those on to HipChat.
It's useful if you spend a lot of time in HipChat, and want to monitor tweets at the same time.
You'll need to set up a Twitter application, and also get a valid oauth token using that app - go to https://apps.twitter.com/app/new and follow the
### Keybase proof | |
I hereby claim: | |
* I am stevejalim on github. | |
* I am stevejalim (https://keybase.io/stevejalim) on keybase. | |
* I have a public key whose fingerprint is 3051 A182 1392 3039 6FC5 C71B CFAE A0DF 26AF C63D | |
To claim this, I am signing this object: |
// How to upgrade your users passwords in the DB without their intervention | |
// | |
// SHA-1 isn't strong enough to hash passwords with, but lots of people have a | |
// whole bunch of SHA-1'd passwords because they thought it was. You could use | |
// bcrypt or scrypt, but maybe in two years' time someone will tell you that's | |
// also not strong enough, and you'll want to upgrade. | |
// | |
// This sample demonstrates how you can remove weak password hashes from your | |
// user database, without needing the user to enter their password. |
Best practice summary | |
================== | |
1. Always use orm when referencing models if you add data migration code to a schemamigration or do a datamigration. | |
2. If using a feature branch, do the migration on the develop branch and merge it into the feature branch if that migration is safe to do on develop (e.g. adds a new model or a benign field) with minimal code changes. This will avoid the need to do out-of-sequence merging. | |
3. If you have to do the migration on the branch claim the next migration number and, as usual, let the other developers know it's yours. | |
4. After finishing the feature if no higher numbered migrations exist on develop you can just do a normal migrate. | |
5. If there are higher numbered migrations: | |
a. do a migrate with the --merge flag | |
b. do a schemamigration with the --empty flag | |
6. Continue with schemamigrations as normal using the --auto flag |
import re | |
from django import forms | |
def validate_CSS_color(value): | |
"""Checks the value is a valid CSS hex colour string""" | |
hit = re.match("(?i)^#([0-9a-f]{3}|[0-9a-f]{6})$", value) | |
return bool(hit) |
import re | |
from django import forms | |
def is_password_strong_enough(value): | |
""" | |
"All passwords should be: | |
10+ characters long | |
contain at least one upper-case character | |
contain at least one lower-case character | |
contain at least one numeric digit |