Skip to content

Instantly share code, notes, and snippets.

@jshensh
jshensh / palindrome.php
Created Aug 1, 2021
Find idcard number
View palindrome.php
<?php
$areaCodeList = ['110101', '110102', '110105', '110106', '110107', '110108', '110109', '110111', '110112', '110113', '110114', '110115', '110116', '110117', '110118', '110119', '120101', '120102', '120103', '120104', '120105', '120106', '120110', '120111', '120112', '120113', '120114', '120115', '120116', '120117', '120118', '120119', '130102', '130104', '130105', '130107', '130108', '130109', '130110', '130111', '130121', '130123', '130125', '130126', '130127', '130128', '130129', '130130', '130131', '130132', '130133', '130181', '130183', '130184', '130202', '130203', '130204', '130205', '130207', '130208', '130209', '130224', '130225', '130227', '130229', '130281', '130283', '130284', '130302', '130303', '130304', '130306', '130321', '130322', '130324', '130402', '130403', '130404', '130406', '130407', '130408', '130423', '130424', '130425', '130426', '130427', '130430', '130431', '130432', '130433', '130434', '130435', '130481', '130502', '130503', '130505', '130506', '130522', '130523', '130524', '
@jshensh
jshensh / multiCurl.php
Created Jun 2, 2021
Multi Curl Example
View multiCurl.php
<?php
// composer require jshensh/php-curl-class
require_once('./vendor/autoload.php');
use CustomCurl\Client;
var_dump(microtime(true));
$pool = [];
@jshensh
jshensh / output
Created May 9, 2021
curl_multi_exec test
View output
root@debian:~/php-curl-class# php test.php
Start: 1620584188.6943
curl_multi_exec: 1620584188.6959
sleep: 1620584191.6963
test1 received data at: 1620584193.697
test3 received data at: 1620584193.6971
test4 received data at: 1620584193.6979
test2 received data at: 1620584193.6989
test5 received data at: 1620584198.6994
test6 received data at: 1620584198.6994
@jshensh
jshensh / downloadCertificate.php
Created Mar 11, 2021
PHP 签发客户端证书
View downloadCertificate.php
<?php
$dn = array(
"countryName" => "CN",
"stateOrProvinceName" => "Shanghai",
"localityName" => "Shanghai",
"organizationName" => "O",
"organizationalUnitName" => "OU",
"commonName" => "Guest",
"emailAddress" => "guest@example.com"
);
View ApiListController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class ApiListController extends Controller
@jshensh
jshensh / ss v2ray-plugin.md
Created Jun 27, 2020 — forked from shuanghua/ss-libev v2ray-plugin.md
ss-libev + v2ray-plugin + tls + CentOS-7
View ss v2ray-plugin.md

v2ray-plugin CentOS-7

ss v2ray-plugin centos-7

购买域名 / 或申请免费域名

配置 cloudflare

  1. cloudflare DNS-> 添加一条 A 记录;name=域名,value=vpsIP, ttl=automatic, status=onlyDns
@jshensh
jshensh / create_ca_cert.sh
Last active Feb 28, 2022
OpenSSL 双向认证配置脚本
View create_ca_cert.sh
#!/bin/bash -e
# 创建CA根证书
# 非交互式方式创建以下内容:
# 国家名(2个字母的代号)
C=CN
#
ST=Shanghai
#
L=Shanghai
@jshensh
jshensh / lnmp
Last active Jun 6, 2020
适用于 ssl 双向认证的 /usr/bin/lnmp
View lnmp
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
# Check if user is root
if [ $(id -u) != "0" ]; then
echo "Error: You must be root to run this script!"
exit 1
fi
View mountdrivers.sh
#sudo nano /etc/init.d/mountdrivers.sh
if [[ ! -z `mount | grep "on /media/TimeMachine type hfsplus (ro,"` ]]
then
echo "Reparando disco /media/TimeMachine em /dev/sda1"
sudo umount /dev/sda1
sudo fsck.hfsplus /dev/sda1
sudo mount -a
echo `mount | grep "on /media/TimeMachine type hfsplus (rw,"`
else
echo "Drive /media/TimeMachine montado corretamente"
@jshensh
jshensh / 断点续传.php
Last active Aug 3, 2017 — forked from HikoQiu/断点续传.php
PHP断点续传
View 断点续传.php
// 下载
<?php
$file = './Penguins.jpg';
$file_display_name = basename($file);
$fsize = @filesize($file);
if (!empty($fsize)) {
$start = null;
$end = $fsize - 1;
if (isset($_SERVER['HTTP_RANGE']) && $_SERVER['HTTP_RANGE'] !== "" && preg_match("/^bytes=([0-9]+)-([0-9]*)$/i", $_SERVER['HTTP_RANGE'], $match) && $match[1] < $fsize && $match[2] < $fsize) {
$start = $match[1];