Skip to content

Instantly share code, notes, and snippets.

@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):
/**
* 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 / 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();
@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-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-buffer-create.js
Created April 28, 2011 19:01
Buffer Creation With Conversion
// Create a buffer and encode a string at the same time.
// Using default encoding of Ti.Codec.CHARSET_UTF8
var buffer = Ti.createBuffer({ value: "Hello World" });
@donthorp
donthorp / update-vendor-branch.sh
Created June 14, 2012 19:47
Auto-track svn vendor branches in git
#! /bin/sh
# This script expects to be in the parent directory of your github projects
#
# in /etc/cron.hourly create a script that invokes this script for each repo
#
# sudo -u USER /home/USER/PROJECTS-ROOT/update-vendor-branch.sh PROJECT-DIR-1
# sudo -u USER /home/USER/PROJECTS-ROOT/update-vendor-branch.sh PROJECT-DIR-2
echo "Updating vendor repository: $1"
@donthorp
donthorp / gist:2957878
Created June 20, 2012 02:47
Z Axis Toner
const int contactPin = 7;
const int speakerPin = 6;
const int ledPin = 13;
int contactState = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(contactPin, INPUT);
@donthorp
donthorp / SimpleCursorLoader.java
Created June 22, 2012 20:42 — forked from casidiablo/SimpleCursorLoader.java
Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework SDK documentation for a class overview
/*
* Copyright 2012 CodeSlap - Cristian Castiblanco
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@donthorp
donthorp / channel.md
Last active December 15, 2015 04:29
Kandan Channel Notes

##Channels

  • A channel is a set of messages that is viewable and possibly broadcast to one or more subscribers.
  • A channel can be active, archived (frozen), or deleted.
  • An active channel has one or more subscribers and can be updated, searchable, subscribable, and viewable.
  • An archived channel is read-only, searchable, and viewable. (A daily log of an active channel could be archvied)
  • A channel may be public with open-subscriptions
  • A channel may be public and invite only
  • A channel may be private with open-subscriptions (if you know the name)
  • A channel may be private and invite only