localStorage 存储对象
存:
var obj = {"name":"hello","age":"16"}
localStorage.setItem("userInfo",JSON.stringify(obj));
取:
var user = JSON.parse(localStorage.getItem("userInfo"));
删:
localStorage.removeItem("userInfo");
清:
localStorage.clear();
存:
var obj = {"name":"hello","age":"16"}
localStorage.setItem("userInfo",JSON.stringify(obj));
取:
var user = JSON.parse(localStorage.getItem("userInfo"));
删:
localStorage.removeItem("userInfo");
清:
localStorage.clear();
@echo off
title 更改文件名大写为小写
::本代码原思路由yyykkkyyyy提供,依梦琴瑶修改并添加子目录的文件处理
::https://zhidao.baidu.com/question/368123497755817644.html
::再次感谢yyykkkyyyy,我这里就借花献佛了。
set dir=%~dp0&call:cdto
for /f "delims=" %%i in ('dir/s/b/ad') do set dir=%%i&call:cdto
pause
exit/b
:cdto
cd /d %dir%
for /f "delims=" %%i in ('dir/b/a-d/l') do ren "%%i" "%%i"
通过用户ID生成唯一邀请码,可以省去入库查询等操作。
加密:
function createCode($user_id) {
static $source_string = 'E5FCDG3HQA4B1NOPIJ2RSTUV67MWX89KLYZ';
$num = $user_id;
$code = '';
while ( $num > 0) {
$mod = $num % 35;
$num = ($num - $mod) / 35;
$code = $source_string[$mod].$code;
}
if(empty($code[3]))
$code = str_pad($code,4,'0',STR_PAD_LEFT);
return $code;
}
解密:
function decode($code) {
static $source_string = 'E5FCDG3HQA4B1NOPIJ2RSTUV67MWX89KLYZ';
if (strrpos($code, '0') !== false)
$code = substr($code, strrpos($code, '0')+1);
$len = strlen($code);
$code = strrev($code);
$num = 0;
for ($i=0; $i < $len; $i++) {
$num += strpos($source_string, $code[$i]) * pow(35, $i);
}
return $num;
}
APCu 前身是 APC,一个免费开源且应用很广的字节码和对象缓存软件。APC分为系统缓存和用户缓存:
1、系统缓存是指PHP执行时增加缓存,减少PHP文件的反复检查和编译,从而达到系统加速的目的。
2、用户缓存是指,PHP代码中将数据写入缓存,是用户写入的数据,通过key和value的键值方式插入和读取。这种数据叫用户缓存。
PHP5.5以后,opcache代替APC做为PHP加速的位置,也就是代替其系统缓存的位置。并将用户缓存功能独立出来,开启新的组件,叫APCu。
其他可选缓存方案:redis/memcache:如果要做分布式存储可以使用,否则不推荐使用,因为redis/memcache需要tcp通信,即使本地也需要unix domain socket通信,其效率远不如共享内存的apcu。
<?php
// 制定允许其他域名访问
header('Access-Control-Allow-Origin:*');
// 响应类型
header('Access-Control-Allow-Methods:*');
//请求头
header('Access-Control-Allow-Headers:*');
// 响应头设置
header('Access-Control-Allow-Credentials:false');
//节假日 需要手动维护配置文件或者放入db中
$holiday=['2019-01-01', '2019-01-05', '2019-01-06', '2019-01-12', '2019-01-13', '2019-01-19', '2019-01-20', '2019-01-26', '2019-01-27', '2019-02-04', '2019-02-05', '2019-02-06', '2019-02-07', '2019-02-08', '2019-02-09', '2019-02-10', '2019-02-16', '2019-02-17', '2019-02-23', '2019-02-24', '2019-03-02', '2019-03-03', '2019-03-09', '2019-03-10', '2019-03-16', '2019-03-17', '2019-03-23', '2019-03-24', '2019-03-30', '2019-03-31', '2019-04-05', '2019-04-06', '2019-04-07', '2019-04-13', '2019-04-14', '2019-04-20', '2019-04-21', '2019-04-27', '2019-05-01', '2019-05-02', '2019-05-03', '2019-05-04', '2019-05-11', '2019-05-12', '2019-05-18', '2019-05-19', '2019-05-25', '2019-05-26', '2019-06-01', '2019-06-02', '2019-06-07', '2019-06-08', '2019-06-09', '2019-06-15', '2019-06-16', '2019-06-22', '2019-06-23', '2019-06-29', '2019-06-30', '2019-07-06', '2019-07-07', '2019-07-13', '2019-07-14', '2019-07-20', '2019-07-21', '2019-07-27', '2019-07-28', '2019-08-03', '2019-08-04', '2019-08-10', '2019-08-11', '2019-08-17', '2019-08-18', '2019-08-24', '2019-08-25', '2019-08-31', '2019-09-01', '2019-09-07', '2019-09-08', '2019-09-13', '2019-09-14', '2019-09-15', '2019-09-21', '2019-09-22', '2019-09-28', '2019-10-01', '2019-10-02', '2019-10-03', '2019-10-04', '2019-10-05', '2019-10-06', '2019-10-07', '2019-10-13', '2019-10-19', '2019-10-20', '2019-10-26', '2019-10-27', '2019-11-02', '2019-11-03', '2019-11-09', '2019-11-10', '2019-11-16', '2019-11-17', '2019-11-23', '2019-11-24', '2019-11-30', '2019-12-01', '2019-12-07', '2019-12-08', '2019-12-14', '2019-12-15', '2019-12-21', '2019-12-22', '2019-12-28', '2019-12-29'];
function afterWorkDay($start_timestamp='',$add_workday_num='',$holiday=[]){
//实际工作时间数组
$workday=array();
$i=0;
//判断实际工作时间数组的长度
while(count($workday)<intval($add_workday_num)){
$i++;
$onewdate=date('Y-m-d',($start_timestamp)+$i*(60*60*24));
//非节假日添加实际工作时间数组
if(!in_array($onewdate,$holiday)){
$workday[]=$onewdate;
}
}
return date('Y-m-d',($start_timestamp)+$i*(60*60*24));
}
$day = $_GET['day'];
$date = $_GET['date'];
$day = (int)$day - 1;
$start_time=strtotime($date);
//计算N个工作日后的时间 $N-1对应共N天
echo afterWorkDay($start_time,$day,$holiday);
<?php
// 过慢,暂不使用 http://api.goseek.cn/Tools/holiday?date=20201002
// 正常工作日对应结果为 0, 法定节假日对应结果为 1, 节假日调休补班对应的结果为 2,休息日对应结果为 3
// 使用:http://tool.bitefu.net/jiari/?d=
// 工作日对应结果为 0, 休息日对应结果为 1, 节假日对应的结果为 2
$arr=[];
$start=strtotime('20191028');
for ($i=0; $i < 100; $i++) {
$now = $start+86400*$i;
$day = date('Ymd', $now);
$res = https_request("http://tool.bitefu.net/jiari/?d=".$day);
if($res==1||$res==2){
file_put_contents('holiday.txt', $day.PHP_EOL, FILE_APPEND);
}
usleep(300);
}
function https_request($url, $data = null){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_TIMEOUT,6);
if (!empty($data)){
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
return $output;
}
判断字段是否存在值,如果不存在则写入本行中另一个字段值。update table_name set new_column= case when (new_column=0) then old_column else new_column end
即:如new_column不存在值则更新为old_column
对于首次提交时,会忽略.gitignore中对应的文件。如果已提交再次修改.gitignore则不会忽略,仍会追踪文件变化。
解决:git rm --cached folder/file
并修改.gitignore文件
另:git update-index --assume-unchanged
的真正用法是这样的: