Skip to content

Instantly share code, notes, and snippets.

@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 / kube-install.sh
Last active March 31, 2020 03:10
Ubuntu 18.04 - K8s install and join cluster
# Enable bridged traffic - https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/
cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
# Enable IP Forward
echo "1" > /proc/sys/net/ipv4/ip_forward
@nitrag
nitrag / gdal_osx_virtualenv
Created October 6, 2017 02:46
Install GDAL on OSX (virtualenv)
# what a headache!
# 10-05-2017
# FIRST!
# Install kyngchaos 1.11 complete:
# http://www.kyngchaos.com/software/frameworks
# Go into your folder where your virtualenv lives and activate
source bin/activate
@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 / 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
*
*/
/**