Skip to content

Instantly share code, notes, and snippets.

@GeHou
GeHou / ffmpeg
Created April 1, 2021 14:01
ffmpeg
ffmpeg -i input.mkv -c:v libx264 -c:a aac output.mp4
@GeHou
GeHou / gist:9c6d717460d341be4805751f43c1d3bd
Created June 14, 2020 14:59
正则表达式表单验证实例
/*是否带有小数*/
function isDecimal(strValue ) {
var objRegExp= /^\d+\.\d+$/;
return objRegExp.test(strValue);
}
/*校验是否中文名称组成 */
function ischina(str) {
var reg=/^[\u4E00-\u9FA5]{2,4}$/; /*定义验证表达式*/
return reg.test(str); /*进行验证*/
@GeHou
GeHou / gofileserver.go
Last active June 23, 2021 11:50
gofileserver
package main
import (
"flag"
"fmt"
"net/http"
"os"
"os/exec"
"path/filepath"
)
<?php
header('Content-Type: text/plain;charset=utf-8');
$data = 'phpbest';
$key = 'oScGU3fj8m/tDCyvsbEhwI91M1FcwvQqWuFpPoDHlFk='; //echo base64_encode(openssl_random_pseudo_bytes(32));
$iv = 'w2wJCnctEG09danPPI7SxQ=='; //echo base64_encode(openssl_random_pseudo_bytes(16));
echo '内容: '.$data."\n";
$encrypted = openssl_encrypt($data, 'aes-256-cbc', base64_decode($key), OPENSSL_RAW_DATA, base64_decode($iv));
echo '加密: '.base64_encode($encrypted)."\n";
/**
* 获取该条记录的自增ID
* 将自增转换为62进制,并拼接网址 如:http://qetee.com/w7e
* 用户访问到 http://qetee.com/w7e 时,提取短网址后缀 w7e
* 将短网址后缀转换为10进制,得到自增ID号 如:123456
* 使用查询该记录,进行业务逻辑处理(比如跳转)
*/
/**
* 十进制数转换成62进制
@GeHou
GeHou / weekdays
Created January 20, 2015 08:18
给定日期之间的周末天数
/*
| @param char|int $start_date 一个有效的日期格式,例如:20091016,2009-10-16
| @param char|int $end_date 同上
| @return 给定日期之间的周末天数
*/
function get_weekend_days($start_date,$end_date){
if (strtotime($start_date) > strtotime($end_date)) list($start_date, $end_date) = array($end_date, $start_date);
$start_reduce = $end_add = 0;
@GeHou
GeHou / MultiHttpRequest.php
Last active August 29, 2015 14:10
MultiHttpRequest.php
<?php
/*
* Curl 多线程类
* 使用方法:
* ========================
$urls = array("http://baidu.com", "http://dzone.com", "http://google.com");
$mp = new MultiHttpRequest($urls);
$mp->start();
* ========================
* 当然,如果你喜欢,还可以对此类进行扩展,
@GeHou
GeHou / fileTree.php
Last active August 29, 2015 13:56
fileTree
<?php
/*
* Return path folders and files
* @param string $path Input path
* @param showFolder $path is show folder
* @param pattern $path glob function's pattern
* @return array
*/
function fileTree($path, $showFolder = false, $pattern = '*'){
@GeHou
GeHou / authcode.php
Created December 26, 2012 07:34
php:authcode
<?php
function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
$ckey_length = 4;
$key = md5($key);
$keya = md5(substr($key, 0, 16));
$keyb = md5(substr($key, 16, 16));
$keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : '';
@GeHou
GeHou / clearbom.php
Last active December 10, 2015 04:08
php:clearBom
<?php
$auto = 1;
checkdir('D:\path\path');
function checkdir($basedir) {
if ($dh = opendir($basedir)) {
while (($file = readdir($dh)) !== false) {
if($file{0} == '.') {
continue;
}