PHP 使用 ImageMagick 生成 Gif 缩略图

取第一帧

1
2
3
4
5
6
7
8
9
10
11
$file_in = './orig.gif';
$file_out = './thumb.gif';

$image = new Imagick($file_in);
foreach ($image as $frame)
{
$frame->writeImage($file_out);
break;
}
$image->clear();
$image->destroy();

Android 截图并保存到电脑

打开终端,cd 到任意一个指定的目录,执行下面的命令即可

Shell命令

1
2
3
adb shell "/system/bin/screencap -p /sdcard/screenshot_tmp.png"
adb pull /sdcard/screenshot_tmp.png ./screenshot.png
adb shell "rm -r /sdcard/screenshot_tmp.png"

PHP持久化Session

默认情况下,浏览器关闭,Session的生命期就会结束,编辑 php.ini,找到下面这行

session.cookie_lifetime = 0;

修改session.cookie_lifetime的值即可,单位是秒,0表示直到浏览器关闭

UTF-8 空白字符

用途:网页以及其他一些排版

「 」

括号里面的便是

Android 使用脚本打包

预备工作

1
2
3
4
5
6
7
8
sudo ln -s /Users/fang/Workspace/adt-bundle-mac-x86_64-20140321/sdk/platform-tools/adb /usr/bin/

vi ~/.bash_profile
# 编辑.bash_profile文件,加上下面两个路径
# /Users/fang/Workspace/adt-bundle-mac-x86_64-20140321/sdk/platform-tools
# /Users/fang/Workspace/adt-bundle-mac-x86_64-20140321/sdk/tools

export PATH=/Users/fang/Workspace/adt-bundle-mac-x86_64-20140321/sdk/platform-tools:/Users/fang/Workspace/adt-bundle-mac-x86_64-20140321/sdk/tools:$PATH

Mac 终端使用 keytool 签名时中文乱码的问题

终端-偏好设置-描述文件-高级-文本编码

暂时将文本编码改为「GB 2312」

PhpStorm-Mac 一些快捷键

Command + Option + F12 ---- 在Finder中显示
Command + L ---- 输入行号跳到某一行
Command + / ---- 行注释
Ctrl + Shift + / ---- 块注释
Command + Shift + C ---- 复制当前文件路径

BootStrap 的导航栏标签

多个文件引用同一个导航栏代码的情况下,希望当前页面所属的标签是active态,可以用下面的方案。

$('#navbar ul a').filter(function()
{
// 此处添加实际需要的规则
    return window.location.href.substr(0, window.location.href.lastIndexOf("/")) == this.href.substr(0, this.href.lastIndexOf("/"));

JavaScript 日期格式化

源码

// 对Date的扩展,将 Date 转化为指定格式的String 
// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符, 

Mac - JavaScriptCore

编辑 ~/.bash_profile ,添加

alias jsc='/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/jsc'

后续在终端执行jsc命令即可。