Archive for the ‘Copy_N_Paste’ Category.

linux mount windows share directory / cifs / samba

在 /etc/fstab 加一行:

//192.168.100.1/ruten /rutenlog cifs user,rw,suid,username=XXX,password=YYY 0 0

Protected: emerge 不見的救法

This post is password protected. To view it please enter your password below:


INTEL vs Transcend SSD little PK (LAB )

J神對於 SSD 的讀取速度特別著迷, 於是重金採購了兩款 performance 都不錯的 SSD 來 lab 一下, 以下就這次的 Result :

Jason Chen: 早上再做一次二顆 SSD 的 Xbench Disk Test , 這次是 Intel 勝出

Transcend 2.5" 32G SSD SLC
Disk Test 73.82
 Sequential 84.27
  Uncached Write 104.16 63.95 MB/sec [4K blocks]
  Uncached Write 83.54 47.26 MB/sec [256K blocks]
  Uncached Read  48.92 14.32 MB/sec [4K blocks]
  Uncached Read  183.43 92.19 MB/sec [256K blocks]
 Random 65.67
  Uncached Write 20.31 2.15 MB/sec [4K blocks]
  Uncached Write 107.89 34.54 MB/sec [256K blocks]
  Uncached Read  1982.02 14.05 MB/sec [4K blocks]
  Uncached Read  523.91 97.21 MB/sec [256K blocks]

Intel X25-V 40G SSD MLC
Disk Test 150.38
 Sequential 97.48
  Uncached Write 72.91 44.76 MB/sec [4K blocks]
  Uncached Write 72.35 40.94 MB/sec [256K blocks]
  Uncached Read  105.10 30.76 MB/sec [4K blocks]
  Uncached Read  251.19 126.25 MB/sec [256K blocks]
 Random 328.80
  Uncached Write 389.34 41.22 MB/sec [4K blocks]
  Uncached Write 132.67 42.47 MB/sec [256K blocks]
  Uncached Read  2099.11 14.88 MB/sec [4K blocks]
  Uncached Read  631.72 117.22 MB/sec [256K blocks]

 

R0015118 R0015122

Protected: Web Design Blog, Tutorials and Inspiration

This post is password protected. To view it please enter your password below:


[設定/memo] PL/SQL Developer , plsql 免設 tnsname 檔的方法

在 Database 那格用這種格式: IP_ADDRESS/SERVICE_NAME

擷取PLSQL

Protected: [sample code] preg_match , regular expression match ,

This post is password protected. To view it please enter your password below:


[php] inline string vs 兜字串的寫法 速度比較 / 測試 sample code

function timeFunc($function, $runs) {
  $times = array();

  for ($i = 0; $i < $runs; $i++) {
    $time = microtime();
    call_user_func($function);
    $times[$i] = microtime() - $time;
  }
  return array_sum($times) / $runs;
}

function Method1() {
  $foo = 'some words';
  for ($i = 0; $i < 10000; $i++)
    $t = "these are $foo";
}

function Method2() {
  $foo = 'some words';
  for ($i = 0; $i < 10000; $i++)
    $t = "these are {$foo}";
}

function Method3() {
  $foo = 'some words';
  for ($i = 0; $i < 10000; $i++)
    $t = sprintf("these are %s", $foo);
}
function Method4() {
  $foo = 'some words';
  for ($i = 0; $i < 10000; $i++)
    $t = "these are " . $foo;
}

function Method5() {
  $foo = 'some words';
  for ($i = 0; $i < 10000; $i++)
    $t = 'these are ' . $foo;
}

print timeFunc('Method1', 10) . "\n";
print timeFunc('Method2', 10) . "\n";
print timeFunc('Method3', 10) . "\n";
print timeFunc('Method4', 10) . "\n";
print timeFunc('Method5', 10) . "\n";

RESULT:

0.0023114

0.002422

0.0072015

0.001946

0.0017625

但是這是 loop 10萬次才有一點點的差距.

結論是 method5(單 quote + concate string) 速度較佳! method3 (sprintf) 最慘!

inline 寫法有兩種, 這兩種都差不多, 所以就 codeing 時的手順上, 以 $foo 這種是比較好寫這也是多數人的寫法 , {$foo} 這種比較好閱讀.

若是在需求上需要加上換行的話, 在一個 strings 中用 inline 寫法把 \n 放在 quote 中, 這種速度卻又比 concate string 寫法來得快.

ps: 速度比較這種題目很多人都會陷入某種迷失, 每個人的環境/需求都不盡相同, 並不是最快的就是適合自己的.

不錯的配色網站 – design your own palette / pattern / color

常下的查網路狀態的指令 Analyzing network traffic

tcpdump -nn -i eth1 -c 10000 port 9000 | awk '{print $5}' | cut -d. -f1-4 | sort | uniq -c | sort -n

tcpdump -nn -e -i eth1 port 9000

arping -I eth1 172.25.1.131

CodeIgniter MVC CRUD + memcache = Secret Message http://msg.monster.com.tw

這個 idea 是來自這個網站 : https://privnote.com/ , 簡單的說它是一個經由 https 保護傳送內容的網路服務 , user 用這個服務把臨時要給朋友的機密/私人資料譬如 password / URL 之類的 data 存放在這網站上, 然後此系統會給 user 一個唯一網址, 再把這網址給朋友, 開啟這個唯一網址後, 就可以看到這個訊息, 系統同時會把這訊息從系統中刪除… 哈哈! 看懂了嗎?

我的改進是用 memcache 的 expire 機制, 設定 10分鐘後, 若 user 沒讀過此訊息, 訊息會 ‘自動’ 銷毀… 我的站若再去申請 ssl 加密的話就跟那個站功能是類似的了.

codeigniter 的 MVC 架構, 讓我很快的把這個 idea implement 出來了 , 基本上就是一個簡單版的 CRUD

我的 Secret Message 服務長像非常的陽春 :P , 僅用簡單的 HTML , 若有空再加上 style 美化一下版面, 不過基本功能是有的了, 大家用看看, 有 idea 或意見請再告訴我.

目前 message 不提供 HTML / VBB , 但是有簡單的 skype 版表情符號 ( icon 正在慢慢搜集中 ) ….

Secret Message 網址是: http://msg.monster.com.tw/

 

dc34889242b1d25e1f4c4d477e85c96c

4185a388c19629704edc284514c6cfe5

CI 表情符號改寫例:

0fe1a40bfd47887c51ed60fc2af4a3a0

3a21610697fc7f7b5983a1358a9f7713d5617ad16b86596c9c44642a08193875

用 php code 產生 1×1 pixel 的 小黑點 sample code

這個可以用來做 tracking 輸出用

header("Content-Type: image/gif");
header("Content-Length: 49");
echo pack('H*',
  '47494638396101000100910000000000ffffffff'
 .'ffff00000021f90405140002002c000000000100'
 .'01000002025401003b'
);

[Great idea!] 10 Minute Mail / 十分鐘電郵

URL : http://www.10minutemail.com/10MinuteMail/

很多網站要申請加入會員都需要一個 email address , 這個十分鐘電郵就是可以用來作這件事, 收到會員的啟用連結後, 就可以跟這個 email 說再見了!

60f1ce7cabdd8ce41f573a9b25405a1b

Get MAC address using C

不過 , 這邊有指定 eth0 , 若 server 有很多 interface 的話就要注意一下了.

#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>

int main( int argc, char *argv[] )
{
	int s;
	struct ifreq buffer;

	s = socket(PF_INET, SOCK_DGRAM, 0);

	memset(&buffer, 0x00, sizeof(buffer));

	strcpy(buffer.ifr_name, "eth0");

	ioctl(s, SIOCGIFHWADDR, &buffer);

	close(s);

	for( s = 0; s < 6; s++ )
	{
		printf("%.2X ", (unsigned char)buffer.ifr_hwaddr.sa_data[s]);
	}

	printf("\n");

	return 0;
}

一些 memcache 的資料

板橋新埔捷運站

[好文推薦] A TUTORIAL ON POINTERS AND ARRAYS IN C

squid proxy server setting

改這個檔 /etc/squid/squid.conf

allow 內網可以透過 proxy

就放在那個 INSERT YOUR ….

acl officenet src 172.30.0.0/24
http_access allow officenet

Protected: [收藏好文] 網站背後技術與技巧

This post is password protected. To view it please enter your password below:


debian / ubuntu , APT HOWTO / Guide / 指令速查表

1. Searching for packages apt-cache
sudo apt-cache search package1

2. Getting more Information about a package apt-cache
sudo apt-cache show package1 package2 …

3. Installing a package apt-get install
sudo apt-get install package1 package2 …
sudo apt-get install package1 –reinstall

4. Removing packages apt-get remove
sudo apt-get remove package1 package2
complete remove:
sudo apt-get remove package1 package2 –purge

5. Update your package database apt-get update
sudo apt-get update

6. Upgrading your system apt-get [dist-]upgrade
sudo apt-get upgrade

The smart upgrade with:
sudo apt-get dist-upgrade

7. Resolving conflicts and Broken packages apt-get
sudo apt-get -f install

8. Checking for dependencies and reverse dependencies apt-cache
apt-cache depends package1 package2
apt-cache rdepends package1 package2

編程最佳的字型 consolas / notepad++ 及 winscp 設定 / Best programming fonts