2015年5月31日 星期日

Google Glass - 'Jump' to a card in CardScrollView via setSelection doesnt work

I had found why it can't jump to specific card for 1~2days.
Finally i got a resolution. hope i could help others
This block is get the position and use animate to jump to the specific
 mCardScroller.setSelection(mCardScroller.getSelectedItemPosition() + 1);
 mCardScroller.startAnimation(AnimationUtils.makeInAnimation(mCardScroller.getContext(), true));
BUT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NOT WORK
IMPORTANT!!ADD THIS IN YOUR ONCREATE()
mCardScroller.activate()
AND CHECK THIS TWO LIFE PERIOD
@Override
    protected void onResume() {
        super.onResume();
        mCardScroller.activate();
    }

    @Override
    protected void onPause() {
        mCardScroller.deactivate();
        super.onPause();
    }
GOOGLE GLASS 跳到特定的CARD,如果你咬遇到一樣的問題setSelection始終無法使用,在ONCREATE()理面加入mCardScroller.activate()就會有結果了 希望可以幫住到更多人,因為GLASS的資訊好少,我們也花了一點時間來解決這個問題!!

2015年5月29日 星期五

[mySQL]hinet.net is not allow to connect to this mySQL server

When i tried to connect mySql (not localhost),i met a problem






[Solution]:Because other the authority
shell>mysql --user=root -p
輸入密碼
mysql>use mysql
mysql>GRANT SELECT,INSERT,UPDATE,DELETE ON [db_name].* TO [username]@[ipadd] identified by '[password]';

[username]:遠程登入的使用者代碼(userid)
〔db_name]:表示欲開放給使用者的數據庫稱(show for user db name)
[password]:遠程登入的使用者密碼(user pwd)
[ipadd]:IP地址或者IP反查後的DNS Name,此例的內容需填入'59-126-182-81.HINET-IP.hinet.net',包涵上引號(')

(其實就是在遠端服務器上執行,地址填寫本地主機的ip地址。)

2015年5月22日 星期五

C# Textbox automatically scroll to the bottom

If you try to show the text on your textbox,we will account a problem.
The textbox vertical or horizontal length is not enough for us to use.
LIKE THIS PICRURE BELOW



















Solution:
  textBox1.ScrollBars = ScrollBars.Vertical; //scroll in vertical 
  textBox1.Text +=count+" : "+ read.GetInt32(0) + "Data"+"\r\n";
  textBox1.SelectionStart = textBox1.Text.Length;
  textBox1.ScrollToCaret();
  textBox1.Refresh();






2015年5月19日 星期二

C++ Fixed decimal point

Record how to fix the decimal point in c++
int main(){
 long double o = sqrt(2);
 for(int i = 0 ; i < 20 ; i++){//print long double
        cout.precision(i);
        cout << o << endl;
    }
}
1
1.4
1.41
1.414
1.4142
1.41421
1.414214
1.4142136
1.41421356
1.414213562
1.4142135624
1.41421356237
1.414213562373
1.4142135623731
1.41421356237310
1.414213562373095
1.4142135623730951
1.41421356237309510
1.414213562373095100
1.4142135623730951000

2015年5月15日 星期五

C++ Vector

Record c++ Vector otherwise i will forget~~
First #include<vector>

"Add element"
for(int i=0 ; i<10 ; i++){
     cout<<"Add "<< i<<" to vector"<< endl;
     v1.push_back(i);
}
     cout<<"size : "<< v1.size()<< endl;

"Resize"
v1.resize(8);
cout<<"resize :"<< v1.size()<< endl;
cout<<"resize element :"<< endl;
for(int i=0 ; i < v1.size() ; i++){
cout<<"NO "<< i+1<<" : "<< v.1[i]<<"  "<< endl;
}

"Delete element"
int pos;
cout<<"Delete NO ";
cin>>pos;
v1.erase(v1.begin()+(pos-1));//begin=起始+0
for(int i=0 ; i < v1.size() ; i++)
cout<<"NO "<< i+1<<" : "<< v1[i]<< endl;

"Pop top element"
cout<<"pop top "<< endl;
v1.pop_back();
for(int i=0 ; i < v1.size() ; i++)
cout<<"NO "<< i+1<<" : "<< v1[i]<<"  "<< endl;

"Sort"
sort(v1.begin(),v1.end());
for(int i=0 ; i < v1.size() ; i++)
cout<< v1[i]<<" ";
cout<< endl;

"Reverse element"
cout<<"reverse : ";
reverse(v1.begin() , v1.end());
for(int i=0 ; i < v1.size() ; i++)
cout << v1[i]<<"  ";
cout<< endl;

"Use iterator"
cout<<"Find value : ";
int fnum;
cin>>fnum;
vector< int >::iterator it;
it=find(v1.begin() , v1.end() , fnum);
  if(it != v1.end()) {
     cout << "Found value!" << endl;
  }
  else{
      cout << "Not found!" << endl;
  }
cout<<"Use iterator"<< endl;
int count=0,temp;
for(it=v1.begin() ; it!=v1.end() ; it++){
     count++;
     cout<< *it <<" ";
       if(*it==fnum)
  temp=count;
}
 cout<< endl;
 cout<<"Found "<< fnum<<" position : "<< temp<< endl;

"Clean vector"
cout<<"use clear vector "<< endl;
v1.clear();
if(v1.empty())
   cout<<"empty vector"<< endl;
else
   cout<<"unempty"<< endl;

Some vector learning website:
web1
web2