Skip to content

Instantly share code, notes, and snippets.

@jgkong
jgkong / vimrc
Created August 17, 2021 18:29
vimrc
" Arcy's vim environment (based on perky's)
let g:Arcy="4.7"
let mapleader="\<Space>"
set nocompatible
"set fileformat=unix
set formatoptions=tcql
set ai
@jgkong
jgkong / mirror_images.sh
Created August 17, 2021 18:27
mirror_images.sh
while :; do
read LINE
[ -z "${LINE}" ] && exit
IMAGE=$(echo ${LINE} |sed -e 's#.* "GET /v2/\(.*\)/manifests/\(.*\) HTTP/1.0" .*#\1@\2#')
echo ${IMAGE}
oc image mirror --filter-by-os="linux/amd64" registry.from.com/${IMAGE} registry.my.com/${IMAGE%@*}
done
#include <Joystick.h>
#define COLS 4
#define ROWS 4
#define PINS COLS+ROWS
#define BTNS COLS*ROWS
#define BTNCOUNT 12
// Pins 1-7 of the keypad connected to the Arduino respectively:
@jgkong
jgkong / Agenda.md
Created July 22, 2019 10:04
aganda.md

Networking

Transport Layer

WiFi

BLE / Bluetooth

ZigBee

Z-Wave

LoRa / NB-IoT / LTE-M / SIGFOX

Protocol

HTTP(S)

[{"id":"9c6cf1e1.8e009","type":"ibmiot out","z":"759e2a0c.e57d04","authentication":"boundService","apiKey":"91fe8e33.3d3f7","outputType":"cmd","deviceId":"+","deviceType":"badge2018","eventCommandType":"led","format":"json","data":"default","qos":0,"name":"IBM IoT - led","service":"registered","x":630,"y":160,"wires":[]},{"id":"d62d81b7.a9c39","type":"inject","z":"759e2a0c.e57d04","name":"Yellow LED Toggle","topic":"","payload":"{\"d\":{\"target\":\"red\",\"action\":\"toggle\"}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":160,"wires":[["5198c38b.5b95bc"]]},{"id":"bb2e3be3.23af08","type":"debug","z":"759e2a0c.e57d04","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":610,"y":220,"wires":[]},{"id":"ee682306.e8f7d","type":"comment","z":"759e2a0c.e57d04","name":"LED Command","info":"","x":180,"y":120,"wires":[]},{"id":"64d02863.c76408","type":"inject","z":"759e2a0c.e57d04","name":"Yellow LED On","topic":"","payload":"{\"d\":{
conf = Config('ibmiot')
conf.data
{'authToken': 'badge2365818', 'orgID': 'quickstart', 'deviceType': 'badge2018', 'user': 'use-token-auth', 'deviceID': '30AEA4151D58'}
conf.data['orgID'] = 'My Organization ID'
conf.save()
rx = machine.RMT(rmt_mode=machine.RMT.RX, channel=4, clk_div=80, pin=machine.Pin(26), mem_block_num=4)
rx.config(filter_en=True, filter_ticks_thresh=100, idle_threshold=30000, rx_buf_size=4000)
cmd = rx.receive()
tx = machine.RMT(rmt_mode=machine.RMT.TX, channel=0, clk_div=80, pin=machine.Pin(16))
tx.config(loop_en=False)
tx.send(list(map(lambda x: ((x[0][0], 1-x[0][1]), (x[1][0], 1-x[1][1])), cmd)))
@jgkong
jgkong / name.py
Last active November 20, 2018 07:46
Display name on badge with uGFX
last_name = 'KONG'
first_name = 'Jin Gi'
company = 'IBM'
ugfx.clear(ugfx.BLACK)
ugfx.set_default_font('IBMPlexMono_Bold48')
ugfx.text(82, 30, first_name, ugfx.WHITE)
ugfx.text(108, 90, last_name, ugfx.WHITE)
ugfx.text(121, 150, company, ugfx.BLUE)
@jgkong
jgkong / boot.py
Created November 18, 2018 13:15
ap mode
import ugfx
import machine
import network
from util import *
sta_if = network.WLAN(network.STA_IF)
import webrepl
import machine
from bh1750 import BH1750
import time
scl = machine.Pin(33, machine.Pin.IN)
sda = machine.Pin(26, machine.Pin.IN)
i2c = machine.I2C(scl,sda)
s = BH1750(i2c)