Skip to content

Instantly share code, notes, and snippets.

View aaronhoffman's full-sized avatar

Aaron Hoffman aaronhoffman

View GitHub Profile
@aaronhoffman
aaronhoffman / StateCodes.cs
Created October 17, 2016 21:18
State Codes United States
var stateCodes = new Dictionary<string, string>()
{
{"AL", "ALABAMA"},
{"AK", "ALASKA"},
{"AZ", "ARIZONA"},
{"AR", "ARKANSAS"},
{"CA", "CALIFORNIA"},
{"CO", "COLORADO"},
{"CT", "CONNECTICUT"},
{"DE", "DELAWARE"},
@aaronhoffman
aaronhoffman / MyContext.cs
Created October 20, 2016 19:50
Entity Framework Data Context Setup
using MyProject.Models;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
namespace MyProject.Data
{
public class MyContext : DbContext
{
public MyContext(string connectionString)
: base(connectionString)
@aaronhoffman
aaronhoffman / generate-hn-uri.sh
Last active June 23, 2021 12:33
hacker news firebase download
#!/bin/bash
# generate file containing all URIs to execute to retrieve data from hacker news firebase API
# api docs: https://github.com/HackerNews/API
echo generating file hn-uri.txt
URICOUNT=10000000
echo file will contain $URICOUNT lines
@aaronhoffman
aaronhoffman / EnumerableExtensions.cs
Created October 21, 2016 20:42
LINQ Batch Enumerable
using System.Collections.Generic;
using System.Linq;
public static class EnumerableExtensions
{
public static IEnumerable<IEnumerable<T>> Batch<T>(this IEnumerable<T> items, int batchSize)
{
return items
.Select((item, inx) => new { item, inx })
.GroupBy(x => x.inx / batchSize)
@aaronhoffman
aaronhoffman / EpochConverter.cs
Created October 24, 2016 15:45
Convert Epoch Seconds to C# DateTime
private static readonly DateTime _epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public DateTime EpochSecondsToDateTime(int secondsSinceEpoch)
{
return _epoch.AddSeconds(secondsSinceEpoch);
}
@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 / ky-county-district-map.csv
Created November 11, 2016 22:53
Kentucky United States Congressional District County Map Crosswalk
CountyName District
Adair KY1
Allen KY1
Anderson KY6
Ballard KY1
Barren KY2
Bath KY4
Bell KY5
Boone KY4
Bourbon KY6
@aaronhoffman
aaronhoffman / email-to-sms.csv
Created January 18, 2017 22:15
Map of Email to SMS Text Message For Major US Cell Phone Carriers
provider emailDomain
AT&T txt.att.net
Verizon vtext.com
US Cellular email.uscc.net
Sprint messaging.sprintpcs.com
T-Mobile tmomail.net
@aaronhoffman
aaronhoffman / KuduWebJobService.cs
Last active October 30, 2020 13:40
Start and Stop Azure WebJobs via the Kudu REST API
public class KuduWebJobService
{
private string KuduUserName { get; set; }
private string KuduPassword { get; set; }
private string AzureWebsiteName { get; set; }
public KuduWebJobService()
{
this.KuduUserName = "";
this.KuduPassword = "";
@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: