Skip to content

Instantly share code, notes, and snippets.

View DavidPx's full-sized avatar

David Peters DavidPx

  • Direct Supply
View GitHub Profile
@DavidPx
DavidPx / readme.md
Last active February 13, 2024 04:14
CopyQ Commands

These are CopyQ commands I use for copying data out of spreadsheets and into SQL windows.

single-quoted-list.ini is good for creating an in clause from a single column of values.

values-grid.ini is good for creating the values section of an insert statement.

Installing these is quite easy:

  1. Copy the script
  2. Within Copyq hit F6 to bring up the Command editor
  3. Now click the Paste Commands button
@DavidPx
DavidPx / FileEvent.cs
Created August 24, 2022 16:49
Solving FileSystemWatcher Multiple Changed Events with System.Reactive
public class FileEvent
{
public FileEvent(string fullPath, WatcherChangeTypes changeTypes)
{
FullPath = fullPath;
ChangeType = changeTypes;
}
public string FullPath { get; set; }
public WatcherChangeTypes ChangeType { get; set; }
}
@DavidPx
DavidPx / MyExtensions.cs
Created June 14, 2021 18:03
Dave's Linqpad Extension Methods
// Everyone has their own set of oddball extension methods.. here are mine.
void Main()
{
// Write code to test your extensions here. Press F5 to compile and run.
}
public static class MyExtensions
{
/// <summary>
@DavidPx
DavidPx / BulkInsertAll.cs
Last active January 15, 2020 16:39 — forked from jmreynolds/BulkInsertAll.cs
Use SQLBulkLoad with linq-toSQL in LinqPad - now with Property support.
// Add this to LinqPad "C# Program"
// Example use:
// Insead of this: (create a List<CS_POSITION>)
// CS_POSITIONs.InsertOnSubmit(position);
// This:
// positions.Add(position);
//
// Then instead of this:
// SubmitChanges()
// This:
@DavidPx
DavidPx / Program.cs
Last active May 24, 2019 21:05
.Net Core 2.1 Testable HttpClient with Dependency Injection
public class Program : IProgram
{
public Program(/* stuff your program needs */)
{
}
private static void Main(string[] args)
{
var serviceProvider = Startup.RegisterDependencies(); // note that we do not pass in a DI modifier
var program = (IProgram)serviceProvider.GetService(typeof(IProgram));
<Query Kind="Statements">
<NuGetReference>CsvHelper</NuGetReference>
<Namespace>CsvHelper</Namespace>
</Query>
// NPR Sunday Puzzle for 2017-12-24
// city data: https://github.com/grammakov/USA-cities-and-states
var cities = new List<string>();
@DavidPx
DavidPx / FishFarm.ahk
Created December 16, 2017 21:18
Minecraft FishFarm AFK AutoHotKey Script
; this has been tested on 1.12.2 against this farm: https://www.youtube.com/watch?v=Y31TEbKjSpg
; ctrl + alt + f starts the loop. Every 1/2 second the right mouse button is clicked.
^!f::
BreakLoop = 0
Loop
{
if (BreakLoop = 1)
{
BreakLoop = 0