Skip to content

Instantly share code, notes, and snippets.

View jcpst's full-sized avatar
💯

Joseph Post jcpst

💯
View GitHub Profile
@spencerkittleson
spencerkittleson / .editorconfig
Last active November 12, 2024 01:30
c# K&R Editor Config
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.cs]
@SaahilClaypool
SaahilClaypool / Result.cs
Last active September 20, 2024 07:42
C# Result & Option type
using System;
namespace Utils
{
public struct Option<T>
{
public T Value { get; set; }
public bool HasValue { get; set; }
private Option(T value, bool hasValue)
@kissgyorgy
kissgyorgy / listen.py
Created September 4, 2020 16:37
How to use PostgreSQL's LISTEN/NOTIFY as a simple message queue with psycopg2 and asyncio
import asyncio
import psycopg2
# dbname should be the same for the notifying process
conn = psycopg2.connect(host="localhost", dbname="example", user="example", password="example")
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
cursor = conn.cursor()
cursor.execute(f"LISTEN match_updates;")
@domenic
domenic / portable-node.md
Created May 25, 2012 21:03
Tips for Writing Portable Node.js Code

Node.js core does its best to treat every platform equally. Even if most Node developers use OS X day to day, some use Windows, and most everyone deploys to Linux or Solaris. So it's important to keep your code portable between platforms, whether you're writing a library or an application.

Predictably, most cross-platform issues come from Windows. Things just work differently there! But if you're careful, and follow some simple best practices, your code can run just as well on Windows systems.

Paths and URLs

On Windows, paths are constructed with backslashes instead of forward slashes. So if you do your directory manipulation