Skip to content

Instantly share code, notes, and snippets.

@kejyun
kejyun / git_prompt_bash_profile.sh
Created November 30, 2012 07:53
git prompt命令列特殊顏色及分支顯示設定
# 取得git branch名稱
function git_branch {
# 取得git branch,若此資料夾沒有git brangh,則將錯誤訊息丟至回收桶,回傳空值
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
# 若有取得git branch,則將取得的名稱「ref/heads/branchname」,並將前面的前贅詞去除,只保留branch名稱
echo "("${ref#refs/heads/}") ";
}
# 設定prompt名稱為 [資料夾路徑 現在時間] (branch)
# \e[1;32m:綠色
# \e[1;35m:紫色
@kejyun
kejyun / git_post_receive_config.sh
Created December 3, 2012 03:47
git_post_receive_config
[core]
repositoryformatversion = 0
filemode = true
bare = false
worktree=/var/www
[receive]
denycurrentbranch = ignore
@kejyun
kejyun / google_api_v3_get_contact.php
Created December 13, 2012 10:56
在PHP使用Google API(V3)取得使用者的Gmail通訊錄清單
<?php
function getEmailList($xml = '' , $access_token = '' , &$contact_list = array()) {
if (empty($xml)) {
return false;
}
$doc = new DOMDocument;
$doc->loadXML($xml);
$xpath = new DOMXPath($doc);
$contacts = $xpath->query("//gd:email");
// 撈取email跟姓名
@kejyun
kejyun / base_facebook_ssl.php
Created December 13, 2012 15:26
Facebook PHP SDK SSL Exception
<?php
//before
if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT
self::errorLog('Invalid or no certificate authority found, '.
'using bundled information');
curl_setopt($ch, CURLOPT_CAINFO,
dirname(__FILE__) . '/fb_ca_chain_bundle.crt');
$result = curl_exec($ch);
}
@kejyun
kejyun / RegCheck.js
Created December 17, 2012 14:53
JavaScript正規表示式資料檢測
var RegCheck = {
/**
* 正規表示式
*/
_reg:{
// Email正規表示式
email: /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/,
// 非「英文大小寫」和「數字」出現過一次
not_en_digital_least1: /[^a-zA-Z0-9]+/,
// 「英文大小寫」和「數字」各出現過一次(a1,b2...)
@kejyun
kejyun / sublime_nodejs_build_system.json
Created December 18, 2012 04:53
sublime nodejs build system
{
"cmd": ["C:/Program Files/nodejs/node.exe", "-p", "$file"]
}
@kejyun
kejyun / comment.sql
Created December 20, 2012 09:49
在MySQL使用Explain做SQL SELECT語法效能測試
-- 建立資料表
-- 留言
CREATE TABLE IF NOT EXISTS `comment` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '編號',
`content` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT '留言',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
-- 使用者
@kejyun
kejyun / phpCodeZip.php
Created January 3, 2013 15:20
php code compiler
<?php
/**
* @author:SANKAI
* @license:MIT & GPL
**/
class PhpCodeZip{
//欲進行壓縮加密的來源資料夾
var $sourceDir = '.';
//進行壓縮加密的存放的資料夾
var $targetDir = 'tmp';
@kejyun
kejyun / compiler.php
Last active December 10, 2015 13:59
using phpCodeZip.php
<?php
//載入函式
include_once('phpCodeZip.php');
//建立加密物件
/**
* example :
* $encryption = new PhpCodeZip('test','test_compiler');
* 請直接指定與compiler.php同目錄的資料夾名稱,不要使用「./test」或「./test_compiler」的資料夾名稱,導致程式出錯
*/
$encryption = new PhpCodeZip('sourceDir','targetDir');
@kejyun
kejyun / clearfix.css
Last active December 11, 2015 11:18
clearfix css
/*
<div class="parent_group">
<div class="float-left"> </div>
<p> ABC123 </p>
</div>
*/
.parent_group:before, .parent_group:after {
content: "";
display: block;
}