factory_boy allows you to define attributes as sequences, e.g.:
class MyFactory(factory.Factory):
id = factory.Sequence(lambda n: "ID%s" % n)
By default, the sequence type is a str
.
#import <Foundation/Foundation.h> | |
@interface MyManager : NSObject { | |
NSString *someProperty; | |
} | |
@property (nonatomic, retain) NSString *someProperty; | |
+ (id)sharedManager; | |
<!DOCTYPE html> | |
<html lang="en-GB"> | |
<head> | |
<title>iTunes slider</title> | |
<link rel="stylesheet" href="style.css" type="text/css" /> | |
<script type="text/javascript" src="js/jquery.js"></script> | |
<script type="text/javascript" src="js/slider.js"></script> | |
</head> |
#include <stdio.h> | |
#include <sqlite3.h> | |
int main(void) | |
{ | |
sqlite3 *db; | |
sqlite3_stmt *stmt; | |
sqlite3_open("expenses.db", &db); |
A little test of sqlite3 thread safety across multiple processes. | |
Ensure sqlite is built with: | |
#define SQLITE_THREADSAFE 1 | |
poll.c will create database and table if necessary and start polling for inserts. | |
writer.c will insert the current time into the db once every second. | |
TimerQueue code borrowed from: |
Example of how to use Windows Platform SDK shared memory functions between C and C#. | |
Code borrowed from: | |
http://www.albahari.com/nutshell/ch22.aspx | |
http://msdn.microsoft.com/en-us/library/windows/desktop/aa366551(v=vs.85).aspx |
A dirty little script to grab performance stats from Rails production.log file. | |
To speed up I recommend grep'ing out relevant lines: | |
egrep ('Started'|'Completed') production.log > output.txt | |
Will give you a CSV file which you can quickly plot in Excel. |
Before doing the initial setup, grab the following from apt-get: | |
$ sudo apt-get install zlib1g-dev openssl libopenssl-ruby1.9.1 libssl-dev libruby1.9.1 libreadline-dev git-core | |
Head over to: | |
http://octopress.org/docs/setup/ | |
Install rbenv as described: | |
cd | |
git clone git://github.com/sstephenson/rbenv.git .rbenv |
Looking into how to retrieve SMS archives from iOS 6. | |
Useful resources: | |
http://lasc.livejournal.com/284909.html | |
To explain the datetime mangling: | |
"The timestamps are not traditional timestamps of the number of seconds from 1/1/1970, but are instead based on the number of seconds from 1/1/2001 (so, there is a 31 year offset). So, we have to add the number of seconds in 31 years (978264705) to the timestamp to change it to a traditional timestamp giving the number of seconds from 1/1/1970." | |
Query below will pull a history of all message to and from the PHONE NUMBER specified. |
# Store the current locale | |
default_loc = locale.getlocale() | |
# Swap to some foreign locale, e.g. German | |
locale.setlocale(locale.LC_ALL, 'de_DE') | |
# Define a new localeconv() with some overrides | |
# see http://docs.python.org/2/library/locale.html#locale.localeconv | |
def _temp_localeconv(lc=locale.localeconv()): | |
lc.update({'decimal_point': ',', 'thousands_sep': '.'}) |