Skip to content

Instantly share code, notes, and snippets.

View aaronhoffman's full-sized avatar

Aaron Hoffman aaronhoffman

View GitHub Profile
Sub FindNextValueChangeInColumn()
'
' FindNextValueChangeInColumn Macro
'
On Error GoTo ErrHandler
Dim currentValue As String
Dim compareValue As String
currentValue = ActiveCell.Value
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 June 5, 2018 13:25
PowerShell script to copy files older than a given date
# 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 November 14, 2018 17:05
rename sql constraints to match convension
-- 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 20:21
VSTS Google Chrome Shortcuts
-- 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 February 9, 2018 20:07
Given a path, find all git repos and perform a git fetch
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 August 1, 2018 20:01
Google Contacts API Create New Contact in My Contacts System Group. more: https://www.mycontactsync.com/
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 December 13, 2017 17:23
Convert SQL hashbytes varbinary to hex char
convert(char(48), HASHBYTES('sha1', @HashInput), 2)
convert(char(64), HASHBYTES('sha2_256', @HashInput), 2)
@aaronhoffman
aaronhoffman / INotifyPropertyChangedExtensions.cs
Last active December 6, 2017 21:57
Visual Studio 2017 Code Snippet INotifyPropertyChanged
public static void OnPropertyChanged<T>(
this INotifyPropertyChanged @this,
PropertyChangedEventHandler propertyChanged,
Expression<Func<T>> propertyExpr)
{
if (propertyChanged == null) return;
var memberExpr = (MemberExpression)propertyExpr.Body;
var ea = new PropertyChangedEventArgs(memberExpr.Member.Name);
@aaronhoffman
aaronhoffman / message.txt
Created December 5, 2017 17:17
keybase just for fun
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
keybase is fun!
-----BEGIN PGP SIGNATURE-----
Version: Keybase OpenPGP v2.0.76
Comment: https://keybase.io/crypto
wsBcBAABCgAGBQJaJtRyAAoJEGnJ5Wt+lYeyjTIH/13v97tzANkiSM3i+Vbr9Q8g
isis5gh3+4slL2SgsiF0YvnUH5o2hycYArm6r05DLdPZ2rja1YEzB1K0IV2EoAad