Call a function with a dynamic argument list (apply + slice)

js如何动态调用不确定参数的函数

1
2
3
4
// Goal: invoke a function with a body + args without hard-coding arity.
var m = function (a, b, c) {
return a + b + c;
};

Read More

Share   |  Updated:

macOS dev toolbox — Homebrew, terminal, and daily utilities

mac工具集

Homebrew

1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

(Legacy one-liner from 2016 used the old install/master URL; use the official script above today.)

iTerm2

1
https://iterm2.com/downloads/stable/iTerm2_v2_0.zip

After launching iTerm2, press Cmd+, → Profiles → Terminal → set Terminal Type to xterm-new.

Read More

基于phpstorm和vagrant环境的xdebug远程调试

网页调试/本地调试

流程是啥

  • 开发环境安装xdebug,配置监听client端(安装phpstorm那端)
  • 配置phpstorm-debug,重点要用path-map,不然对于单一入口的网页调试找不到哦
  • 断点跟踪吧

详细网上资料很多,下边三个都可以用,我就不赘述了

phpstorm远程调试
Zero-configuration Web Application Debugging with Xdebug and PhpStorm
cannot-debug-with-phpstorm-vagrant-xdebug


远程cli调试

Read More

Share   |  Updated:

如何更新别人apple-id购买的应用

Mac的应用比如Xcode太大,一般不会自己下,别人airdrop给你,方便吧!
可是,升级时你就发现没有传给那个人的apple id密码你都没法升级了,而为了安全,除了appstore你别无选择

不过方法还是有的,为了自己不用蛋疼,记录在这

Read More

Share   |  Updated:

jQuery应用杂记

** 工作中常用的一些代码片段 **

全选

1
2
3
4
5
6
7
8
9
$("#ckAll").click(function() {
$("input[name='sub']").prop("checked", this.checked);
});
//全部checkbox选中后 全选框也选中

$("input[name='sub']").click(function() {
var $subs = $("input[name='sub']");
$("#ckAll").prop("checked" , $subs.length == $subs.filter(":checked").length ? true :false);
});

Read More

Share   |  Updated:

PHP process control — signals, fork, wait (pcntl)

php信号处理

pcntl

pcntl_signal

Register a handler for a signal.

pcntl_alarm

  • Fire SIGALRM after N seconds.
  • Only one alarm timer is active; setting a new one replaces the previous and returns seconds left (or 0 if it already fired).
  • pcntl_alarm(0) clears pending alarms.
  • Alarms can interrupt sleeping calls.

Read More

gearman分布式任务服务器学习记录

以下是强大的gearman学习及安装记录,代码demo下边的来自网络的附录有很多可以参考。

Gearman 是一套用来把程式需求委派给机器,提供通用的程序框架来将任务分发在机器运算。
它同时具备并行工作的能力、负载均衡处理的能力,以及在不同程序语言之间沟通的能力。

Read More

Share   |  Updated:

iframe实现的无刷tab页

为了实现tab页无刷,又不想全部用ajax动态生成,同时需要在tab页内有相关操作,简单的话就是用iframe了

先来看个demo: iframe-tabs

参考自jquery-tabs-iframes

这个demo实现了基本的需求,使用中发现还有两点问题

  1. iframe 高度自适应
  2. 如果在iframe页内 history.back(-1) 历史返回时要记录之前选择的tab页
  3. 如果tab页要求实时性,还需要每次点击都请求页面,同时也可以只加载一个iframe并替换其src来复用,而不必每个tab都加载一个iframe

Read More

Share   |  Updated:

Bank card checksum in PHP (Luhn algorithm)

php银行卡校验

Context: UnionPay / Visa / Mastercard credit and quasi-credit cards are often 16 digits; debit cards may be 16–19. Amex is commonly 15. For 16–19 digit numbers the check digit often uses the Luhn (mod 10) algorithm.

Read More

Share   |  Updated: