2014年2月6日 星期四

[工具] - 10分鐘信箱

10分鐘信箱 - 為需要暫時信箱的使用者提供一個還不錯的解決方案。

簡單說,這信箱用一用就可以丟了,可以說是綠色 (環保) 信箱呢!

不需帳號、不需密碼、不需個人資料立即使用

因為用一用就能隨手拋棄,所以再也不用煩惱為何剛使用不久的 email 總是收到一堆垃圾信



2014年1月29日 星期三

[Arduino] [Visual Studio] - 使用 Visual Studio 取代 Arduino 原廠 IDE

最近上 CodePlex 看了看,找到了這功能強大的插件 「Arduino for Visual Studio and Atmel Studio」,它使我能擺脫以前難用的原廠 Arduino IDE ,且支援 Arduino 所有的板子、Serial Monitor、ISP、Bootloader‎,並將 Visual Studio 的特色融入其中,使在開發 Adruino 時也能兼具原本 Visial Studio 的撰寫環境,值得推薦!

Arduino for Visual Studio and Atmel Studio

下載位置:
CodePlex: http://visualmicro.codeplex.com/


安裝使用步驟:
當然,使用 Visual Studio 替代原廠 IDE 必須要有 Visual Studio 才能使用,我這邊使用的是 2012 版本。插件也要求使用者需安裝 Arduino 原廠的 IDE ,有支援 1.0.X 和 1.5.X,我這邊使用的是1.0.5版本。

1.下載並安裝程式檔案,下載連結在上方

2.啟動 Visual Studio ,並會看到多出了個似廣告的視窗,我們先不管它並繼續使用 free trail (試用版本)。選擇 free trail

3.選擇目前使用的 Arduino IDE 版本,並設定目前 Arduino IDE 的安裝路徑,另外 sketchbook 就看要不要填,我這邊是空著它。選擇 OK

4.如需新增一個 Arduino 專案,到 「檔案」->「新增」選擇「Sketch Project」後填入專案名稱並新增一個新的 Arduino 專案


以上安裝步驟概述完畢,但是寫完自己的程式總需要把程式燒錄至 Arduino ,對吧?
沒錯,不用想得太複雜,只需按下 F5 ,Arduino 專案會自己編譯後將程式燒錄至指定的 Serial Port。

*選擇 Arduino 板子類型,請在 Visual Studio 工具列上找到有 Arduino XXXX 的下拉式選單來選取
*選擇要燒錄的 Serial Port ,請在 Visual Studio 工具列上找到有 COMXX 的下拉式選單來選取
*使用 Serial Monitor,它就在選擇 Serial Port 下拉是選單的右方,點該按鈕即可叫出

2014年1月27日 星期一

[PHP] - isset / empty 應用,檢查變數有無被宣告或設置

今天我從客戶端傳送一個 POST/GET 訊息給伺服器端 (PHP) 時,因為我傳送的資料有著不固定的名稱與內容,所以傳送了不知名稱的資料至 PHP,這時 PHP 就出錯了!

後來查了 PHP 官方文件,其實這種錯誤是能夠避免的,方法如下:

檢查一個變數是否有被設置內容時,使用 empty 來進行確認:
<?php

// 顯示為 "YES"

$var0;
$var1='';

if (empty($var0) and empty($var1))
    echo "YES";
else
    echo "NO";


// 顯示為 "FALSE"

$var2="Hello";

if(empty($var2))
    echo "TRUE";
else
    echo "FALSE";

?>

如需檢查這變數是否存在 (已宣告) ,則使用 isset 進行確認:
<?php

// 顯示為 "NO"

$var0;

if (isset($var0))
    echo "YES";
else
    echo "NO";


// 顯示為 "TRUE"

$var1='';
$var2="Hello";

if(isset($var1) and isset($var2))
    echo "TRUE";
else
    echo "FALSE";

?>

這兩種方法看起來相似,其實完完全全是兩樣不同的東西唷!

2014年1月15日 星期三

[C/C++] [VB.NET] - 階層範例,求n!問題

C/C++ 版本
// 階層範例
// (C) 2014 Stubio Awei.
// 2014/1/15
// Source.cpp

#include <iostream>

using namespace std;

int main()
{
 const int SIZE_SUM = 100; // 存放運算結果之陣列大小
 const int LENGTH_SUM = SIZE_SUM -1; // 存放運算結果之陣列長度
 int sum[SIZE_SUM]; // 存放運算結果之陣列
 int N = 12; // 階層數
 int temp = 0; // 暫存,乘開後放置
 int temp0 = 0; // 暫存,進位數

 memset(sum, 0, sizeof(sum)); // 將 sum 全部初始化為零 (0)
 sum[0] = 1; // 階層第一個數都為 1 ,故先給予設定
 for (int i = 2; i < N + 1; i++)
 {
  for (int j = 0; j < SIZE_SUM; j++)
  {
   temp = sum[j] * i + temp0; // 將該位數的數值乘出來,並將上一個進位數加起來
   sum[j] = temp%10; // 取得 temp 所乘出的個位數數字,使用餘除
   temp0 = temp/10; // 取得 temp 所乘出的十位數以上數值
  }
 }

 for (int i = LENGTH_SUM; i>-1; i--)
 {
  // 取得運算出來的數值長度
  if (sum[i] != 0)
  {
   N = i;
   break;
  }
 }

 // 輸出運算結果 sum
 for (int i = N; i >-1; i--)
 {
  cout << sum[i];
 }
 cout << endl;
 system("pause");
}
VB 版本
// 階層範例
Module Module1

    Sub Main()
        Const SIZE_SUM As Integer = 100  ' 存放運算結果之陣列大小
        Const LENGTH_SUM As Integer = SIZE_SUM - 1 ' 存放運算結果之陣列長度
        Dim sum(SIZE_SUM) As Integer ' 存放運算結果之陣列
        Dim N As Integer = 12 ' 階層數
        Dim temp As Integer = 0 ' 暫存,乘開後放置
        Dim temp0 As Integer = 0 ' 暫存,進位數

        sum(0) = 1 ' 階層第一個數都為 1 ,故先給予設定

        For i As Integer = 2 To N
            For j As Integer = 0 To SIZE_SUM
                temp = sum(j) * i + temp0 ' 將該位數的數值乘出來,並將上一個進位數加起來
                sum(j) = temp Mod 10 ' 取得 temp 所乘出的個位數數字,使用餘除
                temp0 = temp \ 10 ' 取得 temp 所乘出的十位數以上數值
            Next
        Next

        For i As Integer = LENGTH_SUM To 0 Step -1
            ' 取得運算出來的數值長度
            If Not sum(i) = 0 Then
                N = i
                Exit For
            End If
        Next

        ' 輸出運算結果 sum
        For i As Integer = N To 0 Step -1
            Console.Write(sum(i))
        Next
        Console.WriteLine()
        Console.Read()
    End Sub

End Module

2013年7月1日 星期一

VC++ 2012 文件檔案路徑筆記

如果想要呼叫在同一資料夾的資料夾下的檔案或者其他資料夾,請試著用以下方法實現:

假如要使用 thefloder 下的 hello.txt ,則...

"./thefloder/hello.txt"

切忌不要...
"../thefloder/hello.txt"
這樣會造成錯誤。

以上。 2017/04/05補充: .. 代表上一個目錄

2013年3月13日 星期三

自守數 (automorphic number)

自守數 簡單來說是一個 正整數自己的平方末幾位數為該數自己本身

舉例說明:

5 * 5 = 25
6 * 6 = 36
25 * 25 = 625
76 * 76 = 5776
376 * 376 = 141376
625 * 625 = 390625

以上均為一些自守數的實際範例。

或可以參考:
[0,1,5,6,25,76,376,625,9376,90625,109376,890625,
 2890625,7109376,12890625,87109376,212890625,
 787109376,1787109376,8212890625,18212890625,
 81787109376,918212890625,9918212890625,
 40081787109376,59918212890625]



2012年3月27日 星期二

Reset CSS 瀏覽器顯示樣式一致化

Reset CSS 瀏覽器顯示樣式一致化


將下方的CSS原始碼貼入你所需要的樣式表中。
------------------------------------------------

/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

------------------------------------------------