Skip to content

Instantly share code, notes, and snippets.

View rblalock's full-sized avatar
🚀

Rick Blalock rblalock

🚀
View GitHub Profile
@fphillips
fphillips / ls20031_gps.js
Created February 18, 2012 21:22
Node.js GPS NMEA parser for LS20031 and Beaglebone
//
// Node.js GPS NMEA parser for LS20031 and Beaglebone
//
// Parses GSV/GGA strings and logs to a file.
// GPS module outputs lat ddmm.mmmm and lon dddmm.mmmm.
// Hardcoded for North-West hemispheres. latPole S and lonPole W are (-)
// Author: Frank Phillips <[email protected]>
// Uses serialport and nmea modules. Edit the require paths as necessary.
var http = require('http');
@jonalter
jonalter / app.js
Created February 10, 2012 16:26
iOS: convert view layout to single image using toImage()
var win = Ti.UI.createWindow({backgroundColor:'white'});
win.open();
// build our layout with 2 views and 1 imageView
var mainView = Ti.UI.createView({top:10,height:200,width:200,backgroundColor:'blue'});
var view2 = Ti.UI.createView({height:100,width:100,backgroundColor:'green'});
var imageView = Ti.UI.createImageView({image:'http://www.appcelerator.com/wp-content/uploads/2011/01/Appcelerator-IDC-Q1-Mobile-Developer-Report-appclogo.png'});
mainView.add(view2);
view2.add(imageView);
function AppcView() {
var ti = require('ui/common/ti');
var self = new ti.View();
var lbl = new ti.Label('appctv');
self.add(lbl);
return self;
}
@jonalter
jonalter / app.js
Created January 16, 2012 18:32
Resize image in imageView
function squareImage(imageView){
function getThumb(){
imageView.removeEventListener('load',getThumb);
var blob = imageView.toBlob();
var height = blob.height;
var width = blob.width;
if(height < width){
var size = height;
@benbahrenburg
benbahrenburg / gist:1515352
Created December 23, 2011 21:04
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);
@jonalter
jonalter / app.js
Created December 20, 2011 21:39
iOS: drag and drop using convertPointToView
var win = Ti.UI.createWindow({
masterWindow: true,
backgroundColor: 'white'
});
var view1 = Ti.UI.createView({
top : 20,
left : 20,
height : 100,
width : 100,
//Wrapper class to create extensible Titanium components
exports.Component = function(/*Object*/ tiView) {
var self = {
__viewProxy:tiView
};
//passthrough for add
self.add = function(/*Object*/ tiChildView) {
var v = tiChildView.__viewProxy||tiChildView;
self.__viewProxy.add(v);
// Here is a proposal for minimalist JavaScript classes, humbly offered.
// There are (at least) two different directions in which classes can be steered.
// If we go for a wholly new semantics and implementation, then fancier classical
// inheritance can be supported with parallel prototype chains for true inheritance
// of properties at both the class and instance level.
// If however, we keep current JavaScript prototype semantics, and add a form that
// can desugar to ES3, things must necessarily stay simpler. This is the direction
// I'm assuming here.
@pec1985
pec1985 / app.js
Created October 23, 2011 09:20
Pull to Refresh in android, plus a demo
/*
Copyright 2011 Pedro Enrique
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
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@dawsontoth
dawsontoth / app.js
Created October 10, 2011 10:11
iOS Text Field Suggestions in Appcelerator Titanium
/**
* This demonstrates how to show suggestions on a text field using just JavaScript with Appcelerator Titanium.
*
* You will need to download four images to get this to work:
*
* 1) http://dl.dropbox.com/u/16441391/Suggest/bg.png
* 2) http://dl.dropbox.com/u/16441391/Suggest/[email protected]
* 3) http://dl.dropbox.com/u/16441391/Suggest/separator.png
* 4) http://dl.dropbox.com/u/16441391/Suggest/[email protected]
*