Skip to content

Instantly share code, notes, and snippets.

View jemerick's full-sized avatar

Jason Emerick jemerick

View GitHub Profile
package org.hamberry.util;
import net.rim.device.api.servicebook.ServiceBook;
import net.rim.device.api.servicebook.ServiceRecord;
import net.rim.device.api.system.DeviceInfo;
import net.rim.device.api.system.EventLogger;
public class NetworkConfig
{
private static Logger log = Logger.getInstance();
@jemerick
jemerick / spritzer.py
Created June 9, 2009 00:30
spritzer sample code
import urllib2
import base64
import threading
import Queue
import simplejson as json
from datetime import datetime
from dateutil import parser
# authentication stuff
username = 'username'
int mh = CodeModuleManager.getModuleHandle("GoogleMaps");
if (mh == 0) {
throw new ApplicationManagerException("GoogleMaps isn't installed");
}
URLEncodedPostData uepd = new URLEncodedPostData(null, false);
uepd.append("action","LOCN");
uepd.append("a", "@latlon:"+l.getLatitude()+","+l.getLongitude());
uepd.append("title", l.getName());
uepd.append("description", l.getDescription());
String[] args = { "http://gmm/x?"+uepd.toString() };
# Load custom template tags in all templates
# Custom template tags that you use all over your templates can be auto loaded. Just add the following in a module that is # loaded (i.e. your urlconf if you want the template tags to be loaded for the whole project)
from django import template
template.add_to_builtins('project.app.templatetags.custom_tag_module')
# relative paths
import os.path
TEMPLATE_DIRS = (
# In-memory Cassandra-ish thingy... useful for unit tests. Maybe useful for other
# stuff too? No support for SuperColumns, but that should be easy enough to add.
import bisect
import copy
from cassandra.ttypes import NotFoundException, Column, ColumnPath, ColumnOrSuperColumn
class SSTable(object):
======================================================
Setting up Django using Apache/mod_wsgi on Ubuntu 8.10
======================================================
This article will cover setting up Django using Apache/mod_wsgi on Ubuntu
8.10. The article is targeted at a production environment, but keep in mind
this is a more generalized environment. You may have different requirements,
but this article should at least provide the stepping stones.
The article will use distribution packages where nesscary. As of 8.10 the
"""
Some simple utilities to read the magic bytes from the beginning of a
file and determine whether the file meets certain criteria (e.g., contains
JPEG image data).
"""
import array
from operator import eq
IMAGE_MAGIC_DATA = (
"""
Simple timer class. Example usage:
t = Timer()
for url in ('http://www.google.com/', 'http://www.yahoo.com/'):
t.start('fetch url')
content = urllib.urlopen(url).read()
t.stop('fetch url')
t.start('reorder bytes')
bytes = list(content)
// To open up a gallery browser
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),1);
// To handle when an image is selected from the browser, add the following to your Activity
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
// create a spannable string
SpannableString spanstring = new SpannableString("bold\ntumblelog");
// make the first 4 chars bold
spanstring.setSpan(new StyleSpan(Typeface.BOLD), 0, 4, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
// set the text of the button
sendButton.setText(spanstring);