Skip to content

Instantly share code, notes, and snippets.

@yusureabc
yusureabc / urlsafeB64.php
Last active August 7, 2023 09:36
URL-safe Base64
<?php
/**
* Decode a string with URL-safe Base64.
*
* @param string $input A Base64 encoded string
*
* @return string A decoded string
*/
function urlsafeB64Decode($input)
@yusureabc
yusureabc / build_index.php
Created January 5, 2018 07:22
首页静态化脚本
<?php
/**
* 首页静态化脚本
* Author: Yusure
* Blog: yusure.cn
*/
ini_set( 'date.timezone', 'PRC' );
/* 缓存过期时间 单位:秒 */
$expire = 86400;
@yusureabc
yusureabc / sources.list
Last active February 12, 2021 09:24
ubuntu 16.04换阿里云源
cd /etc/apt/
cp sources.list sources.list.bak
# 替换以下文件 #
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
##测试版源
@yusureabc
yusureabc / cron.sh
Last active May 7, 2020 06:06
crontab 秒级实现
#!/bin/bash
step=2 #间隔的秒数,不能大于60
for (( i = 0; i < 60; i=(i+step) )); do
/usr/bin/curl 'http:/xxx.com/api/hello'
sleep $step
done
exit 0
@yusureabc
yusureabc / XmlToArr
Created December 30, 2019 08:16
php XML Array 互转
function ArrToXml($arr)
{
if(!is_array($arr) || count($arr) == 0) return '';
$xml = "<xml>";
foreach ($arr as $key=>$val)
{
if (is_numeric($val)){
$xml.="<".$key.">".$val."</".$key.">";
}else{
if ($remote_addr !~ ^(100.110.15.16|100.110.15.17|100.110.15.18|127.0.0.1)) {
return 403;
}
@yusureabc
yusureabc / getIp.php
Created March 21, 2018 06:47
获取客户端 IP( 适用于 Docker 环境 )
<?php
/**
* 获取客户端 IP
* @author Sure Yu http://yusure.cn
* @date 2018-03-21
* @param [param]
* @return [type] [description]
*/
function getIP()
{
@yusureabc
yusureabc / CommandLine.java
Created July 31, 2018 14:23
打印所有的 java 命令行参数
/* $ javac CommandLine.java
$ java CommandLine this is a command line 200 -100 */
public class CommandLine
{
public static void main(String[] args)
{
int len = args.length;
for ( int i = 0; i < len; i++ )
{
@yusureabc
yusureabc / DiffDemo.java
Created July 31, 2018 02:25
测试java代码运行时间
import java.util.*;
public class DiffDemo
{
public static void main(String[] args)
{
try
{
long start = System.currentTimeMillis();
@yusureabc
yusureabc / cmd.reg
Created July 27, 2018 05:59
win10下右键菜单添加“打开cmd”
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\background\shell\cmd_here]
@="在此处打开命令行"
"Icon"="cmd.exe"