Skip to content

Instantly share code, notes, and snippets.

View thunsaker's full-sized avatar
💻
Always Working

Thomas Hunsaker thunsaker

💻
Always Working
View GitHub Profile
@thunsaker
thunsaker / mobile_scroll_to_top.js
Created December 21, 2011 16:23
Mobile Scroll to top, add extra height if needed
// Scroll to top, add extra height to make this possible
$(document).ready(function () {
if (navigator.userAgent.match(/Android/i)) {
window.scrollTo(0, 0); // reset in case prev not scrolled
var nPageH = $(document).height();
var nViewH = window.outerHeight;
if (nViewH > nPageH) {
nViewH -= 250;
$('body').css('height', nViewH + 'px');
}
@thunsaker
thunsaker / monkeyJSON.cs
Created August 16, 2012 03:35
Return Raw JSON with ActionResult
// GET: /Monkey/Get/5
/// <summary>Return Raw JSON</summary>
public ActionResult Get(int id) {
return Json(
new {
Id = id,
Name = "George",
ScientificName = "Simia Curiosa",
Active = "true",
DateCreated = "1343404556"
@thunsaker
thunsaker / caclulateDistance.sql
Created September 10, 2012 22:24
Calculate Distance Between 2 GPS Coordinates
CREATE FUNCTION [dbo].[CalculateDistanceBetweenGPSCoordinates](
@Latitude1 float,
@Longitude1 float,
@Latitude2 float,
@Longitude2 float,
@ReturnUnits char(2) = 'MI'
)
RETURNS float
AS
BEGIN
@thunsaker
thunsaker / mobile_redirect_revision.js
Created November 5, 2012 17:01
Mobile Redirect in Javascript (including Android Tablets)
(function(a,b){
if(/android.+safari|(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt
@thunsaker
thunsaker / gist:6359938
Created August 27, 2013 22:25
Foursquare Connected App Schemes for Android
<data android:scheme="fsq+PRETENT_MY_CLIENT_ID_IS_HERE+reply" />
<data android:scheme="https" android:host="myapp.appspot.com" android:path="/reply" />
@thunsaker
thunsaker / gist:6380609
Created August 29, 2013 16:54
Test Map JSON
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-114.0435791015625,34.016241889667015],[-114.0435791015625,34.88593094075317],[-110.994873046875,34.88593094075317],[-110.994873046875,34.016241889667015],[-114.0435791015625,34.016241889667015]]]}},{"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":[[-111.96716308593749,35.285984736065735],[-111.85729980468749,34.89494244739732],[-113.016357421875,35.30840140169162]]}},{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[-112.24731445312499,35.205233347514536]}}]}
package com.example.scalpeldrawer;
import android.app.Activity;
import android.content.Context;
import android.support.v4.widget.DrawerLayout;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
@thunsaker
thunsaker / main.py
Created January 8, 2014 21:10 — forked from davemasse/main.py
import requests
from pyquery import PyQuery
import settings
if __name__ == '__main__':
# Log in to Alarm.com page
payload = {
'JavaScriptTest': '1',
'cookieTest': '1',
@thunsaker
thunsaker / atom-sane-tab-switching.cson
Last active December 31, 2016 06:33
Atom - Sane Tab Switching
# Add the following to your keymap.cson file
#
# Get to keymap.cson through Settings -> Keybindings or ~/.atom/keymap.cson (on Mac)
'body':
'ctrl-tab':'pane:show-next-item'
'ctrl-shift-tab':'pane:show-previous-item'
@thunsaker
thunsaker / android_build_types.gradle
Last active November 20, 2016 17:23
Common build.gradle snippets for Android
// Android debug/release build types including package renaming for debug
android {
buildTypes {
debug {
zipAlign true
debuggable true
runProguard false
packageNameSuffix ".debug"
versionNameSuffix "-debug"
signingConfig signingConfigs.debugSigning