Skip to content

Instantly share code, notes, and snippets.

Avatar

戴均民 taichunmin

View GitHub Profile
@taichunmin
taichunmin / npo_tw_crawler.php
Created Mar 21, 2014
A web crawler for npo.org.tw
View npo_tw_crawler.php
<?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];
@taichunmin
taichunmin / DNS list in SetDNS App.md
Last active Aug 29, 2015
DNS_list_in_SetDNS_App
View DNS list in SetDNS App.md
  • Google DNS

8.8.8.8 8.8.4.4

  • OpenDNS

208.67.222.222 208.67.220.220

View [laravel] about DB return data.md

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

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

之前在看 EloquentQuery Builder

以為他們的回傳是一樣的

所以再寫程式碼的時候

View DSpace api and jspui language update helper programs.py
'''
使用這個檔案來輔助處理 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")]
View checkUploadSize.php
<?php
/*
2012/05/15 taichunmin
用途:
計算出最大可用的檔案上傳大小。 ( 以設定檔中之 upload_max_filesize 和 post_max_size 來判定 )
此函式是參考 phpMyAdmin 寫出
參考:
phpMyAdmin - phpMyAdmin\libraries\Config.class.php (checkUploadSize)
View checkZHTW.php
<?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);
}
?>
View csvFixDbquotes.php
<?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++ )
View moneyFormat.php
<?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.=',';
View chinese numbers.php
<?php
/**
* 完成 阿拉伯數字 轉 中文數字
*
* @author taichunmin <taichunmin@gmail.com>
*/
function chineseNumber($num)
{
if(empty($num)) return '零';
$num = strrev(''.intval($num)); // 轉為字串並反轉
View mysqliConnect.php
<?php
/*
2012/09/03 taichunmin
2012/10/08 taichunmin add set_charset
*/
switch($_SERVER['HTTP_HOST'])
{
default:
$cfg['dbHost'] = 'localhost';
$cfg['dbUser'] = 'username';