Skip to content

Instantly share code, notes, and snippets.

View nycdotnet's full-sized avatar

Steve Ognibene nycdotnet

View GitHub Profile
@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 / UpdateJava.ps1
Last active September 13, 2017 13:20
Java update PowerShell script
# This script will uninstall anything like *Java* from Add/Remove Programs, Unblock and Install a new JDK,
# and set the JAVA_HOME environment variable for the new version.
#
# You have to set the $jdkInstallerPath first to the location where you got the JDK. Such as:
# $jdkInstallerPath = "C:\Users\MyAccount\Downloads\jdk-7u60-windows-x64.exe"
#
# WARNING: This will uninstall ANYTHING that says Java anywhere in the name!!! Use with caution!!!
#
# Note: This assumes that you are using the x64 JDK on 64-bit Windows. Not tested in other scenarios.
@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 / output.text
Last active August 29, 2015 14:07
Double as binary
Testing 0
0-0-0-0-0-0-0-0-
After rehydrate: 0
Testing 1
0-0-0-0-0-0-240-63-
After rehydrate: 1
Testing -1
0-0-0-0-0-0-240-191-
After rehydrate: -1
Testing NaN