Skip to content

Instantly share code, notes, and snippets.

View enobufs's full-sized avatar

Yutaka Takeda enobufs

  • Twitch Interactive, Inc.
  • San Mateo, CA
View GitHub Profile
@enobufs
enobufs / before_after_each_test.go
Created May 7, 2022 23:07
beforeEach and afterEach with go-test
package main
import (
"fmt"
"os"
"runtime"
"testing"
)
func TestMain(m *testing.M) {
"""List S3 objects into a CSV file
"""
import argparse
import json
import pandas as pd
import subprocess
parser = argparse.ArgumentParser(description='List S3 objects into a CSV file')
parser.add_argument('bucket', type=str, help='bucket name')
@enobufs
enobufs / chrome-to-usrsctp.md
Last active February 23, 2020 09:07
Find usrctp revision by Chrome version
@enobufs
enobufs / main.go
Created October 18, 2019 23:07
Cgo deadlock with C.usleep()
package main
/*
#include <unistd.h>
*/
import "C"
import (
"log"
"time"
)
@enobufs
enobufs / index.html
Last active April 19, 2022 16:31
MediaTrackSettings.echoCancellation Test
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<style>
html, body{
height: 100%;
width: 100%;
}
#video{
height: 300px;
@enobufs
enobufs / main.go
Created June 22, 2019 22:39
What happens if I send a UDP packet to "0.0.0.0"?
package main
import (
"fmt"
"net"
"time"
)
// Add an alias 127.0.0.2 to your lo0 with the following command (macOS) first:
// macOS
@enobufs
enobufs / sna.go
Created February 13, 2019 06:11
Sequence Number Arithmetic (RFC 1982) for Go
// sna32 provides 32-bit serial number arithmetic (RFC 1982)
type sna32 uint32
// lessThan comares 32-bit serial numbers
func (sn sna32) lessThan(val sna32) bool {
return (sn < val && val-sn < 1<<31) || (sn > val && sn-val > 1<<31)
}
func (sn sna32) lessThanOrEqualTo(val sna32) bool {
return sn == val || sn.lessThan(val)
@enobufs
enobufs / main.go
Last active June 2, 2023 03:54
Pion data channel example
package main
import (
"encoding/json"
"log"
"time"
"github.com/pion/webrtc/v2"
)
@enobufs
enobufs / scan.js
Last active October 27, 2018 09:01
Scan NdArray in row-major oder.
const nj = require('numjs');
function scan(ndarr, cb) {
const args = Array(ndarr.shape.length).fill(0);
function _scan(ndarr, cb) {
const shape = ndarr.shape;
const argi = args.length - shape.length;
for (args[argi] = 0; args[argi] < shape[0]; ++args[argi]) {
if (shape.length > 1) {
const d = ndarr.pick(args[argi]);
@enobufs
enobufs / cp_files.sh
Last active October 6, 2018 23:55
Copy files with modifying file names in Bash
#!/bin/bash
srcdir=./sample
dstdir=.
array=(`find $srcdir -type f`)
#echo Length: ${#array[@]}
for i in "${array[@]}"
do