Skip to content

Instantly share code, notes, and snippets.

@nitrag
nitrag / uploadMapboxTileset.js
Last active February 14, 2017 22:15
Upload file to Mapbox Tileset (node.js)
/**
Uploads a tileset (tested with shapefile.zip) to Mapbox S3 (required),
then triggers an API request to Mapbox to create/update the tileset
Usage:
node uploadToMapBoxTileset.js [path/to/file.zip] [tilesetId] [Tileset Title]
Pro tip: Don't foget to change {username} and {access_token} and/or hardcode the process.argv[] values.
@nitrag
nitrag / commands.config
Last active May 27, 2020 20:54
How to setup GeoDjango on AWS Elastic Beanstalk (EB) with a Custom AMI
container_commands:
001installs:
command: "sudo yum-config-manager --enable epel"
setup_gdal:
command: cd /home/ec2-user/gdal-1.11.2/swig/python && /opt/python/run/venv/bin/python setup.py install
@nitrag
nitrag / GPSExif.swift
Last active October 14, 2023 22:50
Generate Metadata Exif for GPS
//
// Generate EXIF GPS metadata
// Swift 3
// Exif Version 2.2.0.0 supports decimal degrees
import Foundation
import CoreLocation
import ImageIO
extension CLLocation {
@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
@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 / 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)
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
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];
{"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
/**
* twitter: @aaronksaunders
*
* See more Appcelerator Information on Company Blog
*
* blog.clearlyinnovative.com
*
*/
/**