Android Dev Phone 1 – AT&T

I received my Android Dev Phone 1 today and wanted to report that with the following APN settings it works great (setup instructions come with the phone).

Name: AT&T
APN: wap.cingular 
Proxy: <Not set>
Port: <Not set>
Username: wap.cingulargprs.com 
Password: CINGULAR1 
Server: <Not set>
MMSC: mmsc.cingular.com 
MMS proxy: <Not set>
MMS port: 80 
MCC: 310
MNC: 410
APN type: <Not set>

Source Jackson Miller

Adroid Dev Phone 1

I just ordered the Adroid Dev Phone 1, an unlocked Android device available through the Developer Console.

Front - Open Front - Closed Back Side - Left Side - Right Profile - Open Profile - Closed

Price: $399.00 USD

Overview

Run and debug your Android applications directly on a device. Modify and rebuild the Android operating system, and flash it onto a phone. The Android Dev Phone 1 is carrier independent, and available for purchase by any developer registered with Android Market.

Development Platform Features

  • SIM unlocked - Put any SIM in the device
  • Hardware unlocked - Rebuild the Android operating system, and load it onto the device
  • Test out your apps on real hardware before publishing them to the world

Hardware Features

  • Touch screen
  • Trackball
  • 3.2 Megapixel camera with auto focus
  • Wi-Fi
  • Bluetooth v2.0
    • Handsfree profile v1.5
    • Headset profile v1.0
  • 3G WCDMA (1700/2100 MHz)
  • Quad-band GSM (850/900/1800/1900 MHz)
  • QWERTY slider keyboard
  • Includes 1GB MicroSD card (Can be replaced with up to 16GB card)
  • Included in the box
    • HTC Android Dev Phone 1
    • USB Cable
    • AC Adapter (with US plug)
    • Stereo Hands-Free Headset
    • Battery
    • Getting Starting Guide
    • 1G Micro SD Card (inserted into Device)

Software Features

  • Real web browsing
  • Customizable home screen
  • One-touch Google Search
  • Android Market
  • Full-featured Google applications:
    • Google Maps
    • Gmail
    • YouTube
    • Google Calendar
    • Google Talk
  • SMS and MMS
  • Music Player

IPython + Python: Single Bash Command

The following is a simple Bash function you can paste into your bashrc file to start Python/IPython depending on the context.

~/.bashrc

function python {
    IPYTHON="/usr/bin/ipython"
    PYTHON="/usr/bin/python"

    if [[ -n $1 ]]; then
        $PYTHON $@
    elif [[ -e $IPYTHON ]]; then
        $IPYTHON
    else
        $PYTHON
    fi
}

Push: Func Module to Run Arbitrary Python Code

Func is a nifty, although not yet polished, Python-based service for running tasks on many hosts at once. It lets you do things like restart Apache instances, run yum updates or provision virtual machines.

You can accomplish theses tasks via the command line interface

func web-*.example.net call service restart httpd

or through the Python API

import func.overlord.client as fc

client = fc.Client('web-*.example.net')

print client.service.restart('httpd')

One of the annoying issues I'm dealing with right now is the distribution of Func modules, which for various reasons isn't as simple as packaging the modules and pushing them to all the hosts (it is, just not in my network).

My solution is Push, a Func module which lets you instantly run Python code on any or all hosts in your network.

Example usage:

import func.overlord.client as fc

client = fc.Client('web-*.example.net')

source = """
def main():
    return 'Hello World'
"""

print client.push.code(source)

I realize this isn't the most elegant solution, but its very useful and extremely simple.

I also realize that I could use the copyfile module to push modules via Func, but I haven't found a way to restart funcd via Func (required to initialize modules), so until that happens I need a solution which doesn't require restarting Func.

Get Push Module

Adobe Flash 10 64-bit SPEC File for Fedora 9

I hacked up a quick SPEC file for the alpha release of Adobe Flash 10 64-bit for Linux.

Name:           adobe-flash
Version:        10.0.d20.7
Release:        1%{?dist}
Summary:        Adobe Flash player.

Group:          Application/Internet
License:        Proprietary
URL:            http://labs.adobe.com/technologies/flashplayer10/
Source0:        http://download.macromedia.com/pub/labs/flashplayer10/libflashplayer-10.0.d20.7.linux-x86_64.so.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildArch:      x86_64
Requires:       firefox >= 3
Requires:       mozilla-filesystem

%description
The Adobe Flash player.

%prep
%setup -T -c -a 0

%install
install -D -m 644 libflashplayer.so $RPM_BUILD_ROOT%{_usr}/lib64/mozilla/plugins/libflashplayer.so

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%{_usr}/lib64/mozilla/plugins/libflashplayer.so

%changelog
* Tue Nov 18 2008 Silas Sewell <silas@sewell.ch> - 10.0.d20.7
- Created package.

C GMP Hello World on Leopard (OS X 10.5)

A simple GMP Hello World example in C.

Makefile

all:
    gcc -o gmp_hello_world gmp_hello_world.c -lgmp -m64

clean:
    rm gmp_hello_world

gmp_hello_world.c

/*
 * GMP Hello World on OS X 10.5
*/
#include <gmp.h>
#include <stdio.h>

int main() {
  mpz_t add_total1, add_total2, sub_total1, sub_total2, mul_total1, mul_total2;
  mpz_t num1, num2;

  // Initialize variables
  mpz_init_set_str(num1, "345192567923875922375736284875732", 10);
  mpz_init_set_str(num2, "937929298382994742939293857584837", 10);
  mpz_init(add_total1);
  mpz_init(add_total2);
  mpz_init(sub_total1);
  mpz_init(sub_total2);
  mpz_init(mul_total1);
  mpz_init(mul_total2);

  // Do arithmetic
  mpz_add(add_total1, num1, num2);
  mpz_add_ui(add_total2, num1, 10);
  mpz_sub(sub_total1, num1, num2);
  mpz_sub_ui(sub_total2, num1, 10);
  mpz_mul(mul_total1, num1, num2);
  mpz_mul_ui(mul_total2, num1, 10);

  // Display results
  gmp_printf("Add Total 1: %Zd\n", add_total1);
  gmp_printf("Add Total 2: %Zd\n", add_total2);
  gmp_printf("Subtract Total 1: %Zd\n", sub_total1);
  gmp_printf("Subtract Total 2: %Zd\n", sub_total2);
  gmp_printf("Multiply Total 1: %Zd\n", mul_total1);
  gmp_printf("Multiply Total 2: %Zd\n", mul_total2);

  // Free space
  mpz_clear(num1);
  mpz_clear(num2);
  mpz_clear(add_total1);
  mpz_clear(add_total2);
  mpz_clear(sub_total1);
  mpz_clear(sub_total2);
  mpz_clear(mul_total1);
  mpz_clear(mul_total2);

  return 0;
}

Persistent Queuing in Python

Peafowl is a Python port of Ruby's Starling.

Common Usage Database (cudb)

A couple of months ago I was searching for an excuse to write an application on Google App Engine. After mucking around with the Datastore and authentication API I decided to rewrite Most Common Usage on Google App Engine.

The end result was the Common Usage Database and like Most Common Usage the website is focused on the usage of CLI commands in Linux and Unix-like operating systems.

The website uses Google for authentication so you don't need to signup if you already have a Google account. I've also setup a Google Group and the #cudb channel on Freenode.

I look forward to creating a repository of useful commands and providing an easy and open way for developers to use that repository.

Link: http://www.cudb.org/

Python SDK for PhoneFactor

A first (and very alpha) attempt at creating a Python SDK for PhoneFactor.

Link: http://github.com/silas/graveyard/tree/master/python-phonefactor/

Universal Feed Parser to JSON

My attempt at wrangling a Universal Feed Parser object into JSON.

import feedparser

def json_make_normal(obj):
    if type(obj) in [str, unicode, int, float, bool, dict, set, list, tuple]:
        return obj
    try: return dict(obj)
    except: pass
    try: return list(obj)
    except: pass
    return None

def json_handle(obj):
    obj = json_make_normal(obj)
    if type(obj) in [str, unicode]:
        obj = obj.replace('\\', '\\\\')
        obj = obj.replace('"', '\\"')
        obj = obj.replace('\b', '\\\b')
        obj = obj.replace('\f', '\\\f')
        obj = obj.replace('\n', '\\\n')
        obj = obj.replace('\r', '\\\r')
        obj = obj.replace('\t', '\\\t')
        return '"%s"' % obj
    elif type(obj) in [int, float]:
        return obj
    elif type(obj) is bool:
        if obj: return 'true'
        else: return 'false'
    elif type(obj) is type(None):
        return 'null'
    elif type(obj) is dict:
        temp = ''
        for key in obj.keys():
            temp += '%s:%s, ' % (json_handle(key), json_handle(obj[key]))
        return '{%s}' % temp[:-2]
    elif type(obj) in [set, list, tuple]:
        temp = ''
        for value in obj:
            temp += '%s, ' % json_handle(value)
        return '[%s]' % temp[:-2]
    return 'null'

data = feedparser.parse('http://digg.com/rss/index.xml')

print json_handle(data)

Link: feed_parser_to_json.py

Update: According to John Paulett jsonpickle now supports Universal Feed Parser objects. Thanks for letting me know!