Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Hoffman aaronhoffman

View GitHub Profile
@aaronhoffman
aaronhoffman / iphone-text-message-sqlite.sql
Last active Jul 20, 2020
SQLite SQL Query for iPhone Text Message Backup
View iphone-text-message-sqlite.sql
-- 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
View RedditOAuthApiController.cs
public ActionResult StartOAuth()
{
var redditOAuthAuthorizeUri = "https://www.reddit.com/api/v1/authorize";
var redditOAuthRedirectUri = "https://localhost:44399/RedditRedirectUri"; // your redirect uri
var redditOAuthScopes = ""; // ex: "identity,history" scope param https://github.com/reddit/reddit/wiki/OAuth2#authorization
var redditClientId = ""; // from app: https://www.reddit.com/prefs/apps
var oauthState = Guid.NewGuid(); // used to uniquely identify this request
// todo: store oauthState somewhere...
@aaronhoffman
aaronhoffman / message.txt
Created Dec 5, 2017
keybase just for fun
View message.txt
-----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
@aaronhoffman
aaronhoffman / git-bc.cmd
Created Mar 2, 2017
Configure Beyond Compare 4 as git diff tool on windows 10
View git-bc.cmd
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 Apr 14, 2017
git hooks - prevent commit to local master branch and prevent push to remote master branch
View pre-commit
#!/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
@aaronhoffman
aaronhoffman / 20200213083642_InitialIdentityServerConfigurationDbMigration.Designer.cs
Last active Feb 13, 2020
IdentityServer Configuration SQL Tables EF Migration Issue
View 20200213083642_InitialIdentityServerConfigurationDbMigration.Designer.cs
// <auto-generated />
using System;
using IdentityServer4.EntityFramework.DbContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace SqlServer.Data.Migrations.IdentityServer.ConfigurationDb
@aaronhoffman
aaronhoffman / RSACryptoServiceProviderHelper.cs
Created Feb 11, 2020
Convert RSACryptoServiceProvider ToXmlString RsaXML W3C XKMS format to Public Private key PEM base64 string
View RSACryptoServiceProviderHelper.cs
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
public class RSACryptoServiceProviderHelper
{
// code from here:
// - https://stackoverflow.com/questions/23734792/c-sharp-export-private-public-rsa-key-from-rsacryptoserviceprovider-to-pem-strin
// - https://stackoverflow.com/questions/28406888/c-sharp-rsa-public-key-output-not-correct/28407693#28407693
@aaronhoffman
aaronhoffman / AesKeyGenerator.cs
Last active Oct 15, 2019
Generate Random AES Encryption Key
View AesKeyGenerator.cs
public static class AesKeyGenerator
{
public static string GenerateKey(int bitStrength)
{
// note: valid bit strength for aes: 128, 192, or 256 bits (16, 24, or 32 bytes)
var random = new System.Security.Cryptography.RNGCryptoServiceProvider();
var keyArray = new byte[bitStrength / 8];
random.GetBytes(keyArray);
var base64key = Convert.ToBase64String(keyArray);
@aaronhoffman
aaronhoffman / TileSystem.cs
Created May 26, 2016
Convert WGS84, latitude, longitude, to Web Mercator, Google Maps, Bing Maps, Pixel Coordinates
View TileSystem.cs
// 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 / generate-hn-uri.sh
Last active Sep 23, 2019
hacker news firebase download
View generate-hn-uri.sh
#!/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
You can’t perform that action at this time.