Skip to content

Instantly share code, notes, and snippets.

@tai
tai / gist:f3866b78b74dca413101
Created February 24, 2015 06:23
Quick script to git clone all KiCad libraries (*.lib components and *.pretty footprints).
#!/bin/sh -x
# Quick script to git clone all KiCad libraries (*.lib components and *.pretty footprints).
curl -S 'https://github.com/KiCad?page=[1-5]' | \
(perl -lne 'print $& while s|KiCad/[^/]+.pretty||'; echo KiCad/kicad-library) | \
sort -u | while read i; do test -d ${i#KiCad/} || git clone https://github.com/$i; done
for i in */.git; do (cd $i/.. && git pull); done
@tai
tai / softuart.cpp
Created March 8, 2015 13:59
Software UART implementation for mbed (testing)
//
// LPC1114FN28+MBED software UART test
//
// This is a pure-mbed software UART implementation.
// I tested this with 9600-8n1 configuration on LPC1114FN28/102.
//
#include "mbed.h"
//
@tai
tai / gist:38fc87627060a0e9cd94
Created March 12, 2015 08:38
Crazy USB API/driver status on Windows
After browsing and reading many pages/sources, I'm still not perfecty sure below is correct!
PROJECT develops-DLL has-API works-with-DRIVER
-------------------------------------------------------------------
libusb libusb0.DLL libusb-0.1 libusb0.SYS, libusbk.SYS
libusb-win32 libusb0.DLL libusb-0.1 (filter-driver-version-of-)libusb0.SYS
libusb libusb-1.0.DLL libusb-1.0 WinUSB.SYS
libusbx (*1) libusb-1.0.DLL libusb-1.0 WinUSB.SYS
OpenUSB libusb-1.0.DLL libusb-1.0 WinUSB.sys
libusbk libusbk.DLL libusbk+WinUSB libusbk.SYS, WinUSB.SYS, libusb0.SYS (*2)
@tai
tai / adhoc-expect.c
Created March 12, 2015 12:52
Ad-hoc expect
/*BINFMTC:-Wall -D_GNU_SOURCE
*
* 簡易expectもどきのテスト
*
* 新しくttyのペアを確保してslave側を子プロセスのcttyにしながら
* 起動するもう一方のmaster側は親プロセス側でIOして子プロセスを
* 制御する
*
* これmaster側をそのまま子プロセスにアタッチしてslave側は
* 別のkermitでもなんでも適当なもので後でアタッチして制御を
/*BINFMTC:-Wall -std=gnu99 -I/d/src/wireshark-1.12.1+g01b65bf -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lpcap
*
* Test to generate dummy pcap data for I2C communication.
*
* Usage:
* $ ./pcapgen-i2c.c hoge.pcap
* $ tshark -V -d wtap_encap==103,i2c -r hoge.pcap
*
* NOTE:
* Not sure where WTAP_ENCAP value of 103 came from.
@tai
tai / raise-and-default-param.py
Created June 23, 2015 09:44
Python bug or feature? I hate it.
#!/usr/bin/python
# -*- coding: utf-8 -*-
def check(v, trace=[]):
print("check: entered")
if trace:
print("trace: " + str(trace))
try:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
A skelton code of a framework that wraps user function
without any modification. This makes framework really
transparent and help keeping user's code clean.
The problem is that once user function gets enhanced
and needs some framework-dependent info (like processing
context), it is hard to pass it down. Hence this code to
@tai
tai / dscr.a51
Created July 5, 2015 02:36
Sample USB descriptor definition for USB-CDC with Cypress EZ-USB FX2/FX2LP + SDCC
;;; -*- mode: asm; coding: utf-8 -*-
;;;
;;; USB descriptor definition for virtual COM port implementation
;;; with Cypress EZ-USB FX2 (CY7C68013) and FX2LP (CY7C68013A).
;;;
;;; NOTE:
;;; - Works with sdcc, but may need recent version due to use of
;;; assembler macros.
;;;
@tai
tai / pexpect-with-workqueue-model.py
Created July 6, 2015 14:41
Simple workqueue implementation to serialize request to pexpect-wrapped process.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Workqueue test to serialize requests sent from multiple threads
# to protect pexpect-based backend.
#
import sys, os
import unittest
import glob
@tai
tai / .block
Created March 24, 2018 02:14
fresh block
license: mit