mac工具集

brew

1
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

iterm2

1
2
https://iterm2.com/downloads/stable/iTerm2_v2_0.zip
运行iterm2之后按cmd+,调出设置界面,在'profile' -> "Terminal Type"改成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

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

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

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

Read More

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

php信号处理

pcntl

pcntl_signal

信号注册函数

pcntl_alarm

  • 指定秒数中断程序执行任务。
  • 每次执行只会有一个定时器生效,若之前计时器还没结束就定义新定时器,会替代之前定时器并返回之前定时器结束前秒数,若之前计时器已完成返回0
  • 参数设为0,会清空当前所有定时器,并不发起调用
  • 定时器会中断系统,即便是sleep执行中

Read More

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

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

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

Read More

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

php银行卡校验

前言
银行金卡,维萨和万事达、银联品牌,如果是贷记卡或准贷记卡,一定为16位卡号。而借记卡可以16-19位不等。
美国运通卡则不论金卡或是白金卡、普通卡,都是15位卡号。
16-19 位卡号校验位采用 Luhm 校验方法计算

Read More

MySQL — pulling gender from OAuth JSON with LOCATE and MID

记一次mysql优化操作

I needed user source and gender for reporting. Gender lived in third-party OAuth JSON in user_info. I did not want to parse it in PHP, so I pushed the work into MySQL. Tell me if you have a cleaner approach.

Setup (simplified)

Schema

OAuth bindings for Weibo, QQ, and WeChat; profile blob in user_info.

  • user_platform
    • weibo_id, qq_id, weixin_id, user_info, uid, user_platform_id

Gender encodings

  • Weibo gender: m / f / n
  • QQ gender: localized male/female labels in the payload (not ASCII m/f)
  • WeChat sex: 1 / 2

Constraints

  • On the order of a million rows — queries had to stay practical on production hardware.

Read More