Skip to content

Instantly share code, notes, and snippets.

@pulading1988
pulading1988 / new_gist_file.php
Created August 1, 2017 05:41
php获取当前时间前一个月bug
date('Ym', strtotime('-1 month', strtotime("first day of this month"))),
@pulading1988
pulading1988 / new_gist_file.mysql
Last active July 31, 2017 09:09
laravel查询参数分组
SELECT *
FROM `market_list`
WHERE `id` IN ('1', '2')
AND `status` = '1'
AND (`start_time` IS NULL
OR `start_time` <= '2017-07-31 17:05:57')
AND (`end_time` IS NULL
OR `end_time` >= '2017-07-31 17:05:57')
ORDER BY `priority` DESC
LIMIT 5
@pulading1988
pulading1988 / new_gist_file.mysql
Last active July 31, 2017 09:08
查找substr在字符串str的第一个出现的位置
mysql> SELECT LOCATE('bar', 'foobarbar');
+---------------------------------------------------------+
| LOCATE('bar', 'foobarbar') |
+---------------------------------------------------------+
| 4 |
+---------------------------------------------------------+
1 row in set (0.00 sec)
@pulading1988
pulading1988 / new_gist_file.php
Last active July 31, 2017 09:09
php二维数组排序
// 先按点赞数据排序,再按评论时间排序
$likeCounts = array();
$reviewTimes = array();
foreach ($commentList as $item) {
$likeCounts[] = $item['likeCount'];
$reviewTimes[] = $item['reviewTime'];
}
array_multisort($likeCounts, SORT_DESC, $reviewTimes, SORT_DESC, $commentList);
@pulading1988
pulading1988 / new_gist_file.js
Last active August 17, 2017 03:56
vue.js写的一个表单验证示例
var mobileRE = /^(((13[0-9]{1})|(14[57]{1})|(15[0-9]{1})|(17[678]{1})|(18[0-9]{1}))+\d{8})$/;
var passwordRE = /^[A-Za-z0-9]{6,20}$/;
var BASE_PATH = '${basePath}';
var j_captchaUrl = '${basePath}/jcaptcha'; // 获取验证码的后端地址
var app = new Vue({
el: '#app',
data: {
mobile: '',
j_captcha: '',