Skip to content

Instantly share code, notes, and snippets.

Aaron Hoffman aaronhoffman

Block or report user

Report or block aaronhoffman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View postal-code-to-state-map-condensed.csv
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 / TrivialJsonConverter.cs
Created Sep 13, 2018
Newtonsoft.Json BaseJsonConverter example
View TrivialJsonConverter.cs
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
public class TrivialJsonConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return true;
}
View find-next-value-change-in-column.vba
Sub FindNextValueChangeInColumn()
'
' FindNextValueChangeInColumn Macro
'
On Error GoTo ErrHandler
Dim currentValue As String
Dim compareValue As String
currentValue = ActiveCell.Value
View aspnet-core-2-1-identity.sql
create table [dbo].[AspNetRoleClaims] (
[Id] int IDENTITY(1, 1) not null,
[RoleId] nvarchar(450) not null,
[ClaimType] nvarchar(MAX) null,
[ClaimValue] nvarchar(MAX) null,
constraint [PK_AspNetRoleClaims] primary key clustered ([Id] asc)
);
go
create nonclustered index [IX_AspNetRoleClaims_RoleId] on [dbo].[AspNetRoleClaims] ([RoleId] asc);
@aaronhoffman
aaronhoffman / copy-older-files.ps1
Created Jun 5, 2018
PowerShell script to copy files older than a given date
View copy-older-files.ps1
# copy files older than a given date
$items = Get-ChildItem -Path ".\" | Where-Object { $_.CreationTime -le "12/31/2017" }
Write-Output "count $($items.Length)"
foreach ($item in $items)
{
Move-Item -Path $item.FullName -Destination "c:\destination\$($item.Name)"
}
@aaronhoffman
aaronhoffman / rename-check-constraint-convention.sql
Last active Nov 14, 2018
rename sql constraints to match convension
View rename-check-constraint-convention.sql
-- script to generate sp_rename commands for all check constraints
select
ck.name as current_name
,po.name as ParentObject
,po.type_desc as ParentType
,ISNULL(pc.name, N'') as ColumnName
,'exec sp_rename @objname = N''[' + ps.name + '].[' + ck.name + ']'', @newname = ''CK_' + po.name + '_' + pc.name + '''' as rename_cmd
from
sys.check_constraints ck
left join sys.objects po on (ck.parent_object_id = po.object_id)
@aaronhoffman
aaronhoffman / generate-vsts-shortcuts.sql
Last active May 25, 2018
VSTS Google Chrome Shortcuts
View generate-vsts-shortcuts.sql
-- Google Chrome stores dates in microseconds since 1601-01-01 in the `keywords` sqlite table
-- the following line generates that value
-- select (strftime('%s', datetime('now')) + 11644473600) * 1000000
-- algo used to generate a uuid per row
-- select lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))),2) || '-' || substr('89ab',abs(random()) % 4 + 1, 1) || substr(lower(hex(randomblob(2))),2) || '-' || lower(hex(randomblob(6)))
/*
Variables are not supported in sqlite.
@aaronhoffman
aaronhoffman / git-fetch-all-recurse.ps1
Created Feb 9, 2018
Given a path, find all git repos and perform a git fetch
View git-fetch-all-recurse.ps1
param (
[string]$path = "c:\dev\"
)
Write-Output "Recurse in $path for hidden .git folders..."
$gitdirs = Get-ChildItem -Recurse -Path $path -Force -Filter ".git"
Write-Output "Found: $($gitdirs.Length) repos"
@aaronhoffman
aaronhoffman / GoogleContactService.cs
Last active Aug 1, 2018
Google Contacts API Create New Contact in My Contacts System Group. more: https://www.mycontactsync.com/
View GoogleContactService.cs
public class GoogleContactService
{
public void CreateContact()
{
var cr = this.CreateContactsRequest();
var groups = cr.GetGroups().Entries.ToList();
var myContactsSystemGroup = groups.FirstOrDefault(x => x.SystemGroup == "Contacts");
var newContact = new Contact();
@aaronhoffman
aaronhoffman / convert-hashbytes-varbinary-hex-char.sql
Last active Dec 13, 2017
Convert SQL hashbytes varbinary to hex char
View convert-hashbytes-varbinary-hex-char.sql
convert(char(48), HASHBYTES('sha1', @HashInput), 2)
convert(char(64), HASHBYTES('sha2_256', @HashInput), 2)
You can’t perform that action at this time.