Skip to content

Instantly share code, notes, and snippets.

@donthorp
donthorp / ex01-codec-string.js
Created April 28, 2011 18:58
Codec String Examples
//Encode and trim a simple UTF-8 String
var buffer = Ti.createBuffer({ length: 1024 });
var length = Ti.Codec.encodeString({
source: "hello world",
dest: buffer
});
buffer.length = length;
@donthorp
donthorp / ex01-codec-numbers.js
Created April 28, 2011 18:56
Codec Numeric Examples
// Encode a 4 byte integer into position 10 using BIG_ENDIAN encoding
var buffer = Ti.createBuffer({ length: 100 });
Ti.Codec.encodeNumber({
source: 0x3456789a,
dest: buffer,
position: 10,
type: Ti.Codec.TYPE_INT,
byteOrder: Ti.Codec.BIG_ENDIAN
});
@donthorp
donthorp / ex01-buffer-create.js
Created April 28, 2011 18:46
Examples: Buffer Blog Post
// create a Buffer with initial length of 0
var buffer = Ti.createBuffer();
/**
* This sample lets you record and share video with Appcelerator Titanium on Android.
* REQUIRES THE 1.6.0 RC OF TITANIUM MOBILE SDK
* http://developer.appcelerator.com/blog/2011/02/release-candidate-for-titanium-mobile-1-6-0.html
*/
/**
* First, create our UI. We'll have two buttons: record, and share.
*/
var win = Titanium.UI.createWindow({
@donthorp
donthorp / http.py
Created January 4, 2011 19:33
A simple HTTP server to use in testing
import os
import cgi
import sys
import pprint
import simplejson
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
class customHTTPServer(BaseHTTPRequestHandler):
pp = pprint.PrettyPrinter(indent=2)
def do_GET(self):
@donthorp
donthorp / FilingIssues.md
Created December 22, 2010 16:45
Guidelines for Filing Lighthouse Tickets

Lighthouse Ticket Guidelines

  1. Please provide a detailed description of the problem and the expectation.

  2. Reproduction sequence including any working sample code or simplified project required to duplicate the problem.

  3. If there is a Q&A or Helpdesk item involved please put a link to the thread in the ticket. Hyperlink it please.

  4. Set the "Who's responsible?" field. See the platform sections below for the appropriate platform responsible party.

Android Emulator usage: emulator [options] [-qemu args]
options:
-sysdir <dir> search for system disk images in <dir>
-system <file> read initial system image from <file>
-datadir <dir> write user data into <dir>
-kernel <file> use specific emulated kernel
-ramdisk <file> ramdisk image (default <system>/ramdisk.img
-image <file> obsolete, use -system <file> instead
-init-data <file> initial data image (default <system>/userdata.img
-initdata <file> same as '-init-data <file>'
#!/bin/bash
# Add this to your ~/.bash_profile
for a in `ls $HOME/.bash_profile.d/*.sh`; do
source $a
done
@donthorp
donthorp / Organize Monitors.scpt
Created November 21, 2010 19:38
For use on my laptop when I'm switching between displays. It currently doesn't move the window to the correct coordinates, but it does put it in the spaces like I want.
tell application "System Events"
tell expose preferences
tell spaces preferences
set apps to application bindings
tell application "Finder"
set displayBounds to bounds of window of desktop
if (item 3 of displayBounds > 1680) then
set tweetDeckScreen to 65544
else
set tweetDeckScreen to 4
@donthorp
donthorp / gist:373911
Created April 21, 2010 14:55 — forked from kwhinnery/gist:372692
Kevin's Module Pattern for JS
var myApplication = function(){
var name = 'Chris';
var age = '34';
var status = 'single';
function createMember(){
// [...]
}
function getMemberDetails(){
// [...]
}