Skip to content

Instantly share code, notes, and snippets.

View taichunmin's full-sized avatar

戴均民 taichunmin

View GitHub Profile
@taichunmin
taichunmin / DNS list in SetDNS App.md
Last active August 29, 2015 13:57
DNS_list_in_SetDNS_App
  • Google DNS

8.8.8.8 8.8.4.4

  • OpenDNS

208.67.222.222 208.67.220.220

@taichunmin
taichunmin / npo_tw_crawler.php
Created March 21, 2014 08:34
A web crawler for npo.org.tw
<?php
set_time_limit(0);
$fh = fopen('list.txt','w');
if(!$fh)
exit("write file error!");
$firstPage = file_get_contents("http://www.npo.org.tw/npolist_list.asp?nowpage=1&npost=&keyword2=");
preg_match('/nowpage=(\d+)[^"]*">最末頁/', $firstPage, $match);
$pageCount = $match[1];

有關 Laravel 的 Query Build 的資料回傳型態疑問

一直覺的 laravel 的文件寫的不夠詳細

之前在看 EloquentQuery Builder

以為他們的回傳是一樣的

所以再寫程式碼的時候

'''
使用這個檔案來輔助處理 DSpace 的 api, jspui 中文語系檔的更新動作
'''
msg = {}
keys = []
with open("en.txt") as enfh:
for line in enfh:
tmp = [i.strip() for i in line.strip().split("\t")]
<?php
/**
* 完成 阿拉伯數字 轉 中文數字
*
* @author taichunmin <taichunmin@gmail.com>
*/
function chineseNumber($num)
{
if(empty($num)) return '零';
$num = strrev(''.intval($num)); // 轉為字串並反轉
<?php
/*
Example:
$arr = array(
'a' => '123',
'b' => '456',
);
$csv = iconv('UTF-8','CP950//IGNORE',tai_array2csv($arr));
參考: https://gist.github.com/3422591
<?php
/*
2012/05/15 taichunmin
用途:
計算出最大可用的檔案上傳大小。 ( 以設定檔中之 upload_max_filesize 和 post_max_size 來判定 )
此函式是參考 phpMyAdmin 寫出
參考:
phpMyAdmin - phpMyAdmin\libraries\Config.class.php (checkUploadSize)
<?php
// function tai_checkZHTW($str)
// {
// return preg_match('/(\xe2[\xba-\xbf][\x80-\xbf]|[\xe3-\xe9][\x80-\xbf]{2})/',$str);
// }
public function is_Han( $str )
{
return preg_match("/\p{Han}+/u", $str);
}
?>
<?php
function tai_csvFixDbquotes( $csv, $delimiter = ',', $enclosure = '"' )
{
$res = '';
if( $csv[ strlen($csv)-1 ] == "\r" )
$csv = substr($csv,0,-1);
$inDbquotes = false;
if( strlen($csv)==0 || $csv[0] != $enclosure )
$res .= $enclosure;
for( $i=0; $i<strlen($csv); $i++ )
<?php
function tai_moneyFormat($money)
{
$res = '';
$money = ''.$money;
for( $i=strlen($money)-1,$j=0; $i>=0; $i--,$j++)
{
$res .= $money[$i];
if($j%3==2 && $i>0) $res.=',';