Skip to content

Instantly share code, notes, and snippets.

View ckhung's full-sized avatar

Chao-Kuei Hung ckhung

View GitHub Profile
@ckhung
ckhung / simPWM.ino
Created August 17, 2016 14:47
arduino: simulating pulse-width modulation
void setup() {
pinMode(9, OUTPUT);
pinMode(13, OUTPUT);
// Serial.begin(9600);
}
int epoch = 3000;
int cycle = 10;
int t = 0;
@ckhung
ckhung / ldap-objectClass-hierarchy.dot
Last active September 24, 2016 02:28
objectClass inheritance hierarchy as defined in the default schemas of openldap
// generating the content of this file:
// ldapsearch -x -LLL -o ldif-wrap=no -b cn=Subschema -s base '(objectClass=subschema)' + | perl -ne 'print "$2 -> $1;\n" if /\bNAME\s*\x27(\w+)\x27.*?\bSUP\s+(\w+)/' | grep -v '^top ->'
// generating an svg from this file:
// dot -Tsvg ldap-objectClass-hierarchy.dot > ldap-objectClass-hierarchy.svg
digraph "openldap schemas" {
rankdir = LR;
overlap = scale;
@ckhung
ckhung / fwmp.lxc.perl
Last active February 9, 2017 14:35
forward multiple port in one command ; 詳見 [fwmp 懶人的通訊埠轉發指令](https://newtoypia.blogspot.tw/2017/02/fwmp.html): 用一個指令幫區網內的一部機器 (可以是實體機、 kvm 虛擬機或 lxc 容器) 同時轉發好幾個通訊埠。
#!/usr/bin/perl -w
# LXC calls us with the following arguments:
# fwmp.lxc set $IP $hp1:$cp1 $hp2:$cp2 ... $cname net up veth $iface
# fwmp.lxc clear $IP $cname net down veth $iface
use strict;
my ($iface, undef, $when, undef, $cid, @ARGV) = reverse @ARGV;
@ARGV = reverse @ARGV;
@ckhung
ckhung / climage.py
Last active February 17, 2017 03:18
classify images using keras
#!/opt/conda/bin/python
# -*- coding: utf-8 -*-
import sys, argparse
from keras.preprocessing import image
import numpy as np
parser = argparse.ArgumentParser(description='classify images')
parser.add_argument('-v', '--verbosity', type=int,
choices=range(3), default=2, help='increase output verbosity')
@ckhung
ckhung / Dockerfile
Created February 17, 2017 03:50
a more flexible and unsafe modification of the keras docker file to allow "sudo bash", with some additional tools
# a more flexible and unsafe modification of
# https://github.com/fchollet/keras/tree/master/docker
# to allow "sudo bash", with some additional tools.
FROM nvidia/cuda:8.0-cudnn5-devel
ENV CONDA_DIR /opt/conda
ENV PATH $CONDA_DIR/bin:$PATH
RUN mkdir -p $CONDA_DIR && \
@ckhung
ckhung / mbootu3.bash
Last active June 25, 2017 13:11
切割、格式化隨身碟,並安裝 extlinux boot loader
請改用 https://github.com/ckhung/mbootuz
@ckhung
ckhung / default
Last active April 7, 2018 09:43
pxe config file example
# http://newtoypia.blogspot.com/2017/05/pxe-live-cd.html "透過 pxe 網路開機載入 live cd"
default grml
prompt 1
timeout 100
path modules/bios/
ui vesamenu.c32
menu background /pic/starry-night.jpg
menu resolution 800 600
@ckhung
ckhung / caffenet-classify.py
Last active July 5, 2017 13:47
classify images using caffe's bvlc_reference_caffenet model
#!/usr/bin/python
# modified from https://nbviewer.jupyter.org/github/BVLC/caffe/blob/master/examples/00-classification.ipynb
import numpy as np
import argparse, sys, caffe, os, pprint
parser = argparse.ArgumentParser(
description='classify images using bvlc_reference_caffenet',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-c', '--caffe', type=str,
#!/usr/bin/perl -w
# post-processing for https://github.com/wavexx/facedetect
# 詳見 http://newtoypia.blogspot.com/2017/08/facedetect.html
# 「自動(大量批次)尋找擷取、裁剪、模糊化、馬賽克照片中的人臉」
# Author: 洪朝貴
# License: GPL 3
use Getopt::Std;
use File::Basename;
use strict;
#!/usr/bin/python
# wrapper for https://github.com/ageitgey/face_recognition
from __future__ import print_function
import face_recognition
import argparse, ntpath, sys, re, json, csv
parser = argparse.ArgumentParser(
description='locate faces in pictures',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)