Skip to content

Instantly share code, notes, and snippets.

//Create a container view
var container = Ti.UI.createView({
width:200,
height:200,
top:10,
left:10
});
//Create a drop shadow view
var shadow = Ti.UI.createView({
//Here's the first window...
var first = Ti.UI.createWindow({
backgroundColor:"#fff",
title:"My App"
});
var label = Ti.UI.createLabel({ text: "poke me to open the next window" });
first.add(label);
//Here's the nav group that will hold them both...
var navGroup = Ti.UI.iPhone.createNavigationGroup({
var Pool = Base(EventEmitter, {
init: function(getConnection, size) {
this._super();
this._pool = [];
this._queue = [];
this.size = size;
var me = this;
getConnection(size, function(conn) {
me.emit('back', conn);
});
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
/////////////////////////
// create base UI tab and root window
// We need a tabBar to be able to win.setToolbar items, even though we'll hide it
/////////////////////////
var win = Titanium.UI.createWindow({
title:'TweetFlow',
/**
* Simple demo for adding swipe detection on a table view row. Since the row is simply a container
* of views, you'll want to generally create a hidden view the size of the row and add your swipe listener
* to this view for detection. We need to improve Titanium so you don't have to do this in the future...
*/
var win = Ti.UI.createWindow();
var data = [];
for (var c=0;c<10;c++)
{
"""
I've been thinking lately about how perfect Redis would be for storing a
simple social graph. I posited that it would be relatively few lines of code,
and that it'd be clean code too. So here it is: a basic social graph built on Redis.
"""
class FriendGraph(object):
def __init__(self, ring):
self.ring = ring
var assert = require('assert')
, subclass = function(type, proto){
// make sure we are extending a global constructor
// accepted: [Boolean, Number, String, Array, Object, Function, RegExp, Date]
if(!global[type.name] || global[type.name].name != type.name) throw new Error();
var constructor = proto.constructor,
keys = Object.keys(proto),
Obj = process.binding('evals').Script.runInNewContext('x = '+type.name), // eval ftw
// Kosso imageAsCropped
// added to TiBlob.m
// requires 4 arguments : x, y, width, height
- (id)imageAsCropped:(id)args
{
[self ensureImageLoaded];
if (image!=nil)
{
ENSURE_ARG_COUNT(args,4);
@meltingice
meltingice / usernode.php
Created November 15, 2010 03:15
Social graph functions implemented using Redis.
<?
/*
* This example would probably work best if you're using
* an MVC framework, but it can be used standalone as well.
*
* This example also assumes you are using Predis, the excellent
* PHP Redis library available here:
* https://github.com/nrk/predis
*/
@TooTallNate
TooTallNate / starttls.js
Created March 1, 2011 01:40
Upgrade a regular `net.Stream` connection to a secure `tls` connection.
// Target API:
//
// var s = require('net').createStream(25, 'smtp.example.com');
// s.on('connect', function() {
// require('starttls')(s, options, function() {
// if (!s.authorized) {
// s.destroy();
// return;
// }
//