Skip to content

Instantly share code, notes, and snippets.

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

tz ✨ tzmartin

🏴‍☠️
ahoy!
View GitHub Profile
@tzmartin
tzmartin / gist:1018258
Created June 10, 2011 05:04 — forked from omorandi/gist:1013226
Two methods for sending SMS messages with Titanium Mobile on Android throught native intents
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff',
layout: 'vertical'
});
var bt1 = Ti.UI.createButton({title: 'send message (method 1)', top: 200});
bt1.addEventListener('click', function(e)
@tzmartin
tzmartin / on-javascript-callbacks.md
Created June 15, 2011 11:34 — forked from lamberta/on-javascript-callbacks.md
On JavaScript callbacks, program flow control and the functional style.

One of the first things a newcomer to JavaScript will notice when confronted with the modern style is the prevalence of function objects passed as parameters to other functions, or callbacks. What is not immediately apparent is why this higher-order function style needed. In short, functional arguments give us a way to delay the execution of a block of code. This kind of program flow control means we can approximate some powerful abstraction techniques usually reserved for macros in other languages.

Here's a typical callback example you'll find on the client-side, attaching a click event handler to a DOM element:

var callback = function (evt) { console.log("Element clicked!"); };
element.addEventListener('click', callback);

Here we've created a variable to hold our callback function. Next we have our DOM element listen for click events and, when it has one, execute our function. The callback function has been taken out of the normal program flow to be run at another time, or in this case, when the

@tzmartin
tzmartin / GPointGenerator.html
Created August 12, 2011 07:05 — forked from rgabbard/GPointGenerator.html
Point generator for Google Map routes
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Utility to generate points along a route using the Google Maps API
Directions service.
2011-03-31 Rob Gabbard, cintimedia LLC, www.cintimedia.com
Based on the Google Maps API Optimized Directions demo at:
@tzmartin
tzmartin / LICENSE.txt
Created February 22, 2012 03:41 — forked from aemkei/LICENSE.txt
Binary Tetris - 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@tzmartin
tzmartin / gist:2716580
Created May 17, 2012 05:10 — forked from benbahrenburg/gist:1515352
Titanium : How to find the Private Directory
function privateDocumentsDirectory(){
Ti.API.info('We need to open a file object to get our directory info');
var testFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory);
Ti.API.info('Now we remove the Documents folder reference');
var privateDir = testFile.nativePath.replace('Documents/','');
Ti.API.info('This is our base App Directory =' + privateDir);
Ti.API.info('Now we add the Private Documents Directory');
privateDir+='Library/Private%20Documents/';
Ti.API.info('Our new path is ' + privateDir);
@tzmartin
tzmartin / mdb.js
Created June 19, 2012 20:29 — forked from kirbysayshi/mdb.js
example showing how to wrap node-mongodb-native driver in promises. uses jquery deferreds from https://github.com/kirbysayshi/jquery-jqd
var mongo = require('mongodb')
,jqd = require('../jquery-jqd').jqd
,host = process.env['MONGO_NODE_DRIVER_HOST'] != null
? process.env['MONGO_NODE_DRIVER_HOST'] : 'localhost'
,port = process.env['MONGO_NODE_DRIVER_PORT'] != null
? process.env['MONGO_NODE_DRIVER_PORT'] : mongo.Connection.DEFAULT_PORT
,db = null
,gConnection = null;
@tzmartin
tzmartin / ScrollingMatrix.ino
Created July 29, 2012 16:32
Scrolling LED Matrix Display for Arduino
const int clockPin = 13;
const int dataPin = 11;
const int latchPin = 10;
byte arrow[8]={0x18,0x3C,0x66,0xDB,0x18,0x18,0x18,0x18};
byte displayBuffer[8]= {0};
int fontDefinitions[475] = {
0x00,0x00,0x00,0x00,0x00,/*space*/ // is 32 in ASCII
0x00,0xF6,0xF6,0x00,0x00,/*!*/
@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 / 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 / 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);
}