This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
import base64 | |
import threading | |
import Queue | |
import simplejson as json | |
from datetime import datetime | |
from dateutil import parser | |
# authentication stuff | |
username = 'username' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 = ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
====================================================== | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 = ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
OlderNewer