Skip to content

Instantly share code, notes, and snippets.

TIMEOUT = 100
regs::GPIO().outset.set_pins(1) // Make the GPIO pin 1 go high
@stestagg
stestagg / pypi.sql
Created May 19, 2017 19:45
PyPi Query
SELECT
file.project,
count(distinct details.system.release) as distinct_setups,
count(*) as num_downloads
FROM `the-psf.pypi.downloads2017*`
WHERE LOWER(file.project) in ('cpickle','json', 'sqlite3','sqlite', 'marshal','math','os','pickle','platform','socket','stat','string','sys','tempfile')
and details.installer.name = 'pip'
GROUP BY file.project
ORDER BY num_downloads desc
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),
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)
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]
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)
))
# 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]
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'
{
"maxPlanets": 2,
"planets": [
[[0.77, 0.5], 50, false],
[[0.58, 0.5], 50, false],
[[0.05, 0.85], 35, false]
]
}