Skip to content

Instantly share code, notes, and snippets.

View chrisfcarroll's full-sized avatar
🤹‍♂️
🌍...☕...🖥️...⏳...⛪...🛌🏼

Chris F Carroll chrisfcarroll

🤹‍♂️
🌍...☕...🖥️...⏳...⛪...🛌🏼
View GitHub Profile
@chrisfcarroll
chrisfcarroll / SerilogStringListSink.cs
Last active September 21, 2017 20:58
A StringList Sink for Serilog. Typical usage:
using System;
using System.Collections.Generic;
using System.IO;
using Serilog;
using Serilog.Configuration;
using Serilog.Core;
using Serilog.Events;
using Serilog.Formatting;
using Serilog.Formatting.Display;
@chrisfcarroll
chrisfcarroll / youtube-dl-prompt.ps1
Created July 8, 2017 10:19
Youtube Downloader Prompting Wrapper : wraps youtube-dl.exe for a start-menu icon that prompts for the url to download.
param( [Parameter(Mandatory=$true)][string]$UrlToDownload )
$downloadDirectory="C:\Users\Services\Downloads"
cd $downloadDirectory
write-host ""
write-host ""
write-host "Downloading $urlToDownload to $downloadDirectory ..."
write-host ""
write-host ""
$Error.Clear()
youtube-dl.exe $urlToDownload
@chrisfcarroll
chrisfcarroll / Curl.ps1
Last active September 12, 2017 12:20
PowerShell wrapper for Invoke-WebRequest with Proxy
#
$env:Proxy="http://YOUR-CORPORATE-PROXY-HERE" ;
Add-Type -AssemblyName 'Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
function curl
{
param(
[Parameter(Mandatory=$true)][string]$Uri,
[Object]$Body,
[String]$ContentType,
[PSCredential]$Credential,
@chrisfcarroll
chrisfcarroll / karabiner.json
Last active September 21, 2017 13:14
Windows on Mac : Just the main Windows Ctrl-keystroke -> Cmd-keystroke mappings. Using Karabiner.
{
"profiles": [
{
"complex_modifications": {
"parameters": { /* ... etc ... */ },
"README": "********************************************************************************************************",
"README": "*" COPY JUST THE ELEMENTS OF THIS "rules" array into your profiles.complex_modifications.rules array. "*",
"README": "********************************************************************************************************",
"rules": [
@chrisfcarroll
chrisfcarroll / LoggingConfig.cs
Created November 9, 2017 11:45
Serilog Typical setup for Log to RollingFile from Config. with fallback
static class LoggingConfig
{
/// <summary>
/// After calling this method, use the logger with
/// <code>Log.Logger....</code>
/// e.g.
/// <see cref="Log.Logger"/>.<see cref="ILogger.Debug(string,object[])"/>
/// </summary>
public static ILogger RegisterLogger(ILogger overrideLogger=null)
{
@chrisfcarroll
chrisfcarroll / LogAssert.cs
Last active November 29, 2018 12:59
Runtime Assertion, Log.Assert, TryLog, TryElse methods
public static class LogAssert
{
public static void Assert(this ILogger logger, Func<bool> assertion, string failureMessage = "Try failed", LogEventLevel level = LogEventLevel.Debug, string successMessage=null, IEnumerable args = null)
{
try
{
var ok = assertion();
if (ok && successMessage!=null) { logger.Write(level, successMessage, args ?? new object[0]); }
if (!ok) { logger.Write(level, failureMessage, args ?? new object[0]); }
@chrisfcarroll
chrisfcarroll / vlc
Last active April 18, 2018 15:23
MacOs command line script : use VLC to transcode to mp3
#! /usr/bin/env bash
outputdirectory="`dirname ~/Music`/Music/VLCout"
albumname=""
acodec="mpga"
mux="mpeg1"
ext=".mp3"
directoryAsAlbumName=""
foldDirectoryNames=""
function showhelp {
@chrisfcarroll
chrisfcarroll / HtmlToPdfWriter.cs
Last active May 9, 2018 18:07
.Net wrapper for the very excellent https://wkhtmltopdf.org/
//Uncomment and paste into LinqPad: void Main()
//{
// var pathToWkHtmlToPdfExe=@"C:\yourpathto\wkhtmltopdf.exe";
// var outputPath=new FileInfo(Path.Combine(System.IO.Path.GetTempPath(), "htmlto.pdf"));
// var html="<html><head></head><body><style>body{font-family:\"Helvetica\"}</style><h1>Hello World</h1></body></html>";
// using(var outputstream= new MemoryStream(10000))
// {
// HtmlToPdfWriter.GeneratePdf(new StringReader(html), outputstream, new Size{Width=210,Height=297}, pathToWkHtmlToPdfExe );
// Encoding.UTF8.GetString(outputstream.GetBuffer()).Dump();
// using (var fs=outputPath.OpenWrite()){ outputstream.CopyTo(fs); }
@chrisfcarroll
chrisfcarroll / Asp.Net SignedUrls.md
Last active October 12, 2018 10:23
Signed Url Generator for .Net with Timestamp and HMACSHA512

Jealous of AWS style signed-URL links? Wish you could do that too?

Generate your own signed links with two simple classes.

<a href='/SignatureRequired/GetSecretThings?@Html.QuerystringFragmentTimestampAndSignature())>
    Get Secret Things Here
</a>
  • My use-case was to restrict the link to the original IP Address:
@chrisfcarroll
chrisfcarroll / Uninstall-Programs-Or-Features.ps1
Last active September 28, 2022 12:09
PowerShell commandline Uninstall-Programs-Or-Features.ps1
<#
.SYNOPSIS
Uninstall one or more Windows Program or Feature, by name or regular expression.
.DESCRIPTION
Lists Programs And Features installed on the current machine which match
the -matchingName parameter and then, after force or confirmation, uninstalls them.
Examples