Skip to content

Instantly share code, notes, and snippets.

View schmohlio's full-sized avatar

Matthew Schmohl schmohlio

View GitHub Profile
@schmohlio
schmohlio / NestedMap.java
Created April 21, 2017 22:23
Variable Depth Java HashMap
class NestedMap<K, V> {
private final HashMap<K, NestedMap> child;
private V value;
public NestedMap() {
child = new HashMap<>();
value = null;
}
@schmohlio
schmohlio / prepend.py
Last active August 10, 2017 23:42
Prepend text to files matching pattern in current directory
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
from os.path import join
TEXT = """syntax = "proto2"\n"""
def main():
package latch.common.utils;
import com.google.common.collect.Lists;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
@schmohlio
schmohlio / TextEditorBuffer.java
Created January 14, 2019 00:44
Text Editor Buffer with 2 Stacks (Sedgewick Algorithms) Example
public class GapBuffer {
private final Stack<Char> left, right;
private final int n;
public GapBuffer() {
left = new Stack<>();
right = new Stack<>();
n = 0;