Skip to content

Instantly share code, notes, and snippets.

View nycdotnet's full-sized avatar

Steve Ognibene nycdotnet

View GitHub Profile
@nycdotnet
nycdotnet / ConstructionPerf.txt
Last active March 4, 2019 03:46
ImmutableDictionary vs ReadOnlyDictionary vs Dictionary Benchmarks with .NET Core SDK 3.0-preview2
BenchmarkDotNet=v0.11.4, OS=Windows 10.0.17134.590 (1803/April2018Update/Redstone4)
Intel Core i7-6600U CPU 2.60GHz (Skylake), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=3.0.100-preview-010184
[Host] : .NET Core 2.1.8 (CoreCLR 4.6.27317.03, CoreFX 4.6.27317.03), 64bit RyuJIT
MediumRun : .NET Core 3.0.0-preview-27324-5 (CoreCLR 4.6.27322.0, CoreFX 4.7.19.7311), 64bit RyuJIT
Job=MediumRun Toolchain=.NET Core 3.0 Preview 2 InvocationCount=1
IterationCount=15 LaunchCount=2 UnrollFactor=1
WarmupCount=10
@nycdotnet
nycdotnet / Program.cs
Created January 2, 2018 11:01
SQL Server Isolation Modes
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using Dapper;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace isolationmode_demo
@nycdotnet
nycdotnet / code.cs
Created October 9, 2017 15:59
Get Constants On Type
/// <summary>
/// Enumerates constants on a type.
/// </summary>
public static IEnumerable<FieldInfo> GetConstantsOnType(Type TypeToReflect)
{
return TypeToReflect.GetFields().Where(f => f.IsStatic && f.IsLiteral);
}
/// <summary>
/// Enumerates constants on a type of a type.
@nycdotnet
nycdotnet / Gruntfile.js
Created July 25, 2016 20:04
Run QUnit from command-line with Grunt
module.exports = function (grunt) {
grunt.initConfig({
qunit: {
default: {
options: {
urls: ["http://localhost:8000/tests/tests.html"]
}
}
},
connect: {
@nycdotnet
nycdotnet / test.ts
Created August 20, 2015 15:18
http self-request
// demo of web server and client request. Lines 17 or 18 can be used and it works.
import http = require('http');
class Test {
request: http.ClientRequest;
private Connect() {
console.log("connecting");
this.request = http.request({
hostname: "localhost",
@nycdotnet
nycdotnet / exec.ts
Created June 1, 2015 16:50
Asynchronous Promise-based exec demo
import {Promise as Promise} from 'es6-promise';
module exec {
function doExec(shouldSucceed: boolean) : Promise<number> {
return new Promise((resolve, reject) => {
doSubExec(shouldSucceed)
.then((result) => {
resolve(result);
},(error) => {
@nycdotnet
nycdotnet / Program.cs
Created June 1, 2015 13:43
Get releases info from GitHub API
using System.IO;
using System.Net;
namespace getReleaseInfo
{
class Program
{
static void Main(string[] args)
{
@nycdotnet
nycdotnet / Program.cs
Created May 4, 2015 16:36
C# Parameterized Events via Interfaces example
// INTERFACES
public interface ITicker
{
event Action<ITicker,ITimeOfTick> Tick;
}
public interface ITimeOfTick
{
DateTime Time { get; set; }
@nycdotnet
nycdotnet / QuickReload.vb
Last active August 29, 2015 14:15
Visual Studio Project Reload Macro
'===============================================================================
' This macro originally written by Sam Saffron, adapted for Visual Studio 2013
' by Steve Ognibene. Run in Visual Studio with a macro launcher such as the
' Visual Commander extension.
' Latest version will be here: https://gist.github.com/nycdotnet/947025d922fa2af87d03
' Original Stack Overflow thread: http://stackoverflow.com/questions/3783648/is-there-a-setting-in-vs-2010-that-will-allow-it-to-recover-open-files-after-a-p/28130299#28130299
' Also, thanks to Jeremy Jameson for code to write to VS Output window in a macro:
' http://blogs.msdn.com/b/jjameson/archive/2009/03/11/tracing-and-logging-from-visual-studio-macros.aspx
'===============================================================================
Option Explicit On
@nycdotnet
nycdotnet / instructions.md
Last active April 28, 2018 14:57
Portable Git in Node.js command prompt on Windows

GitHub for Windows doesn't put Git in the PATH by default. If you'd like your Node.js command prompt to have the git command available by default, simply edit your nodevars.bat file. By default, this is in C:\Program Files\nodejs\. You will have to run your text editor in an administrative context for this to work.

Replace this line in your nodevars.bat file:

set PATH=%APPDATA%\npm;%~dp0;%PATH%

With these thre lines:

for /F %%A in ('"dir /s /b /OD %userprofile%\appdata\local\git.exe"') do set gitPath=%%A\..