Skip to content

Instantly share code, notes, and snippets.

View horsley's full-sized avatar

Horsley Lee horsley

View GitHub Profile
@horsley
horsley / square_wave.ino
Created October 15, 2022 12:45
热水器方波信号,mock水流传感器
View square_wave.ino
#define LED_GPIO 26
#define PWM1_Ch 0
#define PWM1_Res 10
#define PWM1_Freq 50
void setup() {
// put your setup code here, to run once:
ledcAttachPin(LED_GPIO, PWM1_Ch);
ledcSetup(PWM1_Ch, PWM1_Freq, PWM1_Res);
}
@horsley
horsley / main.go
Created December 23, 2020 08:27
Xcode 12.3 golang script for xcframework convertion
View main.go
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"
"time"
@horsley
horsley / ocserv_hack.go
Created May 31, 2015 05:51
ocserv auth hacking
View ocserv_hack.go
// ocservFront project main.go
package main
import (
"bufio"
"bytes"
"crypto/tls"
"fmt"
"io"
"io/ioutil"
@horsley
horsley / main.go
Created April 22, 2014 05:14
文件分割器 for jingboli
View main.go
// ljbSpilter project main.go
package main
import (
"bufio"
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
@horsley
horsley / index.php
Created January 4, 2014 06:14
sms + tasker转发服务的脚本
View index.php
<?php
define('APP_PATH', dirname(__FILE__));
define('DATA_FILE', APP_PATH. '/sms.htdata');
if ($_SERVER['REQUEST_METHOD'] == 'POST') { //tasker提交
if (!isset($_POST['c'])) {
die('Invalid Request!');
} else {
$data = '';
if (file_exists(DATA_FILE)) { //读入已有数据
@horsley
horsley / autodeploy.go
Last active December 30, 2015 09:29
go语言版本autodeploy中间件,比较适用于windows服务器直接在php中调用git不灵,本程序自动寻找git执行文件路径,执行git pull,并通过http方式返回结果,带有简单的身份验证
View autodeploy.go
// gitpull project main.go
package main
import (
"fmt"
"io"
"net/http"
"os"
"os/exec"
"path/filepath"
@horsley
horsley / function.php
Last active December 28, 2015 16:09
url合成的常用函数,获取基准url和部署子目录
View function.php
<?php
/**
* 获取本系统存放的目录 对应的url
* 当本系统部署在非站点根目录的时候 需要使用本函数获取系统根目录对应url
* 其后没有斜杠
* @access public
* @return string
*/
function get_baseurl() {
@horsley
horsley / kv_cache.php
Last active December 27, 2015 06:19
一种简单的文件缓存,git风格的存储结构,简答的序列化
View kv_cache.php
<?php
/**
* 简单文件缓存
* @author: horsley
* @version: 2013-11-04
*/
class Cache {
//内存缓存,跟磁盘缓存保持一致格式
//消耗内存,但可减少一次请求内的磁盘io次数,并加速读取(命中时)
@horsley
horsley / autodeploy.php
Last active December 27, 2015 04:49
一个简单的post hook用来自动部署
View autodeploy.php
<?php
/**
* 简单自动部署
* bitbucket POST hook http://horsley:anypassword@your_host/autodeploy.php
*/
define('APP_PATH', dirname(__FILE__));
if (php_sapi_name() != 'cli') {
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
@horsley
horsley / ScreenCloser.go
Created October 23, 2013 03:15
windows下5秒关闭屏幕
View ScreenCloser.go
// ScreenCloser project main.go
package main
import (
"syscall"
"time"
)
const (
SC_MONITORPOWER = 0xF170