Skip to content

Instantly share code, notes, and snippets.

/*!
* Parse JavaScript SDK
* Version: 1.3.2
* Built: Fri Nov 21 2014 16:31:10
* http://parse.com
*
* Copyright 2014 Parse, Inc.
* The Parse JavaScript SDK is freely distributable under the MIT license.
*
* Includes: Underscore.js
@nitrag
nitrag / ti-download-simple
Created March 16, 2015 14:08
Titanium file download function (not working large files)
function download(localFile, remoteFile, name){
var progressBar = Titanium.UI.createProgressBar({
width: "80%", //describes the width
height:50, //describes the height
bottom: "25%",
min:0, //Minimum position
max:1, //Maximum value for the progress
value:0,
color: '#fff',
message: 'Downloading ' + name + '...',
/*!
* Parse JavaScript SDK
* Version: 1.5.0
* Built: Fri Jul 10 2015 17:05:46
* http://parse.com
*
* Copyright 2015 Parse, LLC
*
* Includes: Underscore.js
* Copyright 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
/**
* twitter: @aaronksaunders
*
* See more Appcelerator Information on Company Blog
*
* blog.clearlyinnovative.com
*
*/
/**
{"type": "FeatureCollection", "crs": {"type": "name", "properties": {"name": "EPSG:4326"}}, "features": [{"geometry": {"type": "MultiLineString", "coordinates": [[[-106.060845, 39.281545], [-106.061356, 39.281166], [-106.061917, 39.280773], [-106.062234, 39.280546], [-106.06255, 39.280312], [-106.062985, 39.280028], [-106.063513, 39.279824], [-106.064143, 39.279826], [-106.064553, 39.279797], [-106.06522, 39.279657], [-106.065821, 39.279575], [-106.066613, 39.279411], [-106.067253, 39.279291], [-106.067617, 39.279123], [-106.067811, 39.278864], [-106.068009, 39.278308], [-106.068335, 39.278105], [-106.069582, 39.277602], [-106.070662, 39.277396], [-106.071755, 39.277545], [-106.072715, 39.277826], [-106.074001, 39.278185], [-106.075039, 39.278314], [-106.076879, 39.278232], [-106.077382, 39.278213], [-106.077947, 39.27819], [-106.07869, 39.27815], [-106.079258, 39.278123], [-106.080154, 39.278101], [-106.081174, 39.278117], [-106.082774, 39.27816], [-106.084699, 39.278236], [-106.086484, 39.278467], [-106.087
NSArray *features = [geoJson valueForKey:@"features"];
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
NSUInteger l = [features count];
NTGeoJSONGeometryReader* geoJsonReader = [[NTGeoJSONGeometryReader alloc] init];
for (int i=0; i<l; i++) {
NSDictionary* feature = [features objectAtIndex:i];
exports.createView = function(args) {
var imageView = Ti.UI.createImageView(args);
imageView.setMaxImage = function(url, maxWidth, maxHeight){
var preview = Ti.UI.createImageView();
Ti.API.info("ImageView's width = " + imageView.getWidth());
preview.addEventListener('load', function(e){
Ti.API.info("Loaded preview, resizing...");
var ratioX = imageView.getWidth() / image.width(); //hardcoded to imageView's max width since this is static to my needs, change for full functionality
@nitrag
nitrag / swift_slippy_counter.swift
Created November 7, 2016 05:01
Swift 3 Slippy Map Tiles Counter
//Swift 3 - Slippy Map Tile Counter
import UIKit
import CoreLocation
private func long2tile(lon: Double, zoom: Int) -> Int {
let z = Double(zoom)
return Int(floor((lon+180) / 360 * pow(2.0, z)))
}
private func lat2tile(lat: Double, zoom: Int) -> Int {
let z = Double(zoom)
@nitrag
nitrag / hmac.swift
Created November 8, 2016 19:06 — forked from davetrux/hmac.swift
HMAC algorithm for iOS
import Foundation
//You have to create a bridging header in your project containing:
// #import <CommonCrypto/CommonHMAC.h>
extension String {
func digestHMac256(_ key: String) -> String! {
let str = self.cString(using: String.Encoding.utf8)
@nitrag
nitrag / Screenshot.swift
Created November 21, 2016 05:16
This will allow you to take a screenshot of a UIView, but more importantly only a section of that view
//
// Screenshot.swift
//
// 1) Take a picture of a UIView
// 2) Take a picture of a UIView's subframe. EG. Fullscreen UIView with a
// small square box in the middle, it will only save what's visible in the box frame
// but not the box itself
import Foundation
import UIKit