Skip to content

Instantly share code, notes, and snippets.

View nycdotnet's full-sized avatar

Steve Ognibene nycdotnet

View GitHub Profile
@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
@nycdotnet
nycdotnet / idea.md
Last active August 29, 2015 14:06
Idea for TypeScript constructor improvement

Problem Statement: In TypeScript 1.1, there are two basic ways to initialize complex properties with strong typing via a parameterized class constructor. Both have disadvantages. I will illustrate this with a simple example that uses Knockout, but this issue applies to any other JavaScript library that implements complex objects via initializer functions.

"Method 1" is to instantiate the properties outside of the constructor using a throw-away value, and then to set the desired value inside the constructor (see RightTriangle1 below). This method has the advantage of being rather simple to program/maintain because TypeScript automatically infers the property's type. However, this has the potential to cause ripple effects or performance issues at runtime because the code to instantiate each property is run at least twice.

class RightTriangle1 {
    public height = ko.observable(0);
    public width = ko.observable(0);
    public hypotenuse = ko.computed(() => {

consol

@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.