Skip to content

Instantly share code, notes, and snippets.

@fasthold
fasthold / gist:6438598
Created September 4, 2013 15:26
Some php.ini settings snippet for Puphpet.com
display_errors = On,
error_reporting = 2047,
short_open_tag = Off,
memory_limit = 512M,
allow_url_fopen = On,
post_max_size = 1024M,
max_file_uploads = 1000,
upload_max_filesize = 1024M,
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
@fasthold
fasthold / install-ffmpeg.sh
Last active December 20, 2015 05:19
Install ffmpeg and useful encoders (h264,mp3...)
# From http://my.oschina.net/michaelyuanyuan/blog/68616
# Set a download dir
download_dir=~/downloads
# Install H264 encoder
cd $download_dir
git clone git://git.videolan.org/x264.git x264
cd x264
@fasthold
fasthold / install-14.04.sh
Last active April 15, 2021 04:52
装好ubuntu server后的那些事
# 请注意修改部分参数,如安装mysql-server时,设置 MySQL root 密码,以便自动安装
# System related
sudo apt-get update
sudo apt-get -y install build-essential ssh curl software-properties-common python-software-properties python g++ make
# Editor
sudo apt-get -y install vim
# VCS
@fasthold
fasthold / composer.json
Last active December 19, 2015 13:59
The useful "wheel"
{
"require": {
"silex/silex": "1.1.*@dev",
"respect/validation": "dev-develop",
"symfony/browser-kit": "2.4",
"monolog/monolog": "1.6.*@dev",
"cartalyst/sentry": "2.0.*",
"illuminate/database": "4.1.*",
"ircmaxell/password-compat": "*",
"gabordemooij/redbean": "dev-master"
@fasthold
fasthold / preload.js
Created May 12, 2013 10:01
Preload images so simple.
// From http://stackoverflow.com/questions/476679/preloading-images-with-jquery
function preload(arrayOfImages) {
$(arrayOfImages).each(function(){
$('<img/>')[0].src = this;
// Alternatively you could use:
// (new Image()).src = this;
});
}
<?php
/**
* 加密 hash,生成发送给用户的 hash 字符串
*
* @param array $hash_data
* @param string $hash_key
* @return string
*/
function encode_hash($hash_data, $hash_key = false)
@fasthold
fasthold / gist:4490336
Last active December 10, 2015 20:48
装好ubuntu desktop后的那些事
sudo apt-get update
sudo apt-get install build-essential vim gvim git gitk
mkdir ~/temp
mkdir ~/app
# 安装 chrome
sudo apt-get install chromium-browser
# 安装 sublime text
cd ~/temp
@fasthold
fasthold / gist:1446080
Created December 8, 2011 04:09
有效的中文型用户名检测
function check_username($username) {
$guestexp = ‘\xA1\xA1|\xAC\xA3|^Guest|^\xD3\xCE\xBF\xCD|\xB9\x43\xAB\xC8′;
$len = $this->dstrlen($username);
if($len > 15 || $len < 3 || preg_match(“/\s+|^c:\\con\\con|[%,\*\"\s\<\>\&]|$guestexp/is”, $username)) {
return FALSE;
} else {
return TRUE;
}
}
@fasthold
fasthold / gist:1357342
Created November 11, 2011 06:22
利用Imagick将pdf转为图片
<?php
/**
* PDF2PNG
* @param $pdf 待处理的PDF文件
* @param $path 待保存的图片路径
* @param $page 待导出的页面 -1为全部 0为第一页 1为第二页
* @return 保存好的图片路径和文件名
*/
function pdf2png($pdf,$path,$page=-1)
{