Skip to content

Instantly share code, notes, and snippets.

View benbahrenburg's full-sized avatar

Ben Bahrenburg benbahrenburg

View GitHub Profile
@benbahrenburg
benbahrenburg / app.js
Created July 31, 2011 03:46 — forked from joemaffia/app.js
foursquare OAuth in Titanium
/**
*
*
* Copyright 2011 Aaron K. Saunders, Clearly Innovative Inc
*
* 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
*
* <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>
@benbahrenburg
benbahrenburg / gist:1446135
Created December 8, 2011 04:43 — forked from tzmartin/gist:1372475
UIModule Error Hack
/*
* This is a hack solves the "Invalid method passed to UIModule" error
* It works by forcing Titanium to load SDK components into memory.
*
* Drop this file anywhere in your project and DON'T Ti.include() it.
* Be sure this file extension is .js.
* Clean and recompile your project.
*
* Enjoy!
* @tzmartin
@benbahrenburg
benbahrenburg / GeolocationModule.mm
Created March 11, 2012 01:41 — forked from stevenou/GeolocationModule.mm
Geofencing in Titanium
// this file located in /Library/Application Support/Titanium/mobilesdk/osx/{version_number}
// add the following methods to GeolocationModule.mm
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(YES),@"success",[NSDictionary dictionaryWithObjectsAndKeys:NUMDOUBLE(region.center.latitude),@"lat",NUMDOUBLE(region.center.longitude),@"lng",NUMDOUBLE(region.radius),@"radius",region.identifier,@"identifier",nil],@"region",nil];
if ([self _hasListeners:@"enteredRegion"])
{
[self fireEvent:@"enteredRegion" withObject:event];
@benbahrenburg
benbahrenburg / ti.socket.io.js
Created June 5, 2012 23:49 — forked from euforic/ti.socket.io.js
Socket.io-client Titanium
/*! Socket.IO.js build:0.9.6, development. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */
/**
* Originally Ported to titanium by Jordi Domenech <jordi@iamyellow.net>
* source: https://github.com/iamyellow/socket.io-client
*/
this.io = {};
module.exports = this.io;
/**
@benbahrenburg
benbahrenburg / gist:3881520
Created October 12, 2012 21:05 — forked from rborn/gist:3881465
A simple Drag, Drop and Resize for Titanium Mobile. (@Thedeejay92 - Mousta.ch )
/*
* I made this code for an upcoming hackaton, so, it's really, really ugly. Feel free
* to update it here so everyone will be able to use it correctly.
*
* It's pretty easy to understand, basicly the object you want to edit, an overlay,
* four handlers, and the background view.
*
* It's currently made for/tested on iPad 5.0 with Timob 2.0.2; works only in landscape.
*
* This code is under the Moustach licence. This means you can do whatever you want with
@benbahrenburg
benbahrenburg / iOS Simulator Device.scpt
Last active December 10, 2015 22:58 — forked from rgabbard/iOS Simulator Device.scpt
Updated to add iPhone 5, and Retina iPad support
set selectedDevices to choose from list {"iPhone", "iPhone (Retina 3.5-inch)", "iPhone (Retina 4-inch)", "iPad", "iPad (Retina)"} with prompt "Choose device type:" default items {"iPhone"} without multiple selections allowed
if selectedDevices is not false then
set selectedDevice to item 1 of selectedDevices as string
set thePListFolderPath to path to preferences folder from user domain as string
set thePListPath to thePListFolderPath & "com.apple.iphonesimulator.plist"
tell application "System Events"
tell property list file thePListPath
tell contents
set value of property list item "SimulateDevice" to selectedDevice
public interface IPop3Client : IDisposable {
void Connect();
List<string> GetMessageUids();
MessageHeader GetMessageHeaders(int messageNumber);
Message GetMessage(int messageNumber);
IEnumerable<Message> FetchMessagesLike(string emailedToRegex);
IEnumerable<Message> FetchMessagesFrom(string[] to);
void DeleteMessage(int messageNumber);
void DeleteMessages(IList<Message> messages);
}
@benbahrenburg
benbahrenburg / app.js
Last active March 15, 2017 14:22 — forked from srahim/app.js
var win = Titanium.UI.createWindow({
backgroundColor:'grey'
});
Ti.Geolocation.preferredProvider = "gps";
Ti.Geolocation.purpose = "GPS demo";
Ti.Geolocation.trackSignificantLocationChange = true;
Ti.Geolocation.setAllowBackgroundLocationUpdates(true);
'use strict';
import View from 'view';
import Window from 'window';
// Example Usage
let win = new Window();
let view = new View({
top: 0,
@benbahrenburg
benbahrenburg / ParameterEncodingExt.swift
Created February 16, 2016 14:28 — forked from tmspzz/ParameterEncodingExt.swift
Alamofire-GZIP-ParameterEncoding
// Actual gzipping from https://github.com/1024jp/NSData-GZIP
// Example: ParameterEncoding.JSON.gzipped
infix operator • { associativity left }
func • <A, B, C>(f: B -> C, g: A -> B) -> A -> C {
return { x in f(g(x)) }
}
extension ParameterEncoding {