Skip to content

Instantly share code, notes, and snippets.

View nickpreston24's full-sized avatar
🏠
Working remote

Nicholas Preston nickpreston24

🏠
Working remote
View GitHub Profile
@nickpreston24
nickpreston24 / ObjectToDictionaryHelper.cs
Created April 25, 2024 01:14 — forked from jarrettmeyer/ObjectToDictionaryHelper.cs
C# convert an object to a dictionary of its properties
public static class ObjectToDictionaryHelper
{
public static IDictionary<string, object> ToDictionary(this object source)
{
return source.ToDictionary<object>();
}
public static IDictionary<string, T> ToDictionary<T>(this object source)
{
if (source == null)
@nickpreston24
nickpreston24 / curl.sh
Created March 31, 2024 14:21 — forked from FylmTM/curl.sh
Neo4j curl call example
#!/bin/bash
QUERY=query.json
time curl -i -XPOST \
-o output.log \
--data "@$QUERY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
http://127.0.0.1:7474/db/data/transaction/commit
#find
"(\w+)":\s*(.*),
#replace with
public string $1 {get;set;} = "$2";
# then fix 2x double quotes
#find
""
#replace with
"
@nickpreston24
nickpreston24 / TypeExtensions.cs
Created January 30, 2024 03:32
Please for the love of all that is dotnet, let's do Less Null Checking!
namespace Extensions.Types;
public static class TypeExtensions
{
/*
*
* String to Type Converters
*
* WHY? Because converting VB to C# and handling null strings with a bunch of `if` statement is a waste of your time and mine...
* How? Ternary logic and fallbacks (or default)
@nickpreston24
nickpreston24 / filter-out-via-spammers
Created November 18, 2023 03:44
Filters out 'via' spammers in Gmail
let debug_mode = true;
// Filters out emails sent on behalf of some other server they might be impersonating
// E.g. mg3.ceipalmm.com
// TODO: put your own mail domains in this array. Mine are samples.
var my_blacklisted_domains = [
"X-Feedback-Id: postmaster@mg3.ceipalmm.com"
,"X-Feedback-Id: postmaster@mg4.ceipalmm.com"];
@nickpreston24
nickpreston24 / GetSellers.sql
Created January 19, 2023 02:33 — forked from rflechner/GetSellers.sql
How to store SQL files in assembly and execute them in C#
-- this file Embedded resource
SELECT * FROM "Sellers"
@nickpreston24
nickpreston24 / GetSellers.sql
Created January 19, 2023 02:33 — forked from rflechner/GetSellers.sql
How to store SQL files in assembly and execute them in C#
-- this file Embedded resource
SELECT * FROM "Sellers"
@nickpreston24
nickpreston24 / daemon.js
Created July 31, 2021 16:38 — forked from kumatch/daemon.js
Node.js daemon example
var fs = require('fs');
var INTERVAL = 1000;
var cycle_stop = false;
var daemon = false;
var timer;
process.argv.forEach(function (arg) {
if (arg === '-d') daemon = true;

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream