Skip to content

Instantly share code, notes, and snippets.

View cobookman's full-sized avatar

Colin Bookman cobookman

  • LinkedIn (Ex AWS/GCP)
  • San Francisco, CA
View GitHub Profile
@cobookman
cobookman / gist:c1a9856a4588496b021a
Last active August 17, 2021 12:39
HTML5 Audio (mp3) and Video (webm) live transcoding streams

The following two functions will stream just about any audio or video file to any browsers supporting mp3 and/or webm. Due to the unknown number of bytes, a custom html5 audio/video player will have to be written (my next step) to allow seeking.

For w/e reason node.js didn't want to spawn a child process with a unix pipe in it. This could be so that they can keep support for windows computers. As such I've created the following bash script:

#!/bin/bash
START_TIME=${2:-0}
VARIABLE_BIT_RATE=${3:-4}
ABSOLUTE_PATH=$1
### Keybase proof
I hereby claim:
* I am cobookman on github.
* I am cobookman (https://keybase.io/cobookman) on keybase.
* I have a public key whose fingerprint is E22F 161C 78BC C866 035A A959 301D 2FC3 9883 D638
To claim this, I am signing this object:
@cobookman
cobookman / Readme.md
Last active May 12, 2017 15:50
Translate API Examples

How to get an API Key.

  1. Head to API Manager
  2. Click on credentials
  3. Create new credential->Api Key
  4. Your api key is a string in the form of something like: BIzqTyzdDdg3fBqaouJI6z2nC3ygJNZ1qZsoYGc
package com.google.cloud.dataflow.teleport;
import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.PipelineResult;
import org.apache.beam.sdk.io.TextIO;
import org.apache.beam.sdk.io.gcp.datastore.DatastoreIO;
import org.apache.beam.sdk.io.gcp.datastore.DatastoreV1;
import org.apache.beam.sdk.options.Description;
@cobookman
cobookman / DatastoreToGcs.java
Created June 7, 2017 16:09
Working ShadowJar Build
package com.google.cloud.dataflow.teleport;
import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.PipelineResult;
import org.apache.beam.sdk.io.TextIO;
import org.apache.beam.sdk.io.gcp.datastore.DatastoreIO;
import org.apache.beam.sdk.io.gcp.datastore.DatastoreV1;
import org.apache.beam.sdk.options.Default;
@cobookman
cobookman / package.json
Created July 24, 2017 18:02
Hello World - Sockets - HTTPS Load Balancer - Nodejs - Sticky Sessions
{
"name": "hello-sockets",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "~4.15.3",
"socket.io": "~2.0.3"
},
"engines": {
"node": "4.7.2"
@cobookman
cobookman / index.html
Created August 3, 2017 01:31
Speech Streaming with Python & GRPC
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h2>Transcript</h2>
<div id="transcript"><?div>
<script>
var app = {
@cobookman
cobookman / README.md
Last active November 25, 2021 14:26
Speech API + Tornado + Python3 + WSS

How to setup this PoC. In this example we'll be using user credentials vs service accounts.

  1. Create a GCP Project. For example let's call it tivo-test

  2. In the cloud console, open VPC Network->Firewall Rules. Firewall Rule

  3. Enable the speech API. (Follow steps in slides)

  4. Create a VM in the GCP project running Ubuntu.

  5. SSH into the vm and run the following commands:

sudo apt-get update \
&& sudo apt-get upgrade -y \
&& sudo apt-get dist-upgrade \
&& sudo apt-get install python3-pip -y \
&& pip3 install google-cloud-bigquery \
&& wget https://gist.githubusercontent.com/cobookman/424670df4c1dca6e5c75a8df7b62e760/raw/eba0bfec3871089446ce6f31efbf066b83ed150f/forever.sh \
&& wget https://gist.githubusercontent.com/cobookman/424670df4c1dca6e5c75a8df7b62e760/raw/eba0bfec3871089446ce6f31efbf066b83ed150f/test.py \
&& chmod +x * \
&& sudo reboot -n
@cobookman
cobookman / Example VTT
Last active September 19, 2019 21:11
WebVTT Generation from Google Video Intelligence API
./captioner.py \
--video=gs://us-central1-cdn-test-files/static-mp4/stay_tuned.mp4 \
--service_account=service_account.json \
--out=stay_tuned.vtt
---
WEBVTT
0:0:1.500 --> 0:0:4.500
Is this a scene from an action movie where this wild