Skip to content

Instantly share code, notes, and snippets.

View akanieski's full-sized avatar

Andrew Kanieski akanieski

View GitHub Profile
var MOBILE = {
Android: function() { return navigator.userAgent.match(/Android/i); },
BlackBerry: function() { return navigator.userAgent.match(/BlackBerry/i); },
iOS: function() { return navigator.userAgent.match(/iPhone|iPad|iPod/i); },
Opera: function() { return navigator.userAgent.match(/Opera Mini/i); },
Windows: function() { return navigator.userAgent.match(/IEMobile/i); },
any: function() { return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows()); } };
if ( MOBILE.any() ) {
@akanieski
akanieski / slicer.rb
Last active August 29, 2015 14:02 — forked from miletbaker/map_tile.rb
#! /usr/bin/ruby -w
require 'rubygems'
require 'rmagick'
require 'fileutils'
include Magick
puts 'Go!'
limit = ARGV.length > 1 ? ARGV[1].to_i : 18
file = ARGV[0]
<!DOCTYPE html>
<html>
<head>
<title>KHIM Inspections Installation</title>
</head>
<body>
<h2>Release builds</h2>
<a href="itms-services://?action=download-manifest&amp;url=https://dl.dropboxusercontent.com/u/9675825/manifest.plist">KHIM Inspections v0.2.0</a></body>
<h2>Testing builds</h2>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
// Converts an ArrayBuffer directly to base64, without any intermediate 'convert to string then
// use window.btoa' step. According to my tests, this appears to be a faster approach:
// http://jsperf.com/encoding-xhr-image-data/5
function base64ArrayBuffer(arrayBuffer) {
var base64 = ''
var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
var bytes = new Uint8Array(arrayBuffer)
var byteLength = bytes.byteLength