Skip to content

Instantly share code, notes, and snippets.

View huzhifeng's full-sized avatar

Zhifeng Hu huzhifeng

View GitHub Profile
@huzhifeng
huzhifeng / Makefile
Last active January 31, 2024 06:35
MPI and OpenMP Example
BINS:= mpi greetings omp hybrid
all: $(BINS)
mpi: mpi-hello.c
mpicc -o mpi mpi-hello.c
greetings: mpi-greetings.c
mpicc -o greetings mpi-greetings.c
/**
* 身份证号码验证
*
*/
function isIdCardNo(num) {
var factorArr = new Array(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1);
var parityBit=new Array("1","0","X","9","8","7","6","5","4","3","2");
var varArray = new Array();
var intValue;
@huzhifeng
huzhifeng / Makefile
Last active July 27, 2017 11:52
UDP latency test (Based on https://www.abc.se/~m6695/udp.html)
CC = gcc
CFLAGS = -O2 -g -Wall
INSTALL_DIR = /usr/bin
.PHONY: clean install uninstall
all: server client
server: udp-server.c
$(CC) udp-server.c -o udp-server
@huzhifeng
huzhifeng / screencapture-ffmpeg.sh
Created June 9, 2017 03:03
Use ffmpeg to capture desktop
#!/bin/sh
VIDEO_DIR=${HOME}/Videos
VIDEO_TIME=`date +'%Y%m%d%H%M%S'`
VIDEO_SUFFIX=mkv
VIDEO_FILE=${VIDEO_DIR}/${VIDEO_TIME}.${VIDEO_SUFFIX}
if [ ! -e ${VIDEO_DIR} ]; then
mkdir -p ${VIDEO_DIR}
fi
@huzhifeng
huzhifeng / smb.conf
Created April 9, 2017 15:22
Samba sample
[global]
workgroup = WORKGROUP
security = user
map to guest = bad user
create mask = 0644
directory mask = 0755
[pub]
path = /public
browseable = yes
@huzhifeng
huzhifeng / _service.md
Created January 10, 2017 01:26 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@huzhifeng
huzhifeng / 0-openwrt-auto-mount-readme.md
Last active September 14, 2016 23:53 — forked from lanceliao/0-openwrt-auto-mount-readme.md
Auto mount USB storage device by uuid on OpenWrt
  1. Install USB device support;
opkg install kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb-storage e2fsprogs fdisk usbutils mount-utils block-mount kmod-fs-ext4 kmod-fs-vfat kmod-nls-utf8 kmod-nls-cp437 kmod-nls-iso8859-1

reboot
  1. Install blkid, run opkg update && opkg install blkid;
  2. Copy block.sh to directory /lib/functions;
  3. Copy 10-mount and 20-swap to directory /etc/hotplug.d/block;
  4. That's it! run logread -f command then plug in a USB stick to test.
@huzhifeng
huzhifeng / 51-android.rules
Created August 22, 2016 03:40
/etc/udev/rules.d/51-android.rules
# fastboot protocol on HiKey
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d00d", MODE="0660", GROUP="dialout"
# adb protocol on HiKey
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", ATTR{idProduct}=="1057", MODE="0660", GROUP="dialout"
# rndis for HiKey
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", ATTR{idProduct}=="1050", MODE="0660", GROUP="dialout"
@huzhifeng
huzhifeng / 90-tty-usb.rules
Created August 22, 2016 03:28
udev rule for usb serial
/etc/udev/rules.d/90-tty-usb.rules
# CP210x
SUBSYSTEMS=="usb", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE="0666"
How to add udev rule for usb serial device
[huzhifeng@CentOS72 ~]$ minicom
Cannot create lockfile for /dev/ttyUSB0: 权限不够
[huzhifeng@CentOS72 ~]$ su root -l
[root@CentOS72 ~]# ls -al /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 8月 22 08:59 /dev/ttyUSB0