Skip to content

Instantly share code, notes, and snippets.

View lepig's full-sized avatar
🎯
Focusing

Geek Cho lepig

🎯
Focusing
  • Global
View GitHub Profile
@lepig
lepig / merge_mijia.py
Created May 11, 2021 00:50 — forked from secsilm/merge_mijia.py
合并米家摄像头监控视频,生成以天为单位的视频文件。
import subprocess
from pathlib import Path
from loguru import logger
def merge_vids(vidlist_file: str, tofile: str):
"""执行 ffmpeg 命令合并视频。"""
cmd = f"ffmpeg -f concat -safe 0 -i {vidlist_file} -c:v copy -c:a flac -strict -2 {tofile}"
subprocess.run(cmd)
@lepig
lepig / randomFromDev.php
Last active May 22, 2020 14:13
读取/dev/urandom获取随机数
<?php
function randomFromDev($len)
{
$fp = @fopen('/dev/urandom','rb');
$result = '';
if ($fp !== FALSE) {
$result .= @fread($fp, $len);
@fclose($fp);
}
@lepig
lepig / my_zsh_func.sh
Last active April 1, 2020 02:41
zsh alias settings
function hs() {
( cd ~/Homestead && vagrant $* )
}
function proxy() {
export http_proxy=http://127.0.0.1:1080
export https_proxy=$http_proxy
echo "Done"
}
function disproxy() {
unset http_proxy https_proxy
@lepig
lepig / ip-rating.php
Created October 3, 2019 02:30
使用redis进行ip限速
<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis->auth("php001");
//这个key记录该ip的访问次数 也可改成用户id
//$key = 'userid_11100';
$key=get_real_ip();
//限制次数为5
$limit = 5;
@lepig
lepig / fibonacci_closure.go
Last active May 14, 2019 02:21
斐波那契数列-Golang闭包Demo
package main
import "fmt"
func main() {
f := fibonacci()
for i:=0; i<10; i++ {
fmt.Println(f())
}
}
@lepig
lepig / swapVars.go
Created May 7, 2019 03:14
不借助第三方变量交换2个变量的值
package main
import (
"fmt"
)
func main() {
a,b := 10,20
a,b = swapNumOne(a,b)
fmt.Println("第一种:", a,b)
<?php
// exit;
for ($i = 1; $i < 10; $i++) {
for ($j = $i; $j < 10; $j++) {
echo "{$i}" . "x" . "{$j}" .'='. ($i * $j) . ' ';
}
echo "\n";
}
@lepig
lepig / bash_alias.sh
Last active August 27, 2018 01:02
Homestead bash_alias file
alias ..="cd .."
alias ...="cd ../.."
alias h='cd ~'
alias c='clear'
alias art=artisan
alias phpspec='vendor/bin/phpspec'
alias phpunit='vendor/bin/phpunit'
alias serve=serve-laravel
@lepig
lepig / _ide_helper.php
Created June 21, 2018 01:48 — forked from barryvdh/_ide_helper.php
Laravel IDE Helper for Netbeans / PhpStorm / Sublime Text 2 CodeIntel, generated using https://github.com/barryvdh/laravel-ide-helper
<?php
/**
* A helper file for Laravel 5, to provide autocomplete information to your IDE
* Generated for Laravel 5.5.13 on 2017-09-28.
*
* @author Barry vd. Heuvel <barryvdh@gmail.com>
* @see https://github.com/barryvdh/laravel-ide-helper
*/
namespace {
exit("This file should not be included, only analyzed by your IDE");
@lepig
lepig / get-yii2-ar-raw-sql.php
Created May 18, 2018 05:36 — forked from dcb9/get-yii2-ar-raw-sql.php
如何获取 YII2 AR 执行的 SQL 语句,直接用程序输出,而不是通过日志去查看
<?php
$query = User::find()
->where(['id'=>[1,2,3,4])
->select(['username'])
// get the AR raw sql in YII2
$commandQuery = clone $query;
echo $commandQuery->createCommand()->getRawSql();