Skip to content

Instantly share code, notes, and snippets.

use std::env::args;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::str::FromStr;
fn main() {
let mut args = args();
if args.len() == 3 {
args.next();
let interval = u32::from_str(&args.next().unwrap()).unwrap();
// file: select_delay.rs
// date: 2019-04-09
// license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
// author: nanpuyue <[email protected]> https://blog.nanpuyue.com
use std::time::{Duration, Instant};
use futures::Future;
use tokio::timer::Delay;
#!/bin/bash
# file: export_data.sh
# date: 2019-03-29
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <[email protected]> https://blog.nanpuyue.com
# note:
# sigrok-cli -i xxx.sr -P uart:baudrate=1500000:tx=D3 -A uart=tx-data --protocol-decoder-samplenum
INTERVAL=100
END=0
@nanpuyue
nanpuyue / yubikey-touch-notify
Created March 9, 2019 14:25
a notifier for yubikey-touch-detector
#!/bin/bash
# file: yubikey-touch-notify
# date: 2019-03-09
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <[email protected]> https://blog.nanpuyue.com
# refer: https://github.com/maximbaz/yubikey-touch-detector
SOCKET="$XDG_RUNTIME_DIR/yubikey-touch-detector.socket"
NOTIFY_ICON="dialog-information"
@nanpuyue
nanpuyue / ss-local
Created February 16, 2019 14:34
ss-local init.d script for openwrt
#!/bin/sh /etc/rc.common
# file: /etc/init.d/ss-local
# date: 2018-11-06
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <[email protected]> https://blog.nanpuyue.com
START=95
USE_PROCD=1
start_service() {
@nanpuyue
nanpuyue / build_mips-unknown-linux-musl.sh
Last active February 21, 2019 14:12
build rust toolchain for mips-unknown-linux-musl
#!/bin/bash
# file: build_mips-unknown-linux-musl.sh
# date: 2018-12-24
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <[email protected]> https://blog.nanpuyue.com
export LC_ALL=C
export STAGING_DIR="/build/openwrt-sdk-18.06.1/staging_dir"
export TOOLCHAIN="toolchain-mips_24kc_gcc-7.3.0_musl"
export PATH="$STAGING_DIR/$TOOLCHAIN/bin/:$PATH"
#!/usr/bin/env python3
from smbus import SMBus
# Use /dev/i2c-0
smbus = SMBus(0)
# Use PEC
smbus.pec = True
ADDR1 = 0x34
ADDR2 = 0x36
#!/bin/bash
# file: x-input.sh
# date: 2018-11-12
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <[email protected]> https://blog.nanpuyue.com
#
# 依赖:zenity xdotool xclip
#
# 使用时将脚本绑定快捷键,例如:
# 设置快捷键 alt + t 绑定 x-input.sh
@nanpuyue
nanpuyue / frpc
Created November 6, 2018 13:30
frpc init script for openwrt
#!/bin/sh /etc/rc.common
# date: 2018-11-06
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <[email protected]> https://blog.nanpuyue.com
START=95
USE_PROCD=1
start_service() {
procd_open_instance
# file: nginx.conf
# date: 2018-10-13
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <[email protected]> https://blog.nanpuyue.com
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;