Skip to content

Instantly share code, notes, and snippets.

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

tz ✨ tzmartin

🏴‍☠️
ahoy!
View GitHub Profile
@tzmartin
tzmartin / TiUIScrollableView.m
Created July 8, 2012 07:33
TiUIScrollableView Mods
/**
TiUIScrollableView.m
Currently, ScrollableViews do not listen for x,y changes during scroll events (touchmove). This mod fixes that. It adds additional x,y coords to the scroll event, similar to scrollViews.
Outputs:
currentPage = 0;
source = "[object TiUIScrollableView]";
type = scroll;
@tzmartin
tzmartin / video.thumbnail.js
Created July 10, 2012 17:46
Create Thumbnail Image From Video File, Titanium Mobile
/**
Create Thumbnail of Video File
This snippet captures a thumbnail JPG image, based on a frame @ 2 second time-lapse.
Titanium Mobile
*/
var movie = Titanium.Media.createVideoPlayer({
contentURL:FILENAME,
@tzmartin
tzmartin / titanium.windows7.debug.txt
Created July 17, 2012 17:40
Titanium Windows 7 installation helper notes..
* These are personal notes taken from various training events for debugging Windows 7 installation...
----------------
1. Uninstall McAfee. Stop ALL McAfee services (services.msc)
2. Verify Internet access.
Add proxy for downloading (optional)
proxy.cognizant.com 6050
3. Install Java JDK v1.6.x (1.7 is not supported)
4. Move Android SDK to
@tzmartin
tzmartin / geolocate.js
Created July 18, 2012 22:51
Roll your own reverse/forward geolocator in Titanium
/* Roll your own reverse/forward geolocator
*
* YQL
*/
Titanium.Yahoo.yql('select * from yahoo.maps.findLocation where q="'+latitude+','+longitude+'" and gflags="R"',function(e) {
var woeid = e.data.ResultSet.Results.woeid;
Titanium.API.info(woeid);
});
/*
@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,/*!*/
- Add a Pre-Compile script in Xcode projects for all Titanium builds. This snippet will pre-compile Alloy projects in Xcode for faster debug workflows.
proj = injectCompileShellScript(
proj,
'Pre-Compile',
"alloy compile "+this.projectDir+"\n\n"+'if [ \\"x$TITANIUM_CLI_XCODEBUILD\\" == \\"x\\" ]; then NO_COLORS=\\"--no-colors\\"; else NO_COLORS=\\"\\"; fi\\n' +
(process.execPath || 'node') + ' \\"' + this.cli.argv.$0.replace(/^(.+\/)*node /, '') + '\\" build --platform ' +
this.platformName + ' --sdk ' + this.titaniumSdkVersion + ' --no-prompt --no-banner $NO_COLORS --xcode\\nexit $?'
);
@tzmartin
tzmartin / suggestHeight
Created September 3, 2013 17:49
Native dynamic height calculation for UIViews in Titanium Mobile SDK. Useful for situations where getSize(), getRect() or postLayout event is not sufficient. Typically needed when view dimensions are set to Ti.UI.FILL or Ti.UI.SIZE. Add this method to TiUiLabelProxy.m, TiUITableViewProxy.m Reference: http://developer.appcelerator.com/question/14…
-(id)suggestHeight:(id)arg
{
CGFloat height = 0;
// resolve arg
if (arg != nil && [arg isKindOfClass:[NSArray class]])
{
NSArray *args = (NSArray *)arg;
if (args.count > 0)
arg = [args objectAtIndex:0];
@tzmartin
tzmartin / toggle_swap.sh
Created September 5, 2013 07:04
The swap is too damn high. Free it up, but ensure there's enough RAM.
#!/bin/bash
free_data="$(free)"
mem_data="$(echo "$free_data" | grep 'Mem:')"
free_mem="$(echo "$mem_data" | awk '{print $4}')"
buffers="$(echo "$mem_data" | awk '{print $6}')"
cache="$(echo "$mem_data" | awk '{print $7}')"
total_free=$((free_mem + buffers + cache))
used_swap="$(echo "$free_data" | grep 'Swap:' | awk '{print $3}')"
@tzmartin
tzmartin / gist:7312401
Created November 5, 2013 01:31
Run Javascript Textmate command
#!/usr/bin/env bash
. "$TM_SUPPORT_PATH/lib/webpreview.sh"
html_header "Javascript Runner" "Open Web Inspector for log"
YOURCODE=`cat`
cat <<HTML
<script>
(function(){try{
@tzmartin
tzmartin / gist:7506739
Created November 16, 2013 23:24
Manually install Go v1.1.1 on Debian. Current package manager is 1.0.
sudo apt-get install -y debhelper build-essential autotools-dev
curl -s -o /tmp/go.tar.gz https://go.googlecode.com/files/go1.1.1.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf /tmp/go.tar.gz
sudo ln -s /usr/local/go/bin/go /usr/local/bin/go