Skip to content

Instantly share code, notes, and snippets.

@dieseltravis
dieseltravis / makecert.ps1
Last active October 17, 2025 17:59
generate and install a self-signed certificate for localhost in powershell
# NOTE: this has to be run as administrator
# generate self-signed cert for the local test.internal domain name, set the expiration to 10 years from now
$domain = "test.internal"
$cert = New-SelfSignedCertificate -DnsName "$domain", "localhost" -FriendlyName "$domain" -KeyExportPolicy Exportable -CertStoreLocation cert:\LocalMachine\My -NotAfter (Get-Date).AddYears(10)
# export the cert to a temp file
Export-Certificate –Cert $cert –FilePath "$env:temp\export.cer"
# import the cert to the trusted root
@dieseltravis
dieseltravis / LICENSE
Last active October 2, 2019 01:35
https://firstdonoharm.dev/ Hippocratic License v1.1
Copyright 2019 Travis Hardiman
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* The software may not be used by individuals, corporations, governments, or other groups for systems or activities that actively and knowingly endanger, harm, or otherwise threaten the physical, mental, economic, or general well-being of individuals or groups in violation of the United Nations Universal Declaration of Human Rights (https://www.un.org/en/universal-declaration-human-rights/).
@dieseltravis
dieseltravis / profiles.json
Last active August 8, 2019 19:58
Windows Terminal (Preview) Version: 0.3.2171.0
{
"globals" :
{
"alwaysShowTabs" : true,
"defaultProfile" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"initialCols" : 120,
"initialRows" : 30,
"keybindings" :
[
{
@dieseltravis
dieseltravis / GetMaxLength.cs
Last active July 17, 2019 22:40
get max length of db column using entity framework, use that to truncate the value
//using System;
//using System.Data.Entity.Core.Metadata.Edm;
//using System.Data.Entity.Infrastructure;
//using System.Linq;
//using System.Linq.Expressions;
public static int GetMaxLength<T>(Expression<Func<T, string>> column)
{
int result = -1;
var entType = typeof(T);
@dieseltravis
dieseltravis / LazyListToCsv.cs
Created July 16, 2019 22:10
lazily using LINQ Aggregate to reduce a List of strings to a CSV format (this is only for quick/dirty applications, it doesn't escape values)
//using System.Linq;
List<List<string>> SomeData = new List<List<string>>();
// add values (first item as column names)
SomeData.Add(new List<string>
{
"Id",
"Name",
"etc"
@dieseltravis
dieseltravis / GetDynamic.cs
Created July 16, 2019 22:04
GetDynamic - converts any class into a dynamic ExpandoObject
//using System.Collections.Generic;
//using System.ComponentModel;
//using System.Dynamic;
private static dynamic GetDynamic(object value)
{
IDictionary<string, object> expando = new ExpandoObject();
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(value.GetType()))
{
//using Newtonsoft.Json;
//private const bool FORMAT_JSON = true;
private static string GetJson(object convertToJson)
{
string serial = JsonConvert.SerializeObject(convertToJson, FORMAT_JSON ? Formatting.Indented : Formatting.None);
return serial;
}
@dieseltravis
dieseltravis / fetch.sh
Last active January 30, 2024 15:57
various update checking shell scripts: `~/fetch.sh` or `sudo ~/update.sh`
#!/bin/bash
set -euo pipefail
INFO='\e[38;05;14m'
NC='\033[0m' # No Color
# apt
echo -e "${INFO}apt update${NC}";
sudo apt update && echo -e "${INFO}apt list --upgradable${NC}" && apt list --upgradable;
# snap
@dieseltravis
dieseltravis / blockstack.txt
Last active February 24, 2019 19:43
blockstack
Verifying my Blockstack ID is secured with the address 1JFNUe8sgLv5EvjjRa6yAQ5eTBdVUFYUzy https://explorer.blockstack.org/address/1JFNUe8sgLv5EvjjRa6yAQ5eTBdVUFYUzy
@dieseltravis
dieseltravis / powershell.json
Created May 9, 2018 17:20 — forked from rkeithhill/powershell.json
PowerShell snippets file for Visual Studio Code - place in your ~\AppData\Roaming\Code\User\Snippets directory
{
"Condition statement": {
"prefix": "cond",
"body": [
"${_} { ${0}; break }"
],
"description": "Switch condition statement"
},
"Condition single quoted string statement": {