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
import java.util.AbstractMap; | |
import java.util.ArrayList; | |
import java.util.Map; | |
import java.util.function.BiConsumer; | |
public class EntryList<K,V> extends ArrayList<Map.Entry<K,V>> { | |
public boolean add(K key, V value) { | |
return this.add(new AbstractMap.SimpleEntry<>(key, value)); | |
} |
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
When did this: | |
Optional.ofNullable(value) | |
.map(MyType::getProp) | |
.map(x -> x.equals(MyEnum.VALUE)) | |
.orElse(Boolean.FALSE) | |
get sexier than this: | |
value != null && MyEnum.VALUE.equals(value.getProp()) |
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
; Display the the byte in A as two hex digits at the current | |
; screen position | |
; | |
; Inputs: | |
; A byte to display | |
; | |
; Destroys A | |
display_hex: | |
pha | |
lsr |
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
import ( | |
"net/http" | |
) | |
func firstOrDefault(r *http.Request, key string, defaultValue string) string { | |
first := r.Header.Get(key) | |
if first != "" { | |
return first | |
} | |
return defaultValue |
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 ( | |
"net/http" | |
"fmt" | |
"io/ioutil" | |
"math/rand" | |
) | |
var letters = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") |
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
def local2(command, print_command=False): | |
"Run a command, returning the exit code, output, and stderr." | |
from subprocess import Popen, PIPE | |
p = Popen(command, stdout=PIPE, stderr=PIPE) | |
if print_command: print " ".join(command) | |
output, errput = p.communicate() | |
return p.returncode, output, errput | |
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
Process: CoQ [33933] | |
Path: /Users/USER/Library/Application Support/Steam/*/CoQ.app/Contents/MacOS/CoQ | |
Identifier: unity.Freehold Games.CavesOfQud | |
Version: 2.0.1 (0) | |
Code Type: X86 (Native) | |
Parent Process: ??? [1] | |
Responsible: CoQ [33933] | |
User ID: 501 | |
Date/Time: 2017-04-22 14:01:07.053 -0700 |
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 Stuff { | |
void method() { | |
/*.. in a catch block ..*/ | |
throw translate(ex); | |
} | |
@SuppressWarnings("UnusedReturnValue") | |
private static RuntimeException translate(Exception ex) | |
throws SomeCheckedException, SomeOtherException { | |
if (ex instanceof SomeException) { |
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 | |
# Escaped color codes | |
BLACK=`echo -e '\033[0;30m'` | |
DK_GREY=`echo -e '\033[1;30m'` | |
RED=`echo -e '\033[0;31m'` | |
PINK=`echo -e '\033[1;31m'` | |
GREEN=`echo -e '\033[0;32m'` | |
LT_GREEN=`echo -e '\033[1;32m'` | |
BROWN=`echo -e '\033[0;33m'` |
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 codenotes; | |
public class Main { | |
public static void main(String[] args) { | |
Result r = new Result(Result.FIRST_NAME_FLAG|Result.LAST_NAME_FLAG|Result.ADDRESS_FLAG); | |
Result.Match m1 = Result.Match.atLeast().firstName().lastName(); | |
System.out.println(r.matches(m1)); // true | |
Result.Match m2 = Result.Match.exactly().firstName().lastName().address(); |
NewerOlder