This file contains hidden or 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 | |
"""Simple static server written using an event loop.""" | |
import argparse | |
import contextlib | |
import errno | |
import functools | |
import logging | |
import mimetypes | |
import os |
This file contains hidden or 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
$ time echo 'GET /first?delay=1 HTTP/1.1 | |
Host: localhost:8080 | |
Connection: keep-alive | |
GET /last?delay=1 HTTP/1.1 | |
Host: localhost:8080 | |
Connection: close | |
' | unix2dos | nc localhost 8080 > /dev/null | |
real 0m2.018s |
This file contains hidden or 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
$ python3 solution.py | |
AMAZON ECHO IS DESIGNED AROUND YOUR | |
VOICE. IT'S ALWAYS ON - JUST ASK FOR | |
INFORMATION, MUSIC, NEWS, WEATHER, AND | |
MORE. ECHO BEGINS WORKING AS SOON AS IT | |
DETECTS THE WAKE WORD. YOU CAN PICK | |
ALEXA OR AMAZON AS YOUR WAKE WORD. ECHO | |
IS ALSO AN EXPERTLY TUNED SPEAKER THAT | |
CAN FILL ANY ROOM WITH IMMERSIVE SOUND. | |
PLEASE VISIT WWW.AMAZON.COM/ECHO IF YOU |
This file contains hidden or 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 ( | |
"fmt" | |
"sync/atomic" | |
"unsafe" | |
) | |
type Iterator interface { | |
Next() string |
This file contains hidden or 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
{ | |
"b": { | |
"param": "yello!" | |
}, | |
"a": "test" | |
} |
This file contains hidden or 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
{ | |
"bool": { | |
"must": { | |
"dis_max": { | |
"queries": [ | |
{ | |
"match": { | |
"common": { | |
"query": "USER_QUERY", | |
"type": "boolean", |
This file contains hidden or 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
::: {Baphomet}{bTq1hGDTQy-AJpWTjTpVbw}{OBFUSCATED}{OBFUSCATED:9300}{rack_id=k13} | |
Hot threads at 2016-09-24T14:27:12.584Z, interval=10s, busiestThreads=3, ignoreIdleThreads=true: | |
19.8% (1.9s out of 10s) cpu usage by thread 'elasticsearch[Baphomet][search][T#15]' | |
2/10 snapshots sharing following 38 elements | |
org.apache.lucene.index.TermContext.build(TermContext.java:94) | |
org.apache.lucene.search.TermQuery.createWeight(TermQuery.java:192) | |
org.apache.lucene.search.IndexSearcher.createWeight(IndexSearcher.java:904) | |
org.apache.lucene.search.BooleanWeight.<init>(BooleanWeight.java:57) | |
org.apache.lucene.search.BooleanQuery.createWeight(BooleanQuery.java:239) |
This file contains hidden or 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 | |
import collections | |
import sys | |
MAX_SIZE = 50 | |
if __name__ == '__main__': | |
d = collections.OrderedDict() |
This file contains hidden or 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 merge_two(i: Iterator[T], j: Iterator[T]) -> Iterator[T]: | |
""" | |
>>> list(merge_two(iter([1, 2, 4]), iter([0, 1, 3, 4]))) | |
[0, 1, 1, 2, 3, 4, 4] | |
""" | |
try: | |
x = next(i) | |
except StopIteration: | |
yield from j | |
return |
This file contains hidden or 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
$ go test -bench=. | |
BenchmarkIterIndex-4 3000 478589 ns/op | |
BenchmarkIterIndexNoPanic-4 3000 469209 ns/op | |
BenchmarkIterSlice-4 2000 664497 ns/op | |
PASS | |
ok _/private/tmp/slice 5.353s |