Skip to content

Instantly share code, notes, and snippets.

View aaronhoffman's full-sized avatar

Aaron Hoffman aaronhoffman

View GitHub Profile
@aaronhoffman
aaronhoffman / TileSystem.cs
Created May 26, 2016 00:53
Convert WGS84, latitude, longitude, to Web Mercator, Google Maps, Bing Maps, Pixel Coordinates
// source: https://msdn.microsoft.com/en-us/library/bb259689.aspx
//------------------------------------------------------------------------------
// <copyright company="Microsoft">
// Copyright (c) 2006-2009 Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Text;
@aaronhoffman
aaronhoffman / iphone-text-message-sqlite.sql
Last active February 2, 2024 11:45
SQLite SQL Query for iPhone Text Message Backup
-- more info http://aaron-hoffman.blogspot.com/2017/02/iphone-text-message-sqlite-sql-query.html
select
m.rowid
,coalesce(m.cache_roomnames, h.id) ThreadId
,m.is_from_me IsFromMe
,case when m.is_from_me = 1 then m.account
else h.id end as FromPhoneNumber
,case when m.is_from_me = 0 then m.account
else coalesce(h2.id, h.id) end as ToPhoneNumber
,m.service Service
@aaronhoffman
aaronhoffman / SpotifyApiController.cs
Created September 14, 2016 17:39
Spotify Web API Auth Example C#
public class SpotifyApiController
{
//see https://developer.spotify.com/web-api/authorization-guide/#client_credentials_flow
public void GetClientCredentialsAuthToken()
{
var spotifyClient = "";
var spotifySecret = "";
var webClient = new WebClient();
@aaronhoffman
aaronhoffman / ConvertVarbinaryToByteArray.cs
Created February 23, 2016 00:58
Convert SQL Server Management Studio SSMS Varbinary Column Output to Byte Array C#
static void Main(string[] args)
{
// read input from local file (could also pass in via args)
var hexInput = File.ReadAllText("hexInput.txt");
// convert to binary, strip off first two chars 'Ox'
var byteArray = StringToByteArray(hexInput.Substring(2));
// write bytes to file
File.WriteAllBytes("output.file", byteArray);
@aaronhoffman
aaronhoffman / git-bc.cmd
Created March 2, 2017 02:50
Configure Beyond Compare 4 as git diff tool on windows 10
git config --global diff.tool bc
git config --global difftool.bc.path "C:\Program Files\Beyond Compare 4\BComp.exe"
git config --global merge.tool bc
git config --global mergetool.bc.path "C:\Program Files\Beyond Compare 4\BComp.exe"
git config --global alias.mydiff "difftool --dir-diff --tool=bc --no-prompt"
@aaronhoffman
aaronhoffman / pre-commit
Created April 14, 2017 15:25
git hooks - prevent commit to local master branch and prevent push to remote master branch
#!/bin/sh
# prevent commit to local master branch
branch=`git symbolic-ref HEAD`
if [ "$branch" = "refs/heads/master" ]; then
echo "pre-commit hook: Can not commit to the local master branch."
exit 1
fi
exit 0
StateName StateCode CondensedPostalCodeRanges
Alabama AL 35000-35299;35400-36999
Alaska AK 99500-99999
Arizona AZ 85000-85399;85500-85799;85900-86099;86300-86599
Arkansas AR 71600-72999
California CA 90000-90899;91000-92899;93000-96199
Colorado CO 80000-81699
Connecticut CT 06000-06389;06391-06999
Delaware DE 19700-19999
District of Columbia DC 20000-20099;20200-20587;56900-56999;20589-20597;20599
@aaronhoffman
aaronhoffman / ThreadSafeConcurrentDictionary.cs
Created November 13, 2020 18:18
Async Thread Safe Concurrent Dictionary
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
public class ThreadSafeConcurrentDictionary
{
public bool TryGetValue<TValue>(string key, out TValue value)
{
return _dictionary.TryGetValue(key, out value);
@aaronhoffman
aaronhoffman / search-db-for-guid.sql
Created October 25, 2016 20:33
SQL Query to search every guid/uniqueidentifier column in a database for the given id
-- SQL Query to search every guid/uniqueidentifier column in a database for the given id
declare @Id uniqueidentifier = 'ED4D0741-B092-4F0A-9E10-51C19265357C'
-- set to 1 to only search within columns that have '%id%' in the name, for all columns of uniqueidentifier type, set to 0
declare @onlyColumnsWithIdInName bit = 1
declare @Columns table (TableName varchar(200), ColumnName varchar(200))
insert into @Columns (TableName, ColumnName)
select
@aaronhoffman
aaronhoffman / keybase.md
Created February 9, 2017 14:26
keybase.md

Keybase proof

I hereby claim:

  • I am aaronhoffman on github.
  • I am aaronhoffman (https://keybase.io/aaronhoffman) on keybase.
  • I have a public key whose fingerprint is CA49 A892 C3FF 3F8B 95B4 8309 B693 4228 86D5 7E4F

To claim this, I am signing this object: