Skip to content

Instantly share code, notes, and snippets.

@taka-wang
taka-wang / atomic.py
Last active March 23, 2024 13:13
確保enqueue的atomic
import redis
r = redis.Redis(host='localhost', port=6379, db=0)
lua_script = """
local queue_length = redis.call('llen', KEYS[1])
if queue_length > 0 then
-- get the last number
local last_number = redis.call('lindex', KEYS[1], -1)
local new_number = tonumber(last_number) + 1
@taka-wang
taka-wang / loadsrt.js
Created February 3, 2024 09:49
Load external subtitle for youtube
function loadSRT(url, callback) {
var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState === XMLHttpRequest.DONE) {
if (httpRequest.status === 200) {
var subtitles = parseSRT(httpRequest.responseText);
callback(subtitles);
} else {
console.error(
@taka-wang
taka-wang / video-subtitles-via-whisper.py
Created June 3, 2023 13:34 — forked from rasbt/video-subtitles-via-whisper.py
Script that creates subtitles (closed captions) for all MP4 video files in your current directory
# Sebastian Raschka 09/24/2022
# Create a new conda environment and packages
# conda create -n whisper python=3.9
# conda activate whisper
# conda install mlxtend -c conda-forge
# Install ffmpeg
# macOS & homebrew
# brew install ffmpeg
# Ubuntu
@taka-wang
taka-wang / selenium.py
Created October 26, 2021 05:05 — forked from korakot/selenium.py
Use selenium in Colab
# install chromium, its driver, and selenium
!apt update
!apt install chromium-chromedriver
!pip install selenium
# set options to be headless, ..
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
@taka-wang
taka-wang / yolov4.py
Created June 7, 2021 00:49 — forked from YashasSamaga/yolov4.py
YOLOv4 inference using OpenCV DNN
import cv2
import time
CONFIDENCE_THRESHOLD = 0.2
NMS_THRESHOLD = 0.4
COLORS = [(0, 255, 255), (255, 255, 0), (0, 255, 0), (255, 0, 0)]
class_names = []
with open("classes.txt", "r") as f:
class_names = [cname.strip() for cname in f.readlines()]
@taka-wang
taka-wang / buy.html
Created September 25, 2020 08:23
test
<div id='product-component-1601022034033'></div>
<script type="text/javascript">
/*<![CDATA[*/
(function () {
var scriptURL = 'https://sdks.shopifycdn.com/buy-button/latest/buy-button-storefront.min.js';
if (window.ShopifyBuy) {
if (window.ShopifyBuy.UI) {
ShopifyBuyInit();
} else {
loadScript();

Installing Python 3.7.4 on Raspbian

As of July 2018, Raspbian does not yet include the latest Python release, Python 3.7.4. This means we will have to build it ourselves, and here is how to do it.

  1. Install the required build-tools (some might already be installed on your system).
@taka-wang
taka-wang / 3d_mesh.ipynb
Last active March 23, 2020 10:24
ai basic1 snippets
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
We can make this file beautiful and searchable if this error is corrected: It looks like row 10 should actually have 1 column, instead of 9 in line 9.
# 1. Number of times pregnant
# 2. Plasma glucose concentration a 2 hours in an oral glucose tolerance test
# 3. Diastolic blood pressure (mm Hg)
# 4. Triceps skin fold thickness (mm)
# 5. 2-Hour serum insulin (mu U/ml)
# 6. Body mass index (weight in kg/(height in m)^2)
# 7. Diabetes pedigree function
# 8. Age (years)
# 9. Class variable (0 or 1)
6,148,72,35,0,33.6,0.627,50,1
@taka-wang
taka-wang / build_opencv4.0_jetson_nano.sh
Created October 16, 2019 02:33
Build openCV 4.0 debian package on Jetson Nano
#!/bin/bash
#
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA Corporation and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA Corporation is strictly prohibited.
#