星期日, 12月 26, 2010

「Android」「HeRo 2.2」「ubuntu」USB 上網問題!!

自從 小hero 刷成2.2後,Ubuntu就好像卡到的樣子,
都不給我用USB上網,而且不只有ubuntu 連win7也是,
很神奇的是 xp 只要裝個驅動就可以上網了(*),
原本發現用橋接的方法可以上網(非常的麻煩),
參考:http://blog.mycila.com/2010/06/reverse-usb-tethering-with-android-22.html
之後看了下面2篇文章後,ubuntu就可以上網了。
參考:http://www.arthurtoday.com/2010/05/ubuntu-dhcp-ip.html
參考:http://foxail.openwebster.com/blog/?p=306
參考:http://blog.roodo.com/rocksaying/archives/11777065.html

首先 打開 sudo vim /etc/network/interfaces,
加入 手機網卡的名字(wo的是usb0),把它搞成dhcp,就OK了

auto usb0
iface usb0 inet dhcp

之後 sudo /etc/init.d/networking restart
最後啟動 手機的usb鏈接的軟體(wired tether)

2011 01/13 :
刷了 FroydVillain 1.7.2 之後 點USB分享網路 WIN7 就直接可以上網了。

2011 01/25:
最近WIN7上網改用 PDANET 感覺不錯用,雖然開驢子還是會怪怪的,不曉得是那邊的問題。

2011 02/05:
最近網路變得很詭異,驢子會怪怪的,意思是不要開驢子,免得網路變得更奇怪。



星期三, 12月 15, 2010

「YII」關聯 relations 和 CGridView

在資料上設定關聯

public function relations()
{
'types'=>array(self::BELONGS_TO, 'Commodity',
'type','alias'=>'category',
'joinType'=>'LEFT JOIN',
),
........


在呼叫search() 函數中加入

$criteria->with = array('types',);


之後設定VIEW

$this->widget('zii.widgets.grid.CGridView', array(
....
'types.name',
....
);


自定 name 和 value 可以加入array

$this->widget('zii.widgets.grid.CGridView', array(
array(
'name'=>'Type',
'value'=>'date("Ymd",strtotime(".$data->time. 00:00:00")).$data->id',
),
'types.name',
....
);

最後 要插入自己的變數 在ARRAY 變數除了用$data->之外 還要用 "."這個該死的東西,
第一次用 根本不曉得要加。

星期一, 12月 06, 2010

「YII」CJuiDatePicker 筆記2

CJuiDatePicker 是個很酷的元件,
設定語言:'language' => Yii::app()->getLanguage(),
設定當前日期:'value'=>$this->myDataPicker_time,
文檔就打的value解釋只寫the input value,
小弟英文太弱,看半天才知道那個是放日期的。
設定每個日期按鈕的事件可以用 jquery ui DatePicker的方法
onSelect 需要放在 options 陣列裏面.

$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name'=>'cakexdp',
'flat' => true,
'htmlOptions' => array('name'=>'cakexdp',),
'language' => Yii::app()->getLanguage(),
'value'=>$this->myDataPicker_time,
'options'=>array(
'showAnim'=>'fold',
'altFormat'=>'yy-mm-dd',
'dateFormat' => 'yy-mm-dd',
'onSelect'=>'js:function(dateText, inst){
$(\'#caketime\').val(dateText);
$(\'#div_time\').submit();
//alert(dateText);
}',
),
));

..

星期日, 12月 05, 2010

「YII」CJuiDatePicker 筆記

YII 實在是太強了!!!
CJuiDatePicker 日期的widget,封裝了jquery UI 的 DatePicker,
使用上 會發現有問題 就是跑不出來,需要在中間加入
'htmlOptions' => array('name'=>'YOUR NAME',),

$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name'=>'cakexdp',
'flat' => true,//不使用隱藏
'htmlOptions' => array('name'=>'cakexdp',),//再多加入才不會有錯誤
'options'=>array(
'showAnim'=>'fold',
'altFormat'=>'yy-mm-dd',//設定格式
'dateFormat' => 'yy-mm-dd',//設定格式
//onSelect 爲 DatePicker 的方法。
'onSelect'=>'js:function(dateText, inst){alert(dateText);}',
),
));
echo "</div>";//最後需要加上 /DIV 沒加入 會有問題。


。。。

星期六, 12月 04, 2010

「YII」隱藏 index.php

YII 是個非常酷的PHP網頁框架,只是那個 index.php 越看越不順眼。

「參考」http://bbs.php.la/thread-323-1-1.html
「參考」http://blog.jsdan.com/20


在 /your project file/config/main.php 中,
需要在 urlManager 陣列中加入資料

'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
.......
),

在 .htaccess 加入 規則

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php


Linux Apache2 需啟動 rewrite

sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart


設定 httpd.conf ,中加入
sudo vim /etc/apache2/httpd.conf

<directory /var/www/xxxxxxxx >
AllowOverride all
</directory>

星期二, 11月 02, 2010

【JavaFX】SQLITE 和 發佈

參考:
連接SQLITE:http://d.hatena.ne.jp/bluepapa32/20090606/1244299138
簽證:http://blog.csdn.net/ming470612141/archive/2009/03/31/4037495.aspx

在發佈時,需要修改2個.jnlp檔。
codebase 改為SERVER的路徑
所有的.jar 都需要簽證。

keytool -genkey -alias TestApplet -validity 365
jarsigner TestApplet.jar TestApplet

先載入SQLITE ,ssql 為建立資料庫字串:CREATE TABLE.....

Class.forName("org.sqlite.JDBC");
var con = DriverManager.getConnection("jdbc:sqlite{FX.getProperty("javafx.user.home")}/sfdata2.sqlite");
var stat = con.createStatement();
stat.executeUpdate(ssql);
stat.executeUpdate(ssql);

使用搜尋 var rs = stat.executeQuery("selece * from xxx");
用的方法就和JAVA蠻像的。

星期三, 10月 20, 2010

「Android」 TableActivity 筆記

參考: http://developer.android.com/resources/tutorials/views/hello-tabwidget.html
在 helloViews 中的 tableActivity 中,是使用 XML的方式來實現 多個分頁。
在分頁中獨立一個 activity 做法:
1.主類別:CakeXsmS ,次要分頁類別:CsetSmsActivi,ChistoryActivi
2.向AndroidManifest.xml application裏面 註冊:

<activity android:name=".CsetSmsActivi">
<activity android:name=".ChistoryActivi">

3.開始載入:

public class CakeXsmS extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
final TabHost tabhost = getTabHost();
tabhost.addTab(tabhost.newTabSpec("tab1")
.setIndicator(this.getResources().getText(R.string.SUBMIT_SMS)
).setContent(new Intent(this,CsetSmsActivi.class)));

tabhost.addTab(tabhost.newTabSpec("tab2")
.setIndicator(this.getResources().getText(R.string.SMS_DATA))
.setContent(new Intent(this,ChistoryActivi.class)));
}
}

4.撰寫分頁的activity:

public class ChistoryActivi extends Activity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
  // TODO Auto-generated method stub
  super.onCreate(savedInstanceState);
.......MORE......
public class CsetSmsActivi extends Activity {
.......MORE......