Skip to content

Instantly share code, notes, and snippets.

@rickt
rickt / server.py
Created September 25, 2024 22:19
simple faster-whisper API server for GCP Cloud Run GPU
from flask import Flask, request, jsonify, Response
from faster_whisper import WhisperModel
import subprocess
app = Flask(__name__)
# Initialize the faster-whisper model
model = WhisperModel("small", device="cuda") # Use 'cuda' to leverage the GPU
@app.route('/transcribe', methods=['POST'])
@rickt
rickt / analytics-dumper.go
Last active October 8, 2024 12:46
example Go code showing how to download reporting data from Google Analytics using the Core Reporting API (updated 2015)
//
// EDIT: this code is now old
// i have recently (april 2016) updated it to use the new golang.org/x/oauth2 lib
// you can get the new analytics dumper at the below url:
// https://gist.github.com/rickt/d839564155cac15d59b6027668d8cb64
//
package main
import (
@rickt
rickt / Dockerfile
Created September 25, 2024 22:18
Dockerfile for faster-whisper in GCP Cloud Run GPU
#
# Dockerfile for a simple PoC faster-whisper translation server in GCP GPU Cloud Run
# 20240925 rickt
#
# build: $ docker build -t gcr.io/<gcp_project_name>/<service_name> .
# push: $ docker push gcr.io/<gcp_project_name>/<service_name>
# deploy: $ gcloud beta run deploy <service_name> --region us-central1 --image gcr.io/<gcp_project_name>/<service_name> \
# --port 8080 --cpu 8 --memory 32Gi --gpu 1 --gpu-type nvidia-l4 --max-instances 1 --allow-unauthenticated
#
@rickt
rickt / wvdl.sh
Created May 18, 2022 21:54
widevine downloader & decrypter
#! /bin/bash
#
# rough and ready bash script to download & decrypt a widevine-encrypted video via MPD URL
# this will work with (for example) channel5 UKTV
#
# assumptions:
# 1) the following binaries are in your $PATH:
# curl, ffmpeg, head, jq, mp4decrypt, yt-dlp
#
# this script requires 2x arguments:
@rickt
rickt / fogdownloader.sh
Created January 20, 2022 21:09
souf bay cam downloader bash script/hack
#! /bin/bash
# set required date range using epoch. sample data used below
RANGE=`seq 1642701000 50 1642710633`
# ensure tmp folder exists
TEMPDIR=/tmp/fogpics_$$
[ ! -d "$TEMPDIR" ] && mkdir -p $TEMPDIR
# download the pics
import os
from google.cloud import bigquery
def csv_loader(data, context):
client = bigquery.Client()
dataset_id = os.environ['DATASET']
dataset_ref = client.dataset(dataset_id)
job_config = bigquery.LoadJobConfig()
job_config.schema = [
bigquery.SchemaField('id', 'INTEGER'),
@rickt
rickt / bzip-inline-decompress.go
Last active June 16, 2021 10:14
HOW-TO: inline-decompress a .bz2 file with Go
package main
import (
"bufio"
"compress/bzip2"
"fmt"
"io"
"os"
)
@rickt
rickt / analyticsdumper.go
Last active April 11, 2020 16:19
example Go code showing how to download reporting data from Google Analytics using the Core Reporting API, a Google service account + oauth2 (UPDATE: go here http://code.rickt.org/post/142445693275/updated-golang-code-to-query-ga-data-via-the instead)
package main
import (
"fmt"
"golang.org/x/oauth2"
"golang.org/x/oauth2/jwt"
"google.golang.org/api/analytics/v3"
"io/ioutil"
"log"
"time"
@rickt
rickt / gdf.go
Last active February 21, 2020 23:41
gdf: Google Drive Find -- Search for a file in Google Drive using a service account and the (Golang) Google Drive API (v3)
package main
import (
"fmt"
"github.com/dustin/go-humanize"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"google.golang.org/api/drive/v3"
"io/ioutil"
"log"
#
# Example fluentd config file for nginx access log injection into Google Bigquery
# collecting nginx access log
<source>
@type tail
tag accesslogs-rickts-dev-box
path /var/log/nginx/access.log
format apache
buffer_type file