Skip to content

Instantly share code, notes, and snippets.

View jmlane's full-sized avatar

Jonathan M. Lane jmlane

  • Fredericton, NB, Canada
  • X @jmlane
View GitHub Profile
@davidfowl
davidfowl / FromSqlInterpolatedStringHandler.cs
Last active July 3, 2023 12:55
Implementation of parameterized sql queries using string interpolation handlers
using System.Data.Common;
using System.Runtime.CompilerServices;
using System.Text;
using Npgsql;
GetCatalogItemsSql(null, null, null, 10);
void GetCatalogItemsSql(int? catalogBrandId, int? before, int? after, int pageSize)
{
// This looks like it would be susceptible to SQL injection, but it's not.
@dadhi
dadhi / main.cs
Last active September 28, 2022 15:04
Discriminated Union (sum-type, co-product) from Algebraic Data Types (ADT) for C# which is memory efficient, supports one-line sub-typing
using System;
using System.Collections.Generic;
using static System.Console;
namespace Union
{
class Program
{
public static void Main()
{
@jessfraz
jessfraz / boxstarter.ps1
Last active April 11, 2024 16:02
Boxstarter Commands for a new Windows box.
# Description: Boxstarter Script
# Author: Jess Frazelle <jess@linux.com>
# Last Updated: 2017-09-11
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#
# You might need to set: Set-ExecutionPolicy RemoteSigned
#
# Run this boxstarter by calling the following from an **elevated** command-prompt:
@Jaykul
Jaykul / ReadMe.md
Last active November 26, 2019 15:46
Making Publish-Module work with VisualStudio.com

This is a simple workaround solution for a complicated problem with registering VisualStudio online NuGet packages repositories as PowerShell module repositories.

The Problem with PowerShellGet

PowerShellGet just doesn't work with NuGet CredentialProviders, because it uses the -noninteractive switch whenever it calls nuget. However, the VisualStudio.com (VSO) nuget package repositories can work as internal PowerShell Galleries, because passing the credentials to Find-Module and Install-Module does work ...

Basically, the problem is two fold: authentication when publishing, and authentication when searching or installing. The second problem can be dealt with, inconveniently, by passing credentials every time. But the first cannot. These VSO repositories require a Credential Provider plugin to handle Microsoft Authentication (including support for 2-factor au

//#include "\a3\ui_f\hpp\defineDIKCodes.inc"
#ifndef DIK_ESCAPE
/****************************************************************************
*
* DirectInput keyboard scan codes
*
****************************************************************************/
@GeorgeDettmer
GeorgeDettmer / incapacitate.sqf
Last active April 27, 2016 15:56
Incapacitate at 95% damage and prevent damage until revived/bleedout
.25 spawn {
while {TRUE} do {
_ct = cursorTarget;
_actions = [];
_crew = [];
if (_ct isKindOf "LandVehicle") then {
_crew = crew _ct;
if (_crew isEqualTo []) exitWith {};
{
if (_x getVariable ["#MOSES#incapacitated",true]) then {
@pera
pera / gist:2624765
Created May 6, 2012 22:02
Improve move speed on Vim
" Improve move speed
let g:boostmove=0
set updatetime=500
au CursorMoved * call BoostMoveON()
au CursorMovedI * call BoostMoveON()
au CursorHold * call BoostMoveOFF()
au CursorHoldI * call BoostMoveOFF()
function BoostMoveON()
if (winline() != line('$')) && (line('.') != 1)
if (winline() == winheight('.')) || (winline() == 1)