Skip to content

Instantly share code, notes, and snippets.

View jaycosaur's full-sized avatar
🐦

Jacob Richter jaycosaur

🐦
  • Sydney, Australia
View GitHub Profile
from shared import camera_producer, cpu_bound, display
def main():
frames = camera_producer()
cpu_bound_op = cpu_bound()
for frame in frames:
cpu_bound_op(frame)
display(frame)
@jaycosaur
jaycosaur / OverwritingRingBuffer.ts
Created October 11, 2019 09:55
Typescript implementation of overwriting ring buffer with memory of insertion position for gets. Useful for a rolling video frame / audio frame cache requiring lookups.
// extension of classical overwriting ring buffer that holds an incremental counter that can be indexed
// this should not be used for read heavy write infrequent streams (as a map would be a much mor effective implementation)
// this could be used for write heavy read infrequent streams
export class OverwritingRingBuffer<T> {
private buffer: T[];
private bufferLength: number;
private pointer: number;
private counter: number;
import { google } from 'googleapis';
import { auth } from 'google-auth-library'
export default class getModel {
modelName: string;
projectName: string;
constructor(attrs) {
this.modelName = attrs.modelName
this.projectName = attrs.projectName
@jaycosaur
jaycosaur / FetchAPI.js
Last active February 24, 2018 04:53
React Fetch Render Props Example
class APIFetch extends Component {
constructor(props){
super(props)
this.state = {
data: null,
isError: false,
isFetching: true
}
}
@jaycosaur
jaycosaur / fetchHOC.js
Last active February 24, 2018 05:15
React Fetch Higher Order Component Example
const fetchHOC = (WrappedComponent, fetchPath, optionalHeader) => {
return class extends Component {
constructor(props){
super(props)
this.state = {
data: null,
isError: false,
isFetching: true
}
}