Skip to content

Instantly share code, notes, and snippets.

View JustinStolle's full-sized avatar

Justin Stolle JustinStolle

View GitHub Profile
@JustinStolle
JustinStolle / multiline-to-in-clause.js
Last active February 15, 2023 08:31
(TextExpander) Multi-line clipboard to a SQL IN clause
// Trim and split the clipboard text on newlines, returning only the unique values as an array
let values = [...new Set(TextExpander.pasteboardText.trim().split(/\r?\n|\r|\n/g))];
// Determine if there are some values that are not integers
if (values.some(x => isNaN(parseInt(x)))) {
// Enclose each value in single quotes while escaping any single quotes found in the value itself
values = values.map(s => `'${s.replace(/'/g, "''")}'`);
}
// Return the list as an IN fragment
@JustinStolle
JustinStolle / .bashrc
Created May 5, 2022 19:00
Launch Notepad++ using 'npp' from Git Bash without waiting for a return code
alias nplusplus='/c/Program\ Files/Notepad++/notepad++.exe'
npp() {
nplusplus $* &
}
@JustinStolle
JustinStolle / ToSelectList.cs
Last active November 5, 2022 19:57
Creates an IEnumerable<SelectListItem> from an IEnumerable<T>.
//-----------------------------------------------------------------------
// <copyright file="ToSelectList.cs">
// Copyright Justin C. Stolle. All rights reserved.
// Licensed under the MIT License.
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;