Skip to content

Instantly share code, notes, and snippets.

View mcongrove's full-sized avatar

Matthew Congrove mcongrove

View GitHub Profile
@mcongrove
mcongrove / TiDrop.js
Created April 1, 2011 22:13
A quick and simple example of how to do drag+drop in Titanium
var TiDrop = {
touching: false,
position: {
elementYStart: 0,
elementXStart: 0,
yStart: 0,
xStart: 0,
yCurrent: 0,
xCurrent: 0
},
@mcongrove
mcongrove / TiLoad.js
Created April 6, 2011 17:12
A loading screen that can be shown and hidden from anywhere within an application
var TiLoad = {
visible: false,
init: function(_properties) {
var options;
if(_properties && _properties.rotate) {
options = {
orientationModes: [
Titanium.UI.LANDSCAPE_LEFT,
Titanium.UI.LANDSCAPE_RIGHT,
@mcongrove
mcongrove / TiFtp.js
Created April 11, 2011 22:02
An FTP wrapper library for Titanium Mobile.
var TiFtp = {
config: {
host: null,
port: 21,
path: null,
user: null,
password: null
},
init: function(_host, _path, _user, _password) {
if(!_host || !_path || !_user || !_password) {
@mcongrove
mcongrove / RedFlare.md
Created April 14, 2011 21:10
A description of the RedFlare service.

What is RedFlare?

RedFlare is an automated emergency contact notification system. It automatically contacts the people who love you in the event that you didn't get home when you should have.

Why do I need it?

Say for instance that you just moved to Boston, MA, and you want to go exploring the mountains just outside the city. Unfortunately you don't have many friends in town, so no one will notice if you've gone missing for quite some time. If the unthinkable happens and you've been pinned under a rock, broken an ankle or just gotten lost in an area without cell reception, you could be in serious trouble.

@mcongrove
mcongrove / HTML5_Audio_Duration.html
Created April 20, 2011 06:36
Retrieve the duration of an HTML5 audio element.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>HTML5 Audio Duration</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
var audio, duration;
window.onload = function() {
var element = document.createElement("audio");
@mcongrove
mcongrove / login.js
Created May 3, 2011 20:14
Simple login example
var login = {
authorized: false,
session_id: null,
init: function() {
// See if we have an existing sess_id
login.session_id = login.checkForSession();
// If not, open login window
if(!login.session_id) {
login.openLoginPage();
@mcongrove
mcongrove / gist:1015435
Created June 8, 2011 21:22
getResponseCookies Regex
Test values:
cn1=cv1; Domain=something.org; Max-Age=89000000; Path=/eportal; HttpOnly, cn2=cv2; HttpOnly , cn3=cv3
cn1=cv1; Domain=something.what.org; Path=/eportal; HttpOnly, cn2=cv2; HttpOnly , cn3=cv3;
cn1=cv1; Domain=something.org; Max-Age=890000;,cn2=cv2, cn3=cv3
cn1=cv1; Domain=what.org; Expires=Fri, 21-Mar-2014 16:52:43 GMT; HttpOnly, cname2=cvalue2; HttpOnly
Expression:
([a-zA-Z0-9])+(?<!Domain|Path|Age|Expires)=([a-zA-Z0-9])+
<?php
/**
* Write a script that prints the numbers 1 through 100.
* However, if a number is divisible by 3 then print the word 'Fizz' instead, or the word 'Buzz' if divisible by 5.
* If the number is divisible by both 3 and 5, instead print 'FizzBuzz'.
*/
for($i = 1; $i <= 100; $i++)
{
function foo()
if (get(onGround)==1) then
if (get(doorOpen)>=1) then
if (get(engineRunning)==1) then
g = 250
else
g = 500
end
else if (get(viewExternal)==1) then
g = 750
defineProperty("viewX", globalPropertyf("sim/graphics/view/view_x"))
defineProperty("viewY", globalPropertyf("sim/graphics/view/view_y"))
defineProperty("viewZ", globalPropertyf("sim/graphics/view/view_z"))
defineProperty("acfX", globalPropertyf("sim/flightmodel/position/local_x"))
defineProperty("acfY", globalPropertyf("sim/flightmodel/position/local_y"))
defineProperty("acfZ", globalPropertyf("sim/flightmodel/position/local_z"))
function cameraDistance()
local cX = (math.abs(get(viewX)) - math.abs(get(acfX)))
local cY = (math.abs(get(viewY)) - math.abs(get(acfY)))