Skip to content

Instantly share code, notes, and snippets.

View crazcdll's full-sized avatar

crazcdll crazcdll

  • 美团
  • Beijing
View GitHub Profile
@crazcdll
crazcdll / ls.js
Created January 19, 2021 06:42
计算 localStorage 所占空间
// 第一种计算方法
var _lsTotal = 0, // 总长度
_xLen, // 每一项的长度
_x; // 每一项的名称
var _ls = [] // 用来存储每一项 localStorage
for (_x in localStorage) {
if (!localStorage.hasOwnProperty(_x)) {
continue;
}
_xLen = ((localStorage[_x].length + _x.length) * 2); // 每一项的长度包括 名字的长度+内容的长度,这里都按照一个字符占2个字节(2B)来简化计算
@crazcdll
crazcdll / map.ts
Created December 17, 2018 17:29
TypeScript Hacks
var arr : { [key:string]:number; } = {};
git config --global core.autocrlf input
@crazcdll
crazcdll / quickSort.js
Created May 10, 2018 06:01
quickSort.js
function qSort(compare) {
var swap = (p1, p2) => {
var tmp = this[p1];
this[p1] = this[p2];
this[p2] = tmp;
}
var sortRange = (start, end) => {
var midValue = this[start];
var p1 = start, p2 = end - 1;
while(p1 < p2) {
@crazcdll
crazcdll / react.md
Created February 8, 2018 09:44
React 学习路线 #react #学习路线
@crazcdll
crazcdll / list.array
Created January 31, 2018 04:27 — forked from easychen/list.array
php函数使用频次列表(GitHub统计)
Array
(
[define] => 1B
[file] => 1B
[list] => 1B
[copy] => 1B
[end] => 1B
[array] => 827M
[time] => 810M
[max] => 751M
@crazcdll
crazcdll / multiple-php-versions-on-ubuntu-16.04.md
Created November 27, 2017 06:27 — forked from aaronbloomfield/multiple-php-versions-on-ubuntu-16.04.md
Running multiple PHP versions on Apache2 and Ubuntu 16.04

Setting up multiple apache2 instances on Ubuntu 16.04

PHP handling on apache is done via modules of one sort or another, and running multiple version is problematic on a single instance. The solution is to run two instances of apache on the same machine. This allows one instance to run PHP 7 (the default on 16.04), and another can run PHP 5. Since normal http/https is on ports 80 and 443, the second instance will run on ports 81 and 444. Since it is running on the same machine, all file system and database access is the exact same.

All the commands herein have to be run as root, or with sudo prefixed to the command.

  1. Read /usr/share/doc/apache2/README.multiple-instances

  2. Run sh ./setup-instance php5 from /usr/share/doc/apache2/examples, where php5 is the suffix for the second site; all commands for the second site will have that suffix. This will keep all of the same configuration for all sites on the new instance, including SSL certif

@crazcdll
crazcdll / pip.sh
Last active January 16, 2018 09:48
pip 换源
vi ~/.pip/pip.conf
[global]
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com
[global]
index-url = http://mirrors.aliyun.com/pypi/simple
trusted-host = mirrors.aliyun.com
<?php
/**
* 设置预约安排信息
* @param Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function setAppointmentPlan(Request $request)
{
// 月份需要写算法判断,是否连续,分析月末的天数
// 先只把 begin,end 两个日期加进去