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 / export_1.js
Created August 19, 2016 19:03
Sample code for googleapis issue #618
// Copyright 2016, Google, Inc.
// 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,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@enobufs
enobufs / softmax.js
Created July 28, 2018 03:02
Softmax in JS using ndarray
const ndarray = require("ndarray");
const ops = require("ndarray-ops");
// Softmax in-place
const softmax = (() => {
function denom(arr, C) {
const tmp = ndarray(new Float32Array(arr.size));
ops.assign(tmp, arr);
ops.addseq(tmp, -C);
ops.expeq(tmp);
@enobufs
enobufs / donkeycar-operation-notes.md
Last active October 28, 2018 03:13
Donkey Car: Operation notes

WiFi connection

Adding WiFi access point

  1. Hook monitor and keyboard via HDMI and USB cables.
  2. Login with username, "pi", and its password.
  3. sudo vi /etc/wpa_supplicant/wpa_supplicant.conf, then add network={} with your SSID and password (you can have more than one network section).
  4. sudo wpa_cli -i wlan0 reconfigure
  5. Note the MAC address for wlan0. (Later used to identify IP address from your laptop)

Find the IP address from your laptop

  1. Use ifconfig to learn your subnet broadcast address (e.g. 10.0.0.255)

How to obtain Imanagent Dataset

Settings

Install kaggle CLI.

pip install kaggle

Then make sure that you have kaggle.json obtained from kaggle.com under $HOME/.kaggle/.

Download

@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
@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 / main.go
Last active June 30, 2024 15:07
Pion data channel example
package main
import (
"encoding/json"
"log"
"time"
"github.com/pion/webrtc/v2"
)
@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
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 / 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;