Skip to content

Instantly share code, notes, and snippets.

View jdmallen's full-sized avatar

J.D. Mallen jdmallen

View GitHub Profile
@jdmallen
jdmallen / CustomFizzBuzz.cs
Created June 19, 2020 05:13
A custom FizzBuzz generator: you select your multiples and keywords, it'll do the rest.
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace JDMallen.Gists
{
class Program
{
public static async Task Main(string[] args)
{
@jdmallen
jdmallen / convert_binary_file_to_base64.ps1
Last active April 24, 2025 21:15
Powershell script to convert a binary file to/from a base64 text file
Param(
$filePath,
[switch]$reverse = $false
)
## Usage
#
# From binary to UTF8 base-64 file with "b64" extension:
# .\convert_binary_file_to_base64.ps1 path\to\file.bin
#
@jdmallen
jdmallen / efCoreDropTables.cs
Last active July 23, 2018 18:53
I wrote this snippet to drop all my MariaDB tables and rebuild them using EnsureCreated each time I ran the app to ensure I got the tables and relationships I wanted from my modelBuilder settings in EF Core 2.1. For reference, `dbContext` is of EF type DbContext and I'm injecting it into the Configure method of the Startup class to call the below.
#if DEBUG
var conn = dbContext.Database.GetDbConnection();
conn.Open();
dbContext.Model.GetEntityTypes()
.ToList()
.ForEach( // For each of the entity types registered in the model...
et =>
{
bool tableExists;
// Fetch its table name, whether it's set in OnModelCreating
@jdmallen
jdmallen / urlParseRegex.js
Last active April 16, 2018 18:28
Regex pattern to capture the domain and params of a URL
// Regex:
// /(?:https?:\/\/)?(?:www\.)?([-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6})(?:[:]?[0-9]{0,5})([-a-zA-Z0-9@:%_\+.~#?&\/=]*)/i
function extractUrlParts(url) {
var matches =
/(?:https?:\/\/)?(?:www\.)?([-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6})(?:[:]?[0-9]{0,5})([-a-zA-Z0-9@:%_\+.~#?&\/=]*)/i
.exec(url);
return {
domain: matches && matches[1],
params: matches && matches[2]
@jdmallen
jdmallen / .gitconfig
Last active July 6, 2021 22:49
My complete .gitconfig file that I take everywhere I go. I included comments for all my aliases that aren't obvious.
[user]
name = J.D. Mallen
email =
# uncomment the below to add a GPG signing key
#signingkey =
[core]
askpass = git-gui--askpass
autocrlf = true
editor = vim
pager = less -x1,3
@jdmallen
jdmallen / .bashrc
Last active July 6, 2021 22:51
A .bashrc script that automatically spawns ssh-agent and adds your identities upon first load
# This .bashrc snippet is primarily geared toward those who use Git Bash for
# Windows. Save this file in the root of your user folder; e.g., C:\Users\jesse,
# or /c/Users/jesse in Git Bash parlance. This app checks to see if ssh-agent
# is running, and if it isn't, starts it and adds any private keys you desire.
# It will only do this once per Windows session, or until ssh-agent is killed.
# Now you don't have to keep loading your key or typing in your git remote
# password repeatedly. I have no reason to believe this would not work equally
# well in a Linux environment. Save it as (or append to) ~/.bashrc
SSH_ENV=~/.ssh/environment
@jdmallen
jdmallen / pre-commit
Created February 9, 2018 23:10
Handy git pre-compile hook to prevent yourself from committing passwords
#!/bin/sh
# Save this file in your {repoRoot}/.git/hooks directory with the filename
# 'pre-commit' (no extension), and replace the passwords with your own. Don't
# worry: this file does not get committed. It exists only where you place it.
# Fair warning, though: you are essentially saving your password in plaintext.
# Ensure that you have other security measures in place to protect your data;
# e.g., drive encryption, station locking, etc.
. git-sh-setup # for die

Keybase proof

I hereby claim:

  • I am jdmallen on github.
  • I am jdmallen (https://keybase.io/jdmallen) on keybase.
  • I have a public key whose fingerprint is 34A4 E436 C02E DA37 0D35 C784 5A3B 55F7 0CE4 381E

To claim this, I am signing this object: