Skip to content

Instantly share code, notes, and snippets.

View tzmartin's full-sized avatar
🏴‍☠️
ahoy!

tz ✨ tzmartin

🏴‍☠️
ahoy!
View GitHub Profile
@tzmartin
tzmartin / AECurl
Created July 2, 2014 07:21 — forked from matthijn/AECurl
<?php
/* A quick emulator for common curl function so code based on CURL works on AppEngine */
if(!function_exists('curl_init'))
{
// The curl option constants, when there is no curl they are not defined so we define them here
// Some options don't do anything, they just prefent crashes when they are here (see the setOpt method for the support of different options)
define('CURLOPT_RETURNTRANSFER', 'CURLOPT_RETURNTRANSFER');
define('CURLOPT_SSL_VERIFYPEER', 'CURLOPT_SSL_VERIFYPEER');
@tzmartin
tzmartin / fulcrum.form.model.js
Created July 17, 2014 02:58
Fulcrum app data model
{
"current_page": 1,
"total_pages": 1,
"total_count": 3,
"per_page": 20000,
"forms": [
{
"name": "Building Survey",
"description": "updated",
"bounding_box": [
@tzmartin
tzmartin / Alloy.Model.HTTP.Loop
Created October 22, 2014 18:50
Loop through an HTTP response object and only add new Alloy Models if needed.
/*
Loop through an HTTP response object and only add new Alloy Models if needed.
Assumes `eventId` is the primary key defined in Events.js Model file.
Caution: this snippet is untested
*/
var events = Alloy.createCollection('Events');
@tzmartin
tzmartin / index.xml
Last active August 29, 2015 14:08 — forked from jasonkneen/index.xml
<!-- note the ONLY change to this is the additional module="tabIndicator"
attribute + properties to override indicator defaults //-->
<Alloy>
<TabGroup module="tabIndicator" tabsBackgroundColor="#000" tabIndicatorHeight="1" tabIndicatorColor="white" tabIndicatorWidth="75%">
<Tab title="Tab 1" icon="/images/icons/519-tools-1.png" activeIcon="/images/icons/519-tools-1_active.png" color="#555" activeColor="#fff">
<Window title="Tab 1" barColor="black" navTextColor = "#fff">
<Label onClick="openWin1">Tab 1</Label>
</Window>
</Tab>
<Tab title="Tab 2" icon="/images/icons/516-archive-box.png" activeIcon="/images/icons/516-archive-box_active.png" color="#555" activeColor="#fff">
@tzmartin
tzmartin / tss.window.properties.js
Created November 11, 2014 21:38
Alloy TSS Window Transparency Properties
"Window[platform=ios]": {
// Tell the windowManager this window is part of the NavGroup by default
navGroup: true,
backButtonTitle: '', // No back button title by default
statusBarStyle: Ti.UI.iPhone.StatusBar.LIGHT_CONTENT,
barColor: 'transparent',
translucent: true,
navTintColor: '#fff',
backgroundColor: '#ffffff99', // rgba for transparency
extendEdges: [
@tzmartin
tzmartin / titanium_webview_websocket.js
Last active August 29, 2015 14:09
Titanium WebView as a Websocket Processor
module.exports = function(_args) {
/*
This is a simple WebView running as a websocket client. Here are notes:
- To test, run a local socket server (ie, socket.io). Socket.io example chat app: http://socket.io/get-started/chat/
- Pass the websocket URL into io.connect() method
- Event callbacks are registered on Ti.App.. app should fire 'app:ws:connected'. Observe console.log: "Websocket is connected"
- For securty purposes, use inline HTML (string below) to compile into bytecode, rather than filesystem / HTML resources.
@tzmartin
tzmartin / anim.js
Last active August 29, 2015 14:09 — forked from guiled/anim.js
// next two from http://stackoverflow.com/a/5624139/292947
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(r, g, b) {
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

// backbone collections lack a search functionality. This adds it to all collections.
// fuse.js is the library that powers the fuzzy search and requires being downloaded and included into your app
// http://kiro.me/projects/fuse.html
_.extend(Backbone.Collection.prototype, {
searchableFields: null,
buildSearchIndex: function(options) {
options = (typeof options !== 'undefined') ? options : {};