Skip to content

Instantly share code, notes, and snippets.

@vico
vico / video-subtitles-via-whisper.py
Created September 27, 2022 02:32 — 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
@vico
vico / ubuntu_evince.md
Last active March 6, 2022 13:57
Open URL from Evince in Chrome (Ubuntu 21.10)

Content of /etc/apparmor.d/abstractions/ubuntu-helpers file for open URL from evince in Chrome (Edge does not work as expected)

# Lenient profile that is intended to be used when 'Ux' is desired but
# does not provide enough environment sanitizing. This effectively is an
# open profile that blacklists certain known dangerous files and also
# does not allow any capabilities. For example, it will not allow 'm' on files
# owned be the user invoking the program. While this provides some additional
# protection, please use with care as applications running under this profile
# are effectively running without any AppArmor protection. Use this profile
@vico
vico / ftp_with_proxy.py
Created March 6, 2022 10:19
Download binary file through a HTTP proxy (Squid) using ftplib in Python3
import socket
import sys
from base64 import b64encode
from ftplib import FTP
from functools import wraps
_real_create_connection = socket.create_connection
_proxied_hostnames = {} # hostname: (proxy_host, proxy_port, proxy_auth)
@vico
vico / embedding_forward.py
Created September 7, 2021 02:46
For explanation of Embedding layer
def forward(self, x):
"""Returns embedding vectors corresponding to input token IDs.
Args:
x: Tensor of token IDs.
Returns:
Tensor of embedding vectors.
"""
embedded = jnp.take(self.weights, x, axis=0, mode='clip')
import numpy as np
from trax import layers as tl # core building block
from trax import shapes # data signatures: dimensionality and type
input_vocab_size = 1
d_model = 16
n_encoder_layers = 1
x = np.array([[-2, -1, 0, 1, 2],
import numpy as np
from trax import layers as tl # core building block
from trax import shapes # data signatures: dimensionality and type
input_vocab_size = 1
d_model = 16 # embedding dimension
x = np.array([[-2, -1, 0, 1, 2],
[-20, -10, 0, 10, 20]])
@vico
vico / Dockerfile-trax
Created February 6, 2021 02:03
Dockerfile for Trax deep learning framework.
FROM nvidia/cuda:11.0-cudnn8-devel-ubuntu18.04
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
wget \
ca-certificates \
libjpeg-dev \
libpng-dev \
python3 python3-pip python3-setuptools
@vico
vico / engine.c
Created December 15, 2019 14:03 — forked from druska/engine.c
Quant Cup 1's winning order book implementation
/*****************************************************************************
* QuantCup 1: Price-Time Matching Engine
*
* Submitted by: voyager
*
* Design Overview:
* In this implementation, the limit order book is represented using
* a flat linear array (pricePoints), indexed by the numeric price value.
* Each entry in this array corresponds to a specific price point and holds
* an instance of struct pricePoint. This data structure maintains a list