Skip to content

Instantly share code, notes, and snippets.

Avatar
🦄
What a mess I've made

Stephen Jennings jennings

🦄
What a mess I've made
View GitHub Profile
@jennings
jennings / InstallPapercutSmtpServer.ps1
Created Jan 16, 2019
Installs the Papercut SMTP Server
View InstallPapercutSmtpServer.ps1
# Using 5.1.23 because 5.1.70 has a bug that prevents the GUI from opening
$tag = "5.1.23"
$downloadUrl = "https://github.com/ChangemakerStudios/Papercut/releases/download/$tag/Papercut.Setup.exe"
$outputFileName = "$($env:TEMP)\Papercut.Setup.exe"
# Download
del $outputFileName -Force -ErrorAction SilentlyContinue
Invoke-WebRequest $downloadUrl -OutFile $outputFileName
# Install
@jennings
jennings / incremental-filter-branch.sh
Last active Jan 10, 2019
Using the `--state-branch` option to `git-filter-branch` to incrementally filter a branch
View incremental-filter-branch.sh
#!/bin/bash
set -exuo pipefail
TRUNK=master
REWRITE_BRANCH=master-to-rewrite
NEW_BRANCH_BOOKMARK=master-filtered
LAST_IMPORT_BRANCH=master-lastimport
STATE=master-state
INDEX_FILTER_SCRIPT='git rm -r --cached --ignore-unmatch bad_directory'
@jennings
jennings / CustomRules.js
Last active Aug 17, 2018
Terminating TLS/SSL with Fiddler
View CustomRules.js
static function redirectHttpsToHttp(oSession: Session, fromHost, toHost) {
if (oSession.HostnameIs(fromHost))
{
// Handle CONNECT Tunnels
if (oSession.HTTPMethodIs("CONNECT"))
{
oSession["x-replywithtunnel"] = "FakeTunnel";
return true;
}
@jennings
jennings / input.js
Created Jun 13, 2018
UglifyJS reproduction
View input.js
function fn1() {
return function fn2(ARG1) {
return callApi({ foo: ARG1 })
.then(handler);
function handler(response) {
const obj = { PROP: response };
return (inlinedFunction(obj.PROP))
.then(fn3());
}
@jennings
jennings / ThrowVsThrowEx.cs
Last active Mar 9, 2018
Demonstrates how `throw ex` replaces the stack trace in an exception, while `throw` preserves it.
View ThrowVsThrowEx.cs
using System;
class Program
{
static void One() { Two(); }
static void Two() { Three(); }
static void Three() { throw new Exception("Error"); }
static void Main(string[] args)
{
@jennings
jennings / dotenv.rb
Last active Jan 28, 2018
Executes a command after adding a `.env` file to the environment. This is probably terribly unsafe.
View dotenv.rb
#!/usr/bin/env ruby
# usage: dotenv irb
begin
File.foreach('.env') do |line|
line = line.strip
unless line.start_with?('#')
parts = line.split '=', 2
if parts.length == 2
View MicrosoftExtensionsConfigurationKeysToJson.cs
// paste this into a LINQPad C# Program
void Main()
{
var str = @"Key1=Value1
Key2:Key3=Value2";
var strings = str.Split(new []{"\r\n"}, StringSplitOptions.None)
.Select(s => s.Split(new[]{'='}, 2));
@jennings
jennings / CSharp_Throw_vs_ThrowEx.cs
Last active Sep 19, 2017
`throw` vs. `throw ex` in C#
View CSharp_Throw_vs_ThrowEx.cs
using System;
namespace ConsoleApplication1
{
public class Program
{
public static void Main()
{
try
{
View Profile.ps1
# Truncate paths in the prompt to 2 characters so long directories don't take up the whole window
function Prompt {
$path = $ExecutionContext.SessionState.Path.CurrentLocation
$segment = Split-path -Leaf $path
$path = Split-Path $path
$segments = @( $segment )
while ($segment -ne $path -and $path -ne "") {
$segment = Split-Path -Leaf $path
View enumerable.js
function Enumerable(arr) {
this.toArray = function () {
return arr
}
this.filter = function (fn) {
return new Enumerable(arr.filter(fn))
}
this.map = function (fn) {
You can’t perform that action at this time.