網頁

2013年11月29日 星期五

FB Share Link

Last Update: 2013/11/29 23:52+08
Type: Note



nstp.fbshare = function(){
  var time = '&time='+new Date().getTime();
  var url = 'http://www.facebook.com/share.php?u='.concat(encodeURIComponent(location.href)).concat(time);
  window.open(url);
};


Debug
https://developers.facebook.com/tools/debug


<meta property="og:title" content="Unknow"/>
<meta property="og:type" content="movie"/>
<meta property="og:url" content="http://www.example.com/" />
<meta property="og:image" content="http://www.example.com/img/logo.png"/>
<meta property="og:site_name" content="example"/>

og 以外 指定縮圖
<link href="圖片連結網址" rel="image_src" type="image/jpeg" / >


2013年10月20日 星期日

C++ memory & stack-allocated for local variable

Last Update: 2013/10/20 12:22+08
Type: note


Intro

Local Variable 的 memory 位置 和 return value
主要是要測試 class 在 function return 時 的問題
但用 int 比較方便解釋, 所以這邊用 int 作測 試
int get1(){ int rs = 1; printf("%d : %d\n", &rs, rs); return rs;}
int* get2(){ int rs = 2; printf("%d : %d\n", &rs, rs); return &rs;}
int& get3(){ int rs = 3; printf("%d : %d\n", &rs, rs); return rs;}
int& get4(){ int *rs = new int(4); printf("%d : %d\n", rs, *rs); return *rs;}


2013年10月19日 星期六

C++ - use of reference(&) or pointer(*) in function parameters

Last Update: 2014/12/20 14:19+08
Type: Note


Intro


如何傳遞參數
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>

class Vec2D {
public:
 int x, y;
};


2013年10月17日 星期四

Online Tool

Last Update: 20131018 11:37+08
Type: note



Photo Online Editor

像Photoshop, 但功能少很多, 夠用就好


Ziin.pl

檔案(圖檔) 轉換工具


syntax highlighting

程式語法的 highlighting


2013年9月2日 星期一

NCVerilog - import VHDL into Verilog

Last Update: 2013/09/02 15:25+08


--- Intro ---


這篇是將 VHDL 導入到 Verilog 的方法
重點在interface(shell)的建立
ImportVhdlToVerilog Verilog Model Verilog Shell For VHDL model Verilog other Model VHDL entity / architecture
環境: Linux - CentOS release 4.6 (Final)
Cadence tools: ncvhdl, ncvlog, ncelab, ncsim


2013年8月31日 星期六

OpenRISC toolchain on Ubuntu

Last Update: 2014/10/26 22:22+08
Type: Note



--- Intro ---



OpenRISC toolchain 環境建立
Ubuntu 建議安裝LTS(Long Term Support)版
各位看倌有興趣可參考 官方安裝說明 有較完整的安裝方式
這裡僅是給我自己的筆記

  • Precompiled binaries
  • Installation from source
  • Installation of development versions

這3個安裝的方法, 應該是則一即可.
但 各版本仍 有些不同 我是全裝起來
再看狀況設置 PATH
還有一個 orbuild 但官方已經說很久沒更新了
所以能不能用就是各位看倌的命了XD


環境: Ubuntu-12.04.2 32bit

Ubuntu-14.04.1 32bit 目前無法成功


2013年8月26日 星期一

Linux & PuTTY & XManager

Last Update: 2013/08/26 16:27+08
Type: Note

Intro


這是在 Windows 用 PuTTY 連線到 Linux/Unix 主機
並且用 XManager 將 GUI 部份顯示到 Windows 的筆記
P.S. 可用 WinSCP 做檔案傳輸


Content


=========PuTTY===========================
在 Session 輸入你的Host Name, 預設Port:22
Connection Type: SSH

再到 Connection => SSH => X11 裡
  勾選 [Enable X11 forwarding]
  X display location= localhost: 0
  其它用預設值



=========防火牆===========================
Windows Firewall => 進階設定 => 輸入規則
=> 加入允許 XManager.exe 通過

基本上, 在安裝時XManager就會被加入了
你應該可以在輸入規則裡找到 [PC X server for MS Windows Platform]
只是要注意一下它預設適用的網路類型只有[私人]
之前有發生過用VPN 不能改網路類型, 結果一直連不到-0-



=========Linux===========================
setenv DISPLAY [your_id_address]:0.0
xclock
[your_id_address] eg. 140.114.11.22 輸入xclock 後, 應該就會有畫面出現在你的電腦了


2013年8月23日 星期五

Eclipse 常用設定

Last Update: 2013/08/24 13:59+08
Type: Note


Intro & Content


Eclipse 常用的一些設定
===使用特定JDK===========================
在 %Eclipse Home%/eclipse.ini
複製下面語句, 放在最上面, 一定要最上面
-vm
C:/Program Files/Java/jdk1.6.0_45/bin/javaw.exe



===Encoding===========================
Window -> Perference -> General -> Content Types -> 把每個type 的 Default encoding 都 update 成 utf-8
Window -> Perference -> General -> Workspace -> Text file encoding 改成 utf-8
Window -> Perference -> Web-> XXX -> Encoding 改成 utf-8 (這邊是Create File時)


若用html 可加上
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
若用 JSP 可在檔頭加
<%@ page language="java" contentType="text/html; charset=utf-8"
 pageEncoding="utf-8"%>
若用 PHP 可在檔頭加
<?php
header("Content-Type:text/html; charset=utf-8");
?>
雖然這3者意義相同
但有可能會在 html 開始前 印出(echo, print and so on)訊息 然後中止response, 所以還是看情況加



===中文字型太小===========================
安裝 YaHei.Consolas.1.12.ttf 字型
到 Windows -> Prefereces -> General -> Appearance -> Colors and Fonts -> Basic -> Text Font -> 編輯修改成剛剛安裝的字型


2013年8月15日 星期四

SQLite 無法修改欄位

Last Update: 2013/08/15 21:14+08
Type: Note


Intro & Content


據說 SQLite 無法修改欄位
可以先 rename table 做為備份
ALTER TABLE foo RENAME TO foo_backup
再將 建立一個 foo table 符合你要的欄位
複製 foo_backup 到 foo
最後Drop
classTABLE foo foo_backup

2013年7月15日 星期一

Apache + PHP & MySql for Windows

Last Update: 2013/07/16 13:06+08


Intro


Apache 安裝 PHP 的方式
基於Windows 7
雖然網路上找到很多人在說
但還是做個筆記
。 解壓&設定 PHP
。 安裝&設定 Apache
。 建立 Apache 的 Windows服務
。 PHP測試程式
。 安裝MySQL & 測試程式

2013年5月24日 星期五

C++ Map 操作

Last Update: 2013/05/24 17:43+08
Type: Note


Content


前置
#include "stdafx.h"
#include <string>
#include <map>
using namespace std;


宣告
int _tmain(int argc, _TCHAR* argv[])
{
 map<string, int> maps;
Insert
 map<string,int>::iterator it = maps.begin();
 maps.insert(it, pair<string,int>("A",26));
 maps.insert(it, pair<string,int>("B",27));
 maps.insert(it, pair<string,int>("C",28));
 maps.insert(it, pair<string,int>("D",29));
 maps["E"] = 30;
For Loop
 for (it=maps.begin(); it != maps.end(); ++it){
  printf("%s = %i\n", it->first.c_str(), it->second);
 }
Get
 printf("E = %i\n", maps["E"]);
 printf("F = %i\n", maps["F"]);//預設為0
Remove
 maps.erase("E");
Find
 it = maps.find("E");
 if(it == maps.end())
  printf("not found.\n");
 else
  printf("%s = %i\n", it->first.c_str(), it->second);
The end...
    
 getchar();
 return 0;
}

2013年5月10日 星期五

C++ Macro Note

Last Update: 2013/05/11 21:33+08
Type: Note

Intro

C++ Macro 筆記
#define GetObjName(x) #x
#define DebugPrint(msg) printf("%s ; %s ; %s ; %d\n", #msg, __FILE__, __FUNCTION__, __LINE__)
#define Contact(x, y) x##y


int _tmain(int argc, _TCHAR* argv[])
{

 printf("line: %d \n", __LINE__);
 printf("file: %s \n", __FILE__);
 printf("function: %s \n", __FUNCTION__);
 //printf("function: %s \n", __func__);
 printf("time: %s \n", __TIME__);
 printf("date: %s \n", __DATE__);
 //printf("STDC: %d \n", __STDC__);
 //printf("STDC_HOSTED: %d \n", __STDC_HOSTED__);
 //printf("VERSION: %s \n", __VERSION__);
 printf("TIMESTAMP: %s \n", __TIMESTAMP__);


 char* s = GetObjName(MyClass);
 printf("%s \n", s);
 Contact(pri, ntf) ("exec printf \n");
 DebugPrint("Debug");


 getchar();
 return 0;
}
Macro中的# 代表取得variable名稱
該變數可以是 class, function, ...

## 是將2個變數粘在一起, pri##ntf = printf

__FILE__ , __FUNCTION__, __LINE__, ... 是 Compiler 預先就定義好的變數
debug時, 可以print出來, 方便識別


C++ operator new/delete

Last Update: 2013/05/10 17:50+08


Intro

Operator new/delete 的測試
先說明一下 new 和 delete 的行為, 如下
MyClass* test = new MyClass();
/*Operator new(sizeof(MyClass)) => exec constructor*/
delete test
/*exec destructor => free(test)*/

2013年5月3日 星期五

C++ new class or not

Last Update: 2013/05/03 18:39+08


Intro

關於使用Class時, 要不要 "new" 一個出來
本來以為C++的memory都要自己管理
沒想到也有交給別人的時候...
嘛 是我太弱了

就是下面2行的差異
MyClass temp1;
MyClass *temp2 = new MyClass();