Skip to content

Instantly share code, notes, and snippets.

@odeke-em
odeke-em / traced-opencv-example.py
Created May 5, 2018 07:39
Tracing an OpenCV tutorial app with OpenCensus Python
#!/usr/bin/env python3
"""
Copyright 2018, OpenCensus Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
u may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@tiernan
tiernan / serviceworker.d.ts
Last active June 10, 2023 10:59
Service Worker Typings to Supplement lib.webworker.ts
/**
* Copyright (c) 2018, Tiernan Cridland
*
* Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby
* granted, provided that the above copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
@Zate
Zate / get_go.sh
Last active January 20, 2025 18:57
Shell script to download and install latest golang
#! /bin/bash
# [get_golang.sh](https://gist.github.com/n8henrie/1043443463a4a511acf98aaa4f8f0f69)
# Download latest Golang release for AMD64
# https://dl.google.com/go/go1.10.linux-amd64.tar.gz
set -euf -o pipefail
# Install pre-reqs
sudo apt-get install python3 git -y
o=$(python3 -c $'import os\nprint(os.get_blocking(0))\nos.set_blocking(0, True)')
const o = {
value: new Map,
done: false,
async * gen(...props) {
while (!this.done) {
if (this.value.size && !this.done) {
try {
for (const [key, val] of this.value) {
// yield* [{key, value: await Promise.all([].concat(val).map(prop => typeof prop === "function" ? prop() : prop)).then(values => { this.value.delete(key); return values }).catch(err => {console.log(err); return {error:[key, err]}})}];
// does not interrupt immediately when `this.done` is set to `true`
@jart
jart / blakefiler.py
Last active October 2, 2024 13:29
Turns bazel query --output=build //tensorflow:libtensorflow_framework.so into isomorphic Makefile
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@adactio
adactio / minimal-serviceworker.js
Last active August 18, 2023 09:15
An attempt at a minimal viable service worker.
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
// HTML files: try the network first, then the cache.
// Other files: try the cache first, then the network.
// Both: cache a fresh version if possible.
// (beware: the cache will grow and grow; there's no cleanup)
const cacheName = 'files';
@CodingDoug
CodingDoug / README.md
Last active March 1, 2025 02:52
Building an assistant (chatbot) that translates languages, integrated with Slack
@enricofoltran
enricofoltran / main.go
Last active April 6, 2025 09:48
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@sebmarkbage
sebmarkbage / Infrastructure.js
Last active February 26, 2025 13:57
SynchronousAsync.js
let cache = new Map();
let pending = new Map();
function fetchTextSync(url) {
if (cache.has(url)) {
return cache.get(url);
}
if (pending.has(url)) {
throw pending.get(url);
}
@InAnimaTe
InAnimaTe / kcc
Last active December 5, 2018 10:53
kubectl context/namespace switcher!
function kcc () {
usage () {
echo -en "Usage: $0 <context> <namespace>\n"
}
result () {
echo -en "-> Context: \e[96m$context\e[0m\n-> Namespace: \e[92m$namespace\n\e[0m"
}
if [ $# -eq 0 ] ; then
## If no options, print the current context/cluster and namespace
context="$(kubectl config current-context 2>/dev/null)"