PIXNET Logo登入

Foxbrush

跳到主文

Where I Record Myself

部落格全站分類:財經政論

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 5月 25 週五 201216:39
  • [C/C++] #pragma 預處理指令


>
C-lanugage的可攜性是公認的, 可以跨平台執行.
所以各平台之間的compiler應該儘可能的符合可攜性的要求.
但
是為了提高執行效率, 符合各平台的機器特徵做一些特殊動作, 例如撰寫組合語言, 使用co-processor, 使用特殊記憶體配置,
使用特殊的compiler能力...等等會使用到#pragma 的語法以達到目的而又不影響沒有這些能力的平台或compile的編譯.
或
許你會認為用#ifdef也可以達到目的, 但是#ifdef的方式必須在command line指定一堆定義是很麻煩的,
而且一些特殊能力用#ifdef 也定義不出來. 況且使用你寫的source
code的人不見得了解該如何定義以符合他的使用平台或compiler的需求.
compiler看到#pragma時如果後面的定義是它不認得的, 它不會理會; 相反的看得懂得compiler就會去執行它.
如
果你是很專業的程式師, 而且考慮跨平台且讓別人可以用你的source code, 那麼很難用一個範例就可以搞懂, 因為它牽涉很複雜的一些規範,
你可以上www.gnu.org去看看他們的規定, GNU是一些熱心軟體發展的人士, 願意提供原始碼貢獻世界的人組成的團體,
依循他們的規範是比較正確的方向(很有學問的).
如果你只是用你現在的compiler時發現這個compiler有一些特殊功能可以提升你的效率, 只要照著做就對了, 沒有什麼大學問, 因為#pragma最有可能的用法就是啟動compiler的特殊能力而不會造成跨平台時一般能力的執行.
舉個例子說在Microsoft C(MSC)上寫:
#pragma asm 表示後面寫的是組合語言 (加速).
#pragma small 表示小記憶體模式 (DOS朝代memory很珍貴)
Keil C在8031平台時寫:
#pragma registerbank(0) 表示使用bank0 (別的CPU沒有這種東西)
#pragma code 表示const 資料放在ROM裡面 (節省RAM)
我舉與你不同的平台的compiler的例子就是要告訴你#pragma就是可攜性的環境下製造不可攜碼的無奈. 你的CPU也會有一些特殊功能或結構, 不用#pragma怎麼辦.
(繼續閱讀...)
文章標籤

Foxbrush 發表在 痞客邦 留言(0) 人氣(35)

  • 個人分類:Development in SW
▲top
  • 5月 22 週二 201220:41
  • [PHP] How to Send A Mail


使用Mail函式透過SMTP發信:
http://sofree.cc/php-smtp-mail/
 Mail函式講解:
http://www.php5.idv.tw/modules.php?mod=books&act=show&shid=2516 
(繼續閱讀...)
文章標籤

Foxbrush 發表在 痞客邦 留言(0) 人氣(2)

  • 個人分類:Development in SW
▲top
  • 5月 14 週一 201221:15
  • [JS] Convert the local time to another time zone with this JavaScript


http://www.techrepublic.com/article/convert-the-local-time-to-another-time-zone-with-this-javascript/6016329
(繼續閱讀...)
文章標籤

Foxbrush 發表在 痞客邦 留言(0) 人氣(1)

  • 個人分類:Development in SW
▲top
  • 5月 09 週三 201216:26
  • [PHP] Session Fixiation


What is session fixiation :
https://www.owasp.org/index.php/Session_fixation
Make session safe
http://www.talkphp.com/general/1077-understanding-life-session.html
(繼續閱讀...)
文章標籤

Foxbrush 發表在 痞客邦 留言(0) 人氣(2)

  • 個人分類:Development in SW
▲top
  • 5月 02 週三 201210:56
  • [CSS] Fighting the Space Between Inline Block Elements


Fighting the Space Between Inline Block Elements
Try the foolowing:
  li {
   display: inline-block;
   padding: 5px;
   background-color: red;
  }
    one
    two
    three
(繼續閱讀...)
文章標籤

Foxbrush 發表在 痞客邦 留言(0) 人氣(2)

  • 個人分類:Development in SW
▲top
  • 4月 27 週五 201216:05
  • [PHP] Parse Accept-Language to detect a user's language


The following code will parse $_SERVER['HTTP_ACCEPT_LANGUAGE'], 
en-ca,en;q=0.8,en-us;q=0.6,de-de;q=0.4,de;q=0.2,
into an array.
(繼續閱讀...)
文章標籤

Foxbrush 發表在 痞客邦 留言(0) 人氣(29)

  • 個人分類:Development in SW
▲top
  • 4月 12 週四 201217:20
  • [Web] Change image resolution per screen resolution


Change image resolution per screen resolution
(繼續閱讀...)
文章標籤

Foxbrush 發表在 痞客邦 留言(0) 人氣(1)

  • 個人分類:Development in SW
▲top
  • 4月 12 週四 201216:53
  • [PHP] Create reflection efftect on image


Create reflection efftect on image
I have written a function that takes an image as parameter and returns the same image with a reflection effect (often seen in WEB 2.0 sites). I have not performance-tested this with large image files, for thumbnails it works fine (requires PHP 4.3.2 or above, or PHP5).
function imagereflection($src_img) {
  $src_height = imagesy($src_img);
  $src_width = imagesx($src_img);
  $dest_height = $src_height + ($src_height / 2);
  $dest_width = $src_width;
 
  $reflected = imagecreatetruecolor($dest_width, $dest_height);
  imagealphablending($reflected, false);
  imagesavealpha($reflected, true);
 
  imagecopy($reflected, $src_img, 0, 0, 0, 0, $src_width, $src_height);
  $reflection_height = $src_height / 2;
  $alpha_step = 80 / $reflection_height;
  for ($y = 1; $y <= $reflection_height; $y++) {
    for ($x = 0; $x < $dest_width; $x++) {
  // copy pixel from x / $src_height - y to x / $src_height + y
  $rgba = imagecolorat($src_img, $x, $src_height - $y);
  $alpha = ($rgba & 0x7F000000) >> 24;
  $alpha =  max($alpha, 47 + ($y * $alpha_step));
  $rgba = imagecolorsforindex($src_img, $rgba);
  $rgba = imagecolorallocatealpha($reflected, $rgba['red'], $rgba['green'], $rgba['blue'], $alpha);
  imagesetpixel($reflected, $x, $src_height + $y - 1, $rgba);
    }
  }
 
  return $reflected;
}
?>
(繼續閱讀...)
文章標籤

Foxbrush 發表在 痞客邦 留言(0) 人氣(9)

  • 個人分類:Development in SW
▲top
  • 4月 11 週三 201218:38
  • [Web] On Responsive Images


How to deal with different image sizes for different screen res 
 http://css-tricks.com/on-responsive-images/
(繼續閱讀...)
文章標籤

Foxbrush 發表在 痞客邦 留言(0) 人氣(2)

  • 個人分類:Development in SW
▲top
  • 4月 11 週三 201217:46
  • [CSS] :target pseudo selector


http://css-tricks.com/on-target/
(繼續閱讀...)
文章標籤

Foxbrush 發表在 痞客邦 留言(0) 人氣(8)

  • 個人分類:Development in SW
▲top
«1...15161719»

個人資訊

Foxbrush
暱稱:
Foxbrush
分類:
財經政論
好友:
累積中
地區:

熱門文章

  • (3,073)[C/C++] 參數數量不固定的函數實作
  • (301)[SCRUM] Scrum 是什麼(2):Scrum 的內涵
  • (72)微軟「失落的十年」
  • (46)富小孩、窮小孩... ...
  • (14)[SCRUM] Scrum 是什麼(14):好問題
  • (9)零肆柒捌
  • (8)一樣水,百百貓喝... ...
  • (5)[CS] 12 Unit Testing Tips for Software Engineers
  • (2)The Fall of Microsoft
  • (2)[Web] 如何挑選適合的 Hosting Plan?

文章分類

  • Investment in Finance (10)
  • Refinement in Design (1)
  • Knowledgement in CS (13)
  • Equipment in SW (25)
  • Development in SW (116)
  • Management in Business (4)
  • Enlightenment in Soul (5)
  • Amazement in Life (4)
  • Argument in Thoughts (3)
  • Sentiment in Whispers (1)
  • 未分類文章 (1)

最新文章

  • 科技業薪水大揭密
  • [Money] Introduction to T-Theory – Magic-T
  • [Stock] 到底要工作還是玩股票
  • [Server][NodeJS] Set-up SSL in NodeJS and Express using OpenSSL
  • [Server] How to get HTTPS working on your local development environment in 5 minutes
  • [MAC] How to open multiple Terminal windows or tabs unsing commands
  • [WEB] mitmproxy
  • [Server] Socket.io 的架構
  • [Server] Socket.io 架構
  • [Money] 教你如何找出轉強股票,不藏私大公開

最新留言

  • [23/06/22] 小克 於文章「[Linux] 讓 Linux 下的中文...」留言:
    您好,我是此篇文章的原作者 您已侵權 請尊重 CC ...
  • [23/05/14] 訪客 於文章「[Linux] 讓 Linux 下的中文...」留言:
    超感謝!...
  • [22/07/02] Sean 於文章「[Linux] 讓 Linux 下的中文...」留言:
    您好, 我跟著https://www.youtube....
  • [22/04/11] 訪客 於文章「[Stock] 如何最精準的掌握到關鍵得...」留言:
    原本在搜尋引擎找出一堆 Blog 文章,不知哪幾篇值得花時間...
  • [21/08/20] ANDRES 於文章「[Linux] 讓 Linux 下的中文...」留言:
    好人,造福LINUX新手,謝謝...
  • [21/08/02] Skyer 於文章「[Linux] 讓 Linux 下的中文...」留言:
    非常棒的設定,非常感謝!...
  • [12/11/29]  於文章「[Web] Install Apache...」留言:
    雲 青 青 兮 欲 雨 ,  水 澹 澹 兮 生 煙 。 ...
  • [09/09/15] liwayhuang 於文章「一樣水,百百貓喝... ......」發表了一則私密留言
  • [09/09/08] pheen 於文章「什麼是行銷!?...」留言:
    為什麼要鎖? 文章,呵。...
  • [09/08/08] liwayhuang 於文章「富小孩、窮小孩... ......」留言:
    mm...interesting...

文章精選

文章搜尋

誰來我家

參觀人氣

  • 本日人氣:
  • 累積人氣: