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
@jarrettmeyer
jarrettmeyer / ObjectToDictionaryHelper.cs
Created January 27, 2011 15:53
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)
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

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
@wcharczuk
wcharczuk / FSGrep.cs
Created April 9, 2012 14:33
C# File System Grep
public class FSGrep
{
public FSGrep()
{
this.Recursive = true;
}
public String RootPath { get; set; }
public Boolean Recursive { get; set; }
public String FileSearchMask { get; set; }
@domenic
domenic / promise-retryer.js
Last active September 16, 2023 02:43
Generalized promise retryer
"use strict";
// `f` is assumed to sporadically fail with `TemporaryNetworkError` instances.
// If one of those happens, we want to retry until it doesn't.
// If `f` fails with something else, then we should re-throw: we don't know how to handle that, and it's a
// sign something went wrong. Since `f` is a good promise-returning function, it only ever fulfills or rejects;
// it has no synchronous behavior (e.g. throwing).
function dontGiveUp(f) {
return f().then(
undefined, // pass through success
@cheynewallace
cheynewallace / NetStatPortsAndProcessNames.cs
Last active July 6, 2024 12:18
C# Get Active Ports and Associated Process Names. This code will parse the output from a "netstat -a -n -o" and retrieve a list of active listening ports, along with the associated PID. The PID is then resolved to a process name so we can see exactly which port is attached to which process.
// ===============================================
// The Method That Parses The NetStat Output
// And Returns A List Of Port Objects
// ===============================================
public static List<Port> GetNetStatPorts()
{
var Ports = new List<Port>();
try {
using (Process p = new Process()) {
@rxaviers
rxaviers / gist:7360908
Last active July 17, 2024 18:16
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@tonymorris
tonymorris / PureIO.cs
Last active April 2, 2022 16:23
A demonstration of pure-functional I/O using the free monad in C#
using System;
namespace PureIO {
/*
C# does not have proper sum types. They must be emulated.
This data type is one of 4 possible values:
- WriteOut, being a pair of a string and A
- WriteErr, being a pair of a string and A
- readLine, being a function from string to A
@staltz
staltz / introrx.md
Last active July 15, 2024 15:43
The introduction to Reactive Programming you've been missing
@davidfowl
davidfowl / dotnetlayout.md
Last active July 12, 2024 04:04
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/
@DanDiplo
DanDiplo / JS-LINQ.js
Last active July 16, 2024 23:49
JavaScript equivalents of some common C# LINQ methods. To help me remember!
// JS array equivalents to C# LINQ methods - by Dan B.
// First: This version using older JavaScript notation for universal browser support (scroll down for ES6 version):
// Here's a simple array of "person" objects
var people = [
{ name: "John", age: 20 },
{ name: "Mary", age: 35 },
{ name: "Arthur", age: 78 },
{ name: "Mike", age: 27 },