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
@davemasse
davemasse / main.py
Created September 8, 2012 01:59
Set Dropcam status based on Alarm.com arming status
import requests
from pyquery import PyQuery
import settings
if __name__ == '__main__':
# Log in to Alarm.com page
payload = {
'JavaScriptTest': '1',
'cookieTest': '1',
@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
@ChrisRisner
ChrisRisner / blobs.delete.js
Last active December 15, 2015 13:19
Blob Storage
var azure = require('azure');
function del(id, user, request) {
var accountName = 'accountname';
var accountKey = 'accountkey';
var host = accountName + '.blob.core.windows.net';
var blobService = azure.createBlobService(accountName, accountKey, host);
blobService.deleteBlob(request.parameters.containerName,
public void PutBlob(String containerName, String blobName)
{
String requestMethod = "PUT";
String urlPath = String.Format("{0}/{1}", containerName, blobName);
String storageServiceVersion = "2012-02-12";
String dateInRfc1123Format = DateTime.UtcNow.ToString("R", CultureInfo.InvariantCulture);
@HBehrens
HBehrens / TicToc.js
Last active October 25, 2016 18:06
// book keeping so that we can easily animate the two hands for the watchface
// .scale/.angle are updated by tween/event handler (see below)
var renderState = {
minute: {style: 'white', scale: 0.80, angle: 0},
hour: {style: 'red', scale: 0.51, angle: 0}
};
// helper function for the draw function (see below)
// extracted as a standalone function to satisfy common believe in efficient JS code
// TODO: verify that this has actually any effect on byte code level
@jgilfelt
jgilfelt / ScalpelDrawer.java
Last active January 28, 2017 13:09
ScalpelDrawer - A simple wrapper for Scalpel (https://github.com/JakeWharton/scalpel) that includes toggle controls accessible from a right-side navigation drawer. Call ScalpelDrawer.wrapInside() in a base Activity onPostCreate() to easily wrap all content in your app.
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;
@andhie
andhie / PermissionUtil.java
Last active October 23, 2017 17:04
Marshmallow Permission Level
public static void printPermissions(Context context) {
PackageInfo android;
try {
android = context.getPackageManager().getPackageInfo("android", PackageManager.GET_PERMISSIONS);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return;
}
PermissionInfo[] permissions = android.permissions;
@antoniolg
antoniolg / SwipeRefreshActivity.java
Last active July 29, 2019 11:59
An activity that uses a SwipeRefreshLayout as a container for the layout of the classes that extend it.
/*
* Copyright (C) 2014 Antonio Leiva Gordillo.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@cblunt
cblunt / MaskedImageView.java
Created July 25, 2012 11:22
Android MaskedImageView - Uses the Background resource as a mask for the src bitmap. If set, foregroundBitmap is overlaid on top of the masked image.
package com.example;
import android.content.Context;
import android.graphics.*;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.ImageView;
@romannurik
romannurik / DashboardLayout.java
Created March 23, 2011 05:06
A custom Android layout class that arranges children in a grid-like manner, optimizing for even horizontal and vertical whitespace.
/*
* ATTENTION:
*
* This layout is now maintained in the `iosched' code.google.com project:
*
* http://code.google.com/p/iosched/source/browse/android/src/com/google/android/apps/iosched/ui/widget/DashboardLayout.java
*
*/
/*