Skip to content

Instantly share code, notes, and snippets.

View nolawnchairs's full-sized avatar

Michael Wieczorek nolawnchairs

View GitHub Profile
@nolawnchairs
nolawnchairs / npm-project.sh
Last active July 29, 2020 13:49
Builds an Node project with TS and Git
#!/bin/sh
if [ -z $1 ]; then
echo "Must provide a location"
exit 1
fi
DIR="$(realpath "$1")"
echo "Creating project at $DIR"
package io.nolawnchairs.util;
public enum AnsiColor {
//Color end string, color reset
RESET("\033[0m"),
// Regular Colors. Normal color, no bold, background color etc.
BLACK("\033[0;30m"), // BLACK
RED("\033[0;31m"), // RED
GREEN("\033[0;32m"), // GREEN
@nolawnchairs
nolawnchairs / FunctionalInterfaces.ts
Created May 17, 2020 07:07
Typescript analogs to java.util.function interfaces
/**
* Represents a function that accepts one argument and produces a result.
* @template T the parameter type
* @template U the return type
*/
export type Function<T, U> = (value: T) => U
/**
* Represents a function that accepts two arguments and produces a result.
@nolawnchairs
nolawnchairs / polyline_util.dart
Created April 30, 2020 22:58
Port of Android PolyUtil for Dart
import 'dart:math' show max, min, tan, pi, sin, log, atan, exp, cos, sqrt;
class LatLng {
double latitude;
double longitude;
}
class PolyUtil {
PolyUtil._() {}
@nolawnchairs
nolawnchairs / Murmur32.ts
Created September 15, 2019 12:21
Murmur32 hash in Typescript
export function murmur32(key: string, seed: number) {
let remainder = key.length & 3 // key.length % 4
let bytes = key.length - remainder
let h1 = seed
let c1 = 0xcc9e2d51
let c2 = 0x1b873593
let i = 0
let k1 = 0
@nolawnchairs
nolawnchairs / ModularItem.ts
Created September 15, 2019 12:18
Unfinished Modular iterator
export class ModularItem<E> {
private readonly _value: E
private _position = 0
constructor(value: E, position: number = 0) {
this._value = value
this._position = position
}
@nolawnchairs
nolawnchairs / semantic.css
Created January 25, 2019 09:28
Generated Semantic-UI CSS Files
/*
* # Semantic UI - 2.4.2
* https://github.com/Semantic-Org/Semantic-UI
* http://www.semantic-ui.com/
*
* Copyright 2014 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
@nolawnchairs
nolawnchairs / MorphiaLogger.java
Last active January 17, 2019 20:25
Morphia binding for slf4j
package whatever;
import org.mongodb.morphia.logging.Logger;
import org.mongodb.morphia.logging.LoggerFactory;
import org.mongodb.morphia.logging.MorphiaLoggerFactory;
public class MorphiaLogger implements Logger {
private final org.slf4j.Logger logger;