This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GapBuffer { | |
private final Stack<Char> left, right; | |
private final int n; | |
public GapBuffer() { | |
left = new Stack<>(); | |
right = new Stack<>(); | |
n = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import os | |
from os.path import join | |
TEXT = """syntax = "proto2"\n""" | |
def main(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NestedMap<K, V> { | |
private final HashMap<K, NestedMap> child; | |
private V value; | |
public NestedMap() { | |
child = new HashMap<>(); | |
value = null; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
yum install -y aws-cli | |
cd /home/ec2-user/ | |
aws s3 cp 's3://aws-codedeploy-us-east-1/latest/codedeploy-agent.noarch.rpm' . --region us-east-1 | |
yum -y install codedeploy-agent.noarch.rpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BlockingQueue implements Queue { | |
private java.util.Queue queue = new java.util.LinkedList(); | |
/** | |
* Make a blocking Dequeue call so that we'll only return when the queue has | |
* something on it, otherwise we'll wait until something is put on it. | |
* | |
* @returns This will return null if the thread wait() call is interrupted. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.schmohl; | |
import java.util.*; | |
public class StringChain { | |
// we can use depth first search for each word to calculate the length of the chain. | |
static int longestChain(String[] words) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.schmohl; | |
import java.io.*; | |
import java.util.*; | |
import java.text.*; | |
import java.math.*; | |
import java.util.regex.*; | |
public class FriendCircles { | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// v2 of the great example of SSE in go by @ismasan. | |
// includes fixes: | |
// * infinite loop ending in panic | |
// * closing a client twice | |
// * potentially blocked listen() from closing a connection during multiplex step. | |
package main | |
import ( | |
"fmt" | |
"log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"log" | |
"sort" | |
) | |
// implement `Interface` in sort package. | |
type sortByteArrays [][]byte |
NewerOlder