Skip to content

Instantly share code, notes, and snippets.

@zyocum
zyocum / sVim.css
Created April 28, 2018 03:01
sVimcss
@-webkit-keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#sVim-command {
#!/usr/bin/env python3
"""Compute pair-wise cluster-level comparison metrics
These metrics are proposed by:
https://www.cs.umd.edu/class/spring2012/cmsc828L/Papers/MenestrinaVLDB10.pdf"""
import random
from string import ascii_lowercase as alphabet
from math import sqrt, log
@zyocum
zyocum / scrape_limecrime.py
Last active February 5, 2019 00:55
Scrape Limecrime
#!/usr/bin/env python3
"""Collect data from limecrime.com"""
import json
from requests_html import HTMLSession
LIMECRIME = 'https://www.limecrime.com/'
@zyocum
zyocum / automata.py
Last active July 24, 2019 22:17
1-Dimensional Cellular Automata
#!/usr/bin/env python3
"""Generate 1-dimensional automata based on various rules"""
def ngrams(iterable, n=1):
"""Generate ngrams from an iterable"""
return zip(*(iterable[i:] for i in range(n)))
def states(state, rule, left_pad='0', right_pad='0'):
"""Generate a stream of states from an initial state and a rule"""
next_state = ''.join(rule[''.join(window)] for window in ngrams(state, 3))
@zyocum
zyocum / William-B-Taylor-2019-06-22.txt
Created October 23, 2019 02:06
Opening Statement of Ambassador William B. Taylor - October 22, 2019
Opening Statement of Ambassador William B. Taylor - October 22, 2019
Mr. Chairman, I appreciate the opportunity to appear today to provide my perspective on the events that are the subject of the Committees’ inquiry. My sole purpose is to provide the Committees with my views about the strategic importance of Ukraine to the United States as well as additional information about the incidents in question.
I have dedicated my life to serving U.S. interests at home and abroad in both military and civilian roles. My background and experience are nonpartisan and I have been honored to serve under every administration, Republican and Democratic, since 1985.
For 50 years, I have served the country, starting as a cadet at West Point, then as an infantry officer for six years, including with the 101“ Airborne Division in Vietnam; then at the Department of Energy; then as a member of a Senate staff; then at NATO; then with the State Department here and abroad—in Afghanistan, Iraq, Jerusalem, and Ukraine; and more rece
@zyocum
zyocum / results.md
Created January 17, 2020 22:37
huniq benchmark results
mode repeats impl results
uniq 1 rust real 0.17
uniq 1 rust user 0.15
uniq 1 rust sys 0.01
uniq 1 rust 39809024 maximum resident set size
uniq 1 cpp real 0.37
uniq 1 cpp user 0.35
uniq 1 cpp sys 0.01
uniq 1 cpp 19337216 maximum resident set size
@zyocum
zyocum / corncob-isograms.txt
Last active February 7, 2020 03:19
List of isograms (words that contain only one instance of each letter they contain).
abdomen
abdomens
abduct
abducting
abduction
abductions
abductor
abductors
abducts
abe
#!/usr/bin/env python3
"""Produce visual, HTML diffs of two files"""
from argparse import ArgumentError, FileType
from difflib import HtmlDiff
def load(filename):
with open(filename, mode='r') as f:
for line in f:
$ curl -sX POST -H "X-RosetteAPI-Key: $ROSETTE_USER_KEY" -H "Content-Type: application/json" -H "Accept: application/json" -d '{"content":"Salesforce.com, Inc. is an American cloud-based software company headquartered in San Francisco."}' 'https://api.rosette.com/rest/v1/entities?output=rosette' | jq .
{
"version": "1.1.0",
"data": "Salesforce.com, Inc. is an American cloud-based software company headquartered in San Francisco.",
"attributes": {
"scriptRegion": {
"type": "list",
"itemType": "scriptRegion",
"items": [
{
#!/usr/bin/env python3
from itertools import chain
from itertools import combinations
import numpy as np
def distances(sentence, window=3, scale=True):
"""Compute a dictionary mapping combinations of pairs of words in the sentence to their normalized distances.
s1 = 'A B X B'.split()