Skip to content

Instantly share code, notes, and snippets.

@fengqi
fengqi / MazeSolver.java
Created May 12, 2023 15:35
迷宫寻路
import java.util.ArrayList;
import java.util.List;
public class MazeSolver {
static final int ROW = 5;
static final int COL = 5;
static final int startX = 0;
static final int startY = 0;
static final int endX = 4;
static final int endY = 4;
@fengqi
fengqi / clipboard.lua
Last active May 12, 2023 04:07
hammerspoon实现的剪切板历史
-- 轮询剪贴板的频率
local frequency = 2
-- 剪贴板历史记录条数
local history_size = 10
-- 显示在菜单栏中的字符长度
local label_length = 50
-- 还原剪贴板历史记录
@fengqi
fengqi / tencent_lighthouse_traffic.php
Last active July 8, 2022 09:28
获取腾讯轻量云服务器流量包使用情况
#!/usr/bin/env php
<?php
$cache = '/tmp/_lighthouse_traffic_';
$cacheTime = 3600;
$now = time();
if (is_file($cache) && is_readable($cache)) {
$content = file_get_contents($cache);
$_time = substr($content, 0, 10);
$content = substr($content, 10);
@fengqi
fengqi / caesar.go
Created February 23, 2022 10:08
凯撒密码加密解密
// CaesarEncode 凯撒密码:加密
func CaesarEncode(str string, step rune) string {
step = step % 26
strSlice := []rune(str)
dstSlice := strSlice
for i := 0; i < len(strSlice); i++ {
if !unicode.IsLetter(strSlice[i]) {
strSlice[i] = strSlice[i]
continue
}
@fengqi
fengqi / pve_host_mac_ip.sh
Last active February 16, 2022 11:00
pve根据id生成openwrt静态ip绑定配置
#!/bin/bash
prefix="192.168.50"
cd /etc/pve/nodes/pve/lxc
for conf in `ls`;do
id=$(echo $conf|awk -F '.' '{print $1}')
name=$(cat $conf|grep hostname|awk '{print $2}')
mac=$(cat $conf|grep 'net0:'|awk -F '[=,]' '{print $8}')
-- 引入类库
local redis = require "resty.redis".new()
local mysql = require "resty.mysql".new()
local cjson = require "cjson"
-- 获取参数
local param_get = ngx.req.get_uri_args()
local id = param_get["id"]
-- 连接 Redis
@fengqi
fengqi / GithubGist.php
Last active August 29, 2015 14:21
解析内容源代码中的 Github Gist
<?php
/**
* 解析内容源代码中的 Github Gist 链接
*
* @package Github Gist
* @version 0.0.1
* @author Simple Code
* @link http://typecho.org
*/
class GithubGist implements Typecho_Plugin_Interface
@fengqi
fengqi / fonts.fengqi.me.conf
Last active November 8, 2017 15:34
fonts.fengqi.me
server {
listen 80;
listen [::]:80;
listen 443;
listen [::]:443;
server_name fonts.fengqi.me font.fengqi.me;
root /data/www/fonts.fengqi.me.SF92s/;
index index.php;
@fengqi
fengqi / walk_and_bike.cpp
Last active August 29, 2015 14:20
walk_and_bike
#include <iostream>
using namespace std;
int main()
{
int num = 0;
cin >> num;
double delta = 1e-5; // ??
for (int i =0 ; i < num; i++) {