Skip to content

Instantly share code, notes, and snippets.

View dterracino's full-sized avatar
🐢
I may be slow to respond…

David Terracino dterracino

🐢
I may be slow to respond…
View GitHub Profile
internal static class ExtensionMethods
{
public static bool TryDequeue<T>(this Queue<T> queue, out T result)
{
result = default;
if (queue == null || !queue.Any())
{
return false;
}
result = queue.Dequeue();
@JoshData
JoshData / epapercmd.cpp
Last active November 10, 2024 13:21
Waveshare e-paper driver tool
/*
* A Waveshare E-Paper controller via a simple web API
*
* This C++ program creates a simple HTTP server to control a Waveshare
* e-Paper display, like the 10.3inch e-Paper e-Ink Display HAT For
* Raspberry Pi at https://www.waveshare.com/10.3inch-e-Paper-HAT.htm
* which I am using. This program is meant to be run on the Pi that is
* connected to the e-Paper display.
*
* When run, this program creates a simple web server that serves a
using System;
using System.Collections.Generic;
using System.Text;
namespace tests
{
public static class ExtensionMethods
{
/// <summary>
/// Returns the TimeSpan text in a concise way
@crazy-max
crazy-max / git-empty-commit.md
Last active October 17, 2020 21:34
Create Git empty commit

In case you want to trigger an event on GitHub, you can create an empty commit:

$ git commit --allow-empty -m "Trigger event"
@JoshData
JoshData / zipcode_database.py
Last active February 14, 2021 05:57
Severless ZIP code database
# Pull ZIP code latitude/longitude coordinates from Geonames.org
# and write them out to a sharded flat-file database that makes
# it easy to efficiently query the database from the browser without
# any backend server. The Geonames database has a CC-BY license so
# credit must be given in the application.
#
# There are about 41,000 ZIP codes in the database, and with their
# lat/lng coordinate it's about 1MB of data, which a browser could
# load but it's kind of a lot of data for a browser to download and
# process. With state and place names, which might make for a nicer
@josheinstein
josheinstein / DateFunctions.sql
Last active June 11, 2024 01:37
Creates various MSSQL scalar functions to get dates relative to the current date.
CREATE FUNCTION [Today]() RETURNS date AS BEGIN RETURN CONVERT(date, GETUTCDATE()) END;
GO
CREATE FUNCTION [Tomorrow]() RETURNS date AS BEGIN RETURN CONVERT(date, DATEADD(day, 1, GETUTCDATE())) END;
GO
CREATE FUNCTION [Yesterday]() RETURNS date AS BEGIN RETURN CONVERT(date, DATEADD(day, -1, GETUTCDATE())) END;
GO
CREATE FUNCTION [ThisMonthStart]() RETURNS date AS BEGIN RETURN CONVERT(date, DATEADD(day, 1-DATEPART(day, GETUTCDATE()), GETUTCDATE())) END;
GO
CREATE FUNCTION [ThisMonthEnd]() RETURNS date AS BEGIN RETURN CONVERT(date, DATEADD(day, -1, DATEADD(month, 1, DATEADD(day, 1-DATEPART(day, GETUTCDATE()), GETUTCDATE())))) END;
GO
@ZacharyPatten
ZacharyPatten / TowelCommandLineComparisons.md
Created September 10, 2020 02:16
Towel CommandLine Comparisons

This is a comparison between Towel's CommandLine implementation and other similar command line parsers.

Here is an example of Towel's CommandLine:

using System;
using System.IO;
using static Towel.CommandLine;

namespace ConsoleApp
{
@ZacharyPatten
ZacharyPatten / HiddenConsoleReadLine.cs
Last active July 31, 2024 15:42
C# custom Console.ReadLine with hidden characters
using System;
using Towel;
namespace ConsoleApp1
{
class Program
{
static void Main()
{
Console.WriteLine(
@ZacharyPatten
ZacharyPatten / ConsoleColoring.cs
Created August 27, 2020 17:42
An example of a helper method for console output settings.
using System;
public class Program
{
public static void Main()
{
Console.WriteLine("hi mom");
ConsoleHelper.DoWith(
action: () => Console.WriteLine("hi mom"),
@sachinsu
sachinsu / extensions.cs
Created August 27, 2020 07:20
Retrying while Opening connection to Oracle Database using Polly
using System;
using Oracle.ManagedDataAccess.Client;
using Polly;
namespace frontend.ExtensionMethods
{
public static class Extensions
{
const int retryTimes = 3;