Skip to content

Instantly share code, notes, and snippets.

View jsok's full-sized avatar

Jonathan Sokolowski jsok

  • Sydney, Australia
  • 17:50 (UTC +11:00)
View GitHub Profile
#import <Foundation/Foundation.h>
@interface MyManager : NSObject {
NSString *someProperty;
}
@property (nonatomic, retain) NSString *someProperty;
+ (id)sharedManager;
@jsok
jsok / slider.html
Created May 25, 2011 01:09
Simple jquery slider
<!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>
@jsok
jsok / sqlite3_test.c
Created June 15, 2012 14:34
sqlite3 C example
#include <stdio.h>
#include <sqlite3.h>
int main(void)
{
sqlite3 *db;
sqlite3_stmt *stmt;
sqlite3_open("expenses.db", &db);
@jsok
jsok / README
Created June 18, 2012 13:18
SQLite3 multithreaded example
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:
@jsok
jsok / README
Created June 27, 2012 01:56
Shared memory on Windows Platform SDK
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
@jsok
jsok / README
Created July 2, 2012 00:47
RoR log parser
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.
@jsok
jsok / README
Created September 28, 2012 03:46
Octopress on Debian
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
@jsok
jsok / README
Created October 4, 2012 04:36
iOS 6 SMS database dumping
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.
@jsok
jsok / README.md
Created December 7, 2012 12:50
factory_boy Sequence customisation

factory_boy Sequence

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.

@jsok
jsok / locale_hack.py
Created February 3, 2013 06:03
A little hack to switch locales and override some locale conventions temporarily.
# 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': '.'})