Skip to content

Instantly share code, notes, and snippets.

@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
regs::GPIO().outset.set_pins(1) // Make the GPIO pin 1 go high
TIMEOUT = 100
ioregs! (GPIO @ 0x50000000 = { //! power management unit
0x504 => reg32 out { 31..0 => pins }, // write to gpio
0x508 => reg32 outset { 31..0 => pins }, // set individual out pins to high
0x50c => reg32 outclr { 31..0 => pins } , // set individual out pins to low
0x510 => reg32 in { 31..0 => pins } , // read pin values
0x514 => reg32 dir { 31..0 => pins } , // set direction of all pins (1=output, 0=input)
0x518 => reg32 dirset { 31..0 => pins } , // set individual pins to output
0x51c => reg32 dirclr { 31..0 => pins } , // set individual pins to input
0x700 => reg32 pin_config[32] {
0 => dir,
@stestagg
stestagg / display init.py
Last active February 25, 2017 18:16
bitflyer
from microbit import i2c, sleep
CMD_ON = 175
CMD_OFF = 174
CMD_CHARGE_PUMP_SET = 141
CMD_SET_ROW = 176
CMD_TOP_TO_BOTTOM = 200
CMD_LEFT_TO_RIGHT = 161
CMD_SET_ADDR_MODE = 32
#!/usr/bin/env python3
import smbus2
import time
import numpy as np
import cv2
from collections import deque
class Display:
<style>.ww{word-break: break-all;}</style>
<body>
<div id="x" class=""></div>
<script>
function n_rand(n){
var str = "";
while (str.length < n) {
>>> from machine import *
>>> from pyb import *
>>> iic = I2C(Pin(2), Pin(0))
>>> iic.writeto(60, b'\x80\xAF') # Turn display on
>>> iic.writeto(60, b'\x80\x8D\x80\x14') # Set the voltage pump
>>> from machine import *
>>> from pyb import *
>>> iic = I2C(Pin(2), Pin(0))
>>> iic.writeto(0x7A, 0xAF)
>>> iic.writeto(0x7A, 0xA7)
>>> from machine import *
>>> from pyb import *
>>> iic = I2C(Pin(2), Pin(0))
>>> iic.writeto(0x78, 0xAF)
>>> iic.writeto(0x78, 0xA7)