View tempo_animation_prototype.py
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 cv2 | |
import librosa | |
import librosa.display | |
import wave | |
import pyaudio | |
from cv2 import VideoWriter, VideoWriter_fourcc | |
VIDEO_PATH = 'Demo_Full_1.mp4' | |
video = cv2.VideoCapture(VIDEO_PATH) |
View stream_beat_v2.py
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 pyaudio | |
import librosa | |
import numpy as np | |
import requests | |
from pyo import * | |
import time | |
from numpy_ringbuffer import RingBuffer | |
pa = pyaudio.PyAudio() |
View stream_beat.py
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
"""PyAudio Example: Play a wave file (callback version).""" | |
import pyaudio | |
import wave | |
import time | |
import sys | |
import librosa | |
import numpy as np | |
import scipy | |
import matplotlib.pyplot as plt |
View pyaudio_recorder.py
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 pyaudio | |
import wave | |
sample_format = pyaudio.paFloat32 # 16 bits per sample | |
channels = 1 | |
fs = 44100 # Record at 44100 samples per second | |
seconds = 10 | |
filename = "output.wav" | |
chunk = 2048#fs*5 # Record in chunks of 1024 samples |
View geojson2bigquery.py
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 json | |
with open('HGURiau_EoF2019ATR2014Bappenas2011.json', 'r') as ifp: | |
with open('to_load.json', 'w') as ofp: | |
features = json.load(ifp)['features'] | |
print(features) | |
# new-line-separated JSON | |
schema = None | |
for obj in features: | |
props = obj['properties'] # a dictionary | |
props['geometry'] = json.dumps(obj['geometry']) # make the geometry a string |
View shape2geojson.py
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 shapefile | |
# read the shapefile | |
reader = shapefile.Reader("hello.shp") | |
fields = reader.fields[1:] | |
field_names = [field[0] for field in fields] | |
buffer = [] | |
for sr in reader.shapeRecords(): | |
atr = dict(zip(field_names, sr.record)) | |
geom = sr.shape.__geo_interface__ |
View loop.js
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
exports.getTranslations = functions.https.onRequest(async (req, res) => { | |
const english_words = req.body.english_words || []; | |
console.log(english_words); | |
const collectionRef = admin.firestore().collection("translations"); | |
const createResponse = (res) => { | |
var data = { | |
english_word: (res === undefined) ? '' : res.english_word , | |
translation: (res === undefined) ? '' : res.translation , | |
transliteration: (res === undefined) ? '' : res.transliteration, | |
sound_link: (res === undefined) ? '' : res.sound_link |
View 26. Remove Duplicates from Sorted Array.cpp
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
class Solution { | |
public: | |
int removeDuplicates(vector<int>& nums) { | |
if (nums.empty()) return 0; | |
int cur = 0; | |
for (int i=1;i<nums.size();i++){ | |
if (nums[i] != nums[cur]){ | |
swap(nums[i],nums[++cur]); | |
} | |
} |
View 117. Populating Next Right Pointers in Each Node II.cpp
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
/** | |
我的方法用了一个queue,再用一个NULL指针来分辨是不是一层的。 | |
看了答案以后发现optimized的解法是,不需要用queue,因为这个next的link已经可以serve as queue. | |
* Definition for binary tree with next pointer. | |
* struct TreeLinkNode { | |
* int val; | |
* TreeLinkNode *left, *right, *next; | |
* TreeLinkNode(int x) : val(x), left(NULL), right(NULL), next(NULL) {} | |
* }; |
View 16. 3Sum Closest.cpp
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
class Solution { | |
public: | |
int threeSumClosest(vector<int>& nums, int target) { | |
int res = target + 1000; | |
sort(nums.begin(),nums.end()); | |
for (int i=0;i<nums.size()-2;i++){ | |
int target2 = target - nums[i]; | |
int j=i+1; | |
int k=nums.size()-1; | |
while (j<k){ |
NewerOlder