Skip to content

Instantly share code, notes, and snippets.

View wanghongfei's full-sized avatar
🎯
Focusing

wanghongfei wanghongfei

🎯
Focusing
View GitHub Profile
@wanghongfei
wanghongfei / awake-usbdisk.go
Created January 17, 2021 03:03
保持usb外接硬盘活动状态,防止休眠;间隔 1min向usb硬盘中写入一个文件来防止休眠
package main
import (
"io"
"log"
"os"
"time"
)
func main() {
@wanghongfei
wanghongfei / rm-target.go
Created June 19, 2018 08:49
递归遍历当前目录,删除指定文件
package main
import (
"path/filepath"
"os"
"fmt"
)
func main() {
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
@wanghongfei
wanghongfei / ArgParser.py
Created April 3, 2016 18:01
仿getopt实现的python命令行参数解析器
# 解析命令行参数
class ArgParser:
def __init__(self, args, mod):
self.args = args
self.mod = mod
self.tokens = []
self.__parse_mode__()
# 解析mod参数
@wanghongfei
wanghongfei / clean-target.sh
Created April 2, 2016 13:15
递归当前目录下所有target/目录
#!/bin/bash
log_info() {
echo "[INFO] => $1"
}
log_del() {
echo "[DELETE] => $1"
}
@wanghongfei
wanghongfei / RequsetParser.java
Created December 22, 2015 16:55
Netty HTTP请求参数解析器, 支持GET和POST
package cn.fh.http.component;
import cn.fh.http.exception.BaseCheckedException;
import cn.fh.http.exception.MethodNotSupportedException;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.HttpMethod;
import io.netty.handler.codec.http.QueryStringDecoder;
import io.netty.handler.codec.http.multipart.Attribute;
import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder;
import io.netty.handler.codec.http.multipart.InterfaceHttpData;
# encoding=UTF-8
__author__ = 'whf'
import socket
import subprocess
import sys
import thread
HOST = ''
PORT = 9013
# encoding=UTF-8
__author__ = 'whf'
import socket
import subprocess
import sys
HOST = ''
PORT = 9013
@wanghongfei
wanghongfei / schedule.java
Created June 19, 2015 06:44
tbschedule DEMO
package com.anzhi.schedule.task;
import com.anzhi.schedule.model.PassportModel;
import com.taobao.pamirs.schedule.IScheduleTaskDealSingle;
import com.taobao.pamirs.schedule.TaskItemDefine;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
@wanghongfei
wanghongfei / del-git.py
Created June 18, 2015 16:18
清除git版本控制
__author__ = 'wanghongfei'
# -*- coding:utf8 -*-
import os
# 删除指定目录下的所有文件
def del_dir(base_path):
file_list = os.listdir(base_path)
for name in file_list:
@wanghongfei
wanghongfei / eat-tip
Created June 18, 2015 15:00
提醒自己订餐,要不明天中午没的吃了
__author__ = 'wanghongfei'
# -*- coding:utf8 -*-
import Tkinter
WIDTH = 300
HEIGHT = 200
# centralize window
def center_window(root, w, h):