Skip to content

Instantly share code, notes, and snippets.

Michael Haufe mlhaufe

Block or report user

Report or block mlhaufe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View uMVC.ts
abstract class Observer {
abstract update(data?: any): void
}
abstract class Observable {
protected _observers: Observer[] = []
observe(observer: Observer) {
if (this._observers.indexOf(observer) > -1)
throw new Error('Observer already added')
@mlhaufe
mlhaufe / ShellBrowse.vbs
Last active Aug 5, 2019
VBScript File Browser
View ShellBrowse.vbs
Option Explicit
' Flags for the options parameter
Const BIF_returnonlyfsdirs = &H0001
Const BIF_dontgobelowdomain = &H0002
Const BIF_statustext = &H0004
Const BIF_returnfsancestors = &H0008
Const BIF_editbox = &H0010
Const BIF_validate = &H0020
Const BIF_browseforcomputer = &H1000
@mlhaufe
mlhaufe / simulating-generics.ts
Last active Jul 8, 2019
Simulating Generics w/ Inheritance in TypeScript.
View simulating-generics.ts
abstract class Comparable {
abstract le(other: this): boolean
min(other: this): Comparable {
return this.le(other) ? this : other
}
}
abstract class Ring {
constructor(
readonly zero: Ring,
@mlhaufe
mlhaufe / parameters.vbs
Created Jun 19, 2011
VBScript class constructor parameters
View parameters.vbs
Class Person
Private m_Age
Private m_Name
Public Default Function Init(Name, Age)
m_Name = Name
m_Age = Age
Set Init = Me
End Function
@mlhaufe
mlhaufe / arith-bool.js
Created Jan 8, 2019
Booleans with arithmetic
View arith-bool.js
// x, y :: {0,1}
var and = (x,y) => x * y,
not = (x) => 1 - x,
or = (x,y) => 1 - (1 - x) * (1 - y)
and(0,0) // 0
and(0,1) // 0
and(1,0) // 0
and(1,1) // 1
@mlhaufe
mlhaufe / Combinators.js
Last active Dec 30, 2018
ES6 Combinators
View Combinators.js
// λh.(h h)
let U = f => f(f)
// (λ x. x x) (λ x. x x)
let Ω = _ => (x => x (x)) (x => x (x))
// λf.(λx.f (λv.((x x) v))) (λx.f (λv.((x x) v)))
let Z = f => (x => f(y => x(x)(y)))
(x => f(y => x(x)(y)))
@mlhaufe
mlhaufe / README.txt
Created Dec 10, 2018
A half assed, buggy implementation of a Tiny File System. Not useful for anything as is.
View README.txt
- The application is currently single threaded
- The following commands have been implemented:
- exit
- create <PATH>
- open <PATH>
- display
- ls
- cd <TFS> (partial)
- mkdir <TFS> (partial). currently buggy due to nibble manipulation
- import <PATH> <TFS> (partial) stub + error checking only
View hackathon-2016.ts
function main() {
console.log("question1(0) == 0");
console.assert(question1(0) == 0, `${question1(0)}`);
console.log("question1(1) == 1");
console.assert(question1(1) == 1, `${question1(1)}`);
console.log("question1(7) == 13");
console.assert(question1(7) == 13, `${question1(7)}`);
console.log("question1(12) == 144");
console.assert(question1(12) == 144, `${question1(12)}`);
@mlhaufe
mlhaufe / downloadImage.vbs
Last active Jul 17, 2018
Downloading an image from a webpage in VBScript
View downloadImage.vbs
Dim document : Set document = WScript.GetObject("http://example.com")
While document.readyState <> "complete" : WScript.Sleep 200 : Wend
Dim xhr : Set xhr = CreateObject("MSXML2.XMLHTTP.3.0")
xhr.open "GET", document.getElementsByTagName("img")(0).src, False
xhr.send
Dim stream : Set stream = CreateObject("Adodb.Stream")
stream.Type = 1
stream.Open
stream.Write xhr.responseBody
stream.SaveToFile "C:\..\foo.jpg", 2
You can’t perform that action at this time.