This file contains 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
from machine import Pin | |
import serial | |
# serial: https://pythonhosted.org/pyserial/pyserial.html#overview | |
# create an output pin on pin #8 | |
out_pin = Pin(8, Pin.OUT) | |
# set the output pin to high mode | |
out_pin.value(1) |
This file contains 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
import mido | |
with mido.open_input('mido_port', virtual=True) as in_port: | |
for msg in in_port: | |
print(msg) |
This file contains 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
# ----------------------------------------------------------------------------- | |
# From Numpy to Python | |
# Copyright (2017) Nicolas P. Rougier - BSD license | |
# More information at https://github.com/rougier/numpy-book | |
# ----------------------------------------------------------------------------- | |
from matplotlib.animation import FuncAnimation | |
from collections import namedtuple | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import random |
This file contains 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
from flask import Flask, jsonify, request | |
import gpt_2_simple as gpt2 | |
import tensorflow as tf | |
import os | |
if not os.path.exists('checkpoint'): | |
os.makedirs(os.path.join('checkpoint', 'run1')) | |
gpt2.download_gpt2(model_name='117M') | |
os.system('mv models/117M/* checkpoint/run1/') |
This file contains 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
from dateutil.relativedelta import relativedelta | |
from datetime import date, datetime | |
import json | |
import requests | |
import calendar | |
import time | |
import sys | |
end = date.today() | |
start = end - relativedelta(years=3) |
This file contains 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
# conda install -c cogsci pygame | |
import pygame, base64 | |
def midi_to_base64(midi_filename): | |
return base64.encodestring(open(midi_filename, 'rb').read()) | |
def play_music(midi_filename): | |
'''Stream music_file in a blocking manner''' | |
clock = pygame.time.Clock() | |
pygame.mixer.music.load(midi_filename) |
This file has been truncated, but you can view the full file.
This file contains 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
Introduction: | |
A Musico-Logical Offering | |
Author: FREDERICK THE GREAT, King of Prussia, came to power in 1740. Although he is emembered in history books mostly for his military astuteness, he was also devoted to he life of the mind and the spirit. His court in Potsdam was one of the great centers of ntellectual activity in Europe in the eighteenth century. The celebrated mathematician | |
Leonhard Euler spent twenty-five years there. Many other mathematicians and scientists ame, as well as philosophers-including Voltaire and La Mettrie, who wrote some of their ost influential works while there. But music was Frederick's real love. He was an avid flutist and composer. Some of his ompositions are occasionally performed even to this day. Frederick was one of the first atrons of the arts to recognize the virtues of the newly developed "piano-forte" ("softloud"). The piano had been developed in the first half of the eighteenth century as a odification of the harpsichord. The problem with the harpsichord was that pieces |
This file contains 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
// NB: To load from localhost one can: | |
fetch(url) | |
.then(response => response.blob()) | |
.then(async image => { | |
const img = document.createElement('img'); | |
img.src = URL.createObjectURL(image); | |
img.onload = async () => {} | |
}) |
This file contains 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
import numpy as np | |
import sys | |
import struct | |
dim = 50 | |
a = np.load('stacked-vecs-{}.npy'.format(dim)) | |
with open('stacked.fvecs', 'wb') as out: | |
for i in a: | |
line = [float(j) for j in i] |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.