Skip to content

Instantly share code, notes, and snippets.

View NoFishLikeIan's full-sized avatar
🦉
night owling

Andrea NoFishLikeIan

🦉
night owling
View GitHub Profile
@enricopolanski
enricopolanski / eq1.md
Last active May 25, 2020 12:36
Equivalence #1

Suppose we want a set of unique { x, y } points to plot on a graph.

this expression:

new Set([
  { x: 1, y: 1 },
  { x: 1, y: 1 },
]);
@YBogomolov
YBogomolov / either_tuple.ts
Created April 13, 2020 15:02
Encoding Either<E, A> as a tuple
export type Either<E, A> = [E, null] | [null, A];
type Fn<A, B> = (a: A) => B;
export const left = <E, A>(e: E): Either<E, A> => [e, null];
export const right = <E, A>(a: A): Either<E, A> => [null, a];
export const isLeft = <E, A>(e: Either<E, A>): e is [E, null] => e[1] === null;
export const isRight = <E, A>(e: Either<E, A>): e is [null, A] => e[0] === null;
@aseering
aseering / ntlmdecoder.py
Last active March 8, 2024 01:36
NTLM auth-string decoder
#!/usr/bin/env python
## Decodes NTLM "Authenticate" HTTP-Header blobs.
## Reads the raw blob from stdin; prints out the contained metadata.
## Supports (auto-detects) Type 1, Type 2, and Type 3 messages.
## Based on the excellent protocol description from:
## <http://davenport.sourceforge.net/ntlm.html>
## with additional detail subsequently added from the official protocol spec:
## <http://msdn.microsoft.com/en-us/library/cc236621.aspx>
##
@roblg
roblg / gist:2400902
Created April 16, 2012 19:25
retrieving a basic auth-protected CSV with Google Spreadsheets and Google App Scripting
// this function assumes the CSV has no fields with commas,
// and strips out all the double quotes
function parseCsvResponse(csvString) {
var retArray = [];
var strLines = csvString.split(/\n/g);
var strLineLen = strLines.length;
for (var i = 0; i &lt; strLineLen; i++) {
var line = strLines[i];
if (line != '') {