Skip to content

Instantly share code, notes, and snippets.

var express = require('express')
var http = require('http')
var path = require('path')
var reload = require('reload');
var app = express()
app.get('/', function (req, res) {
res.sendFile(path.join(__dirname, 'public', 'test.html'));
})
@stestagg
stestagg / complex_schema.json
Created April 28, 2020 10:14
fastavro perf test
{
"type": "array",
"items": [
{
"type": "map",
"values": "bytes"
},
{
"name": "veTBcQK",
"type": "record",
{
"maxPlanets": 2,
"planets": [
[[0.77, 0.5], 50, false],
[[0.58, 0.5], 50, false],
[[0.05, 0.85], 35, false]
]
}
import tubes
import numpy as np
from matplotlib import pyplot
import glob
from os import path
FILES = glob.glob(path.expanduser("~/src/data/ngrams/1gram/googlebooks*"))
PYTHON_MATCH = '0'
PASCAL_MATCH = '1'
# Find the matching rows (where the first column is True)
word_rows = one_grams[IS_WORD_COL]
# Create an empty array to hold the per-year % values
word_counts = np.zeros(last_year+1)
# Iterate over each matching row (for a matching word, there should just be 1,000s of rows)
for _, year, count in one_grams[word_rows]:
# Set the relevant word_counts row to the calculated value
word_counts[year] += (100*count) / year_totals[year]
one_grams_tube = (tubes.Each(FILES)
.read_files()
.split()
.tsv(headers=False)
.skip_unless(lambda row: row.get(1).to(int).gt(1799))
.multi(lambda row: (
row.get(0).equals(word.encode('utf-8')),
row.get(1).to(int),
row.get(2).to(int)
))
last_year = 2008
YEAR_COL = '1'
COUNT_COL = '2'
year_totals, bins = np.histogram(
one_grams[YEAR_COL],
density=False,
range=(0, last_year+1),
bins=last_year + 1,
weights=one_grams[COUNT_COL]
import tubes
FILES = glob.glob(path.expanduser("~/src/data/ngrams/1gram/googlebooks*"))
WORD = "Python"
# Set up the data load pipeline
one_grams_tube = (tubes.Each(FILES)
.read_files()
.split()
.tsv(headers=False)
extern fn isr_rtc0();
#[allow(non_upper_case_globals)]
#[link_section=".isr_vector_nvic"]
#[no_mangle]
pub static NVICVectors: [Option<unsafe extern fn()>; ISR_COUNT+1] = [
None,
Some(isr_power_clock),
...
Some(isr_rtc0),