Mac 總算來了
最近在架設有關mac的相關環境
看到mac內建的terminal
雖說簡單
但...他只有黑白orz
所以就將它改個顏色吧
Google了蠻多篇的
但終於找到可以用的
#vim ~/.bash_profile //new a new file
新增以下兩行
export CLICOLOR=1
export LSCOLORS=gxfxaxdxcxegedabagacad
存檔...logout...restart terminal即可生效
2012年7月13日 星期五
2012年7月9日 星期一
有關php code會直接被download與Call to undefined function mysql_connect() 的解決方法
今天在test東西的後發現
我將我的php code丟進我的server後竟然...
把我的網頁下載下來orz
經過google大神得到以下的解決方法
進入/etc/apache2/mods-available/php5.conf
將以下全部註解
< IfModule mod_userdir.c >
< Directory /home/*/public_html >
php_admin_value engine Off
< /Directory >
< /IfModule >
存檔後將apache restart
----------------------------------------------
通常問題不會只有一個
果然又出現另一個問題了
網頁出現了另一個error message
Fatal error: Call to undefined function mysql_connect()...
解決的方法其實很簡單
step1:
檢查你的/etc/apache2/apache2.conf
extension = mysql.so
如果有注解的話將它拿掉
拿掉後restart apache
如果還是不行的話
step2":
檢查是否沒有安裝php5-mysql與php5-cgi
直接使用
#sudo apt-get install php5-mysql
#sudo apt-get install php5-cgi
安裝結束後restart apache
ps.本人在安裝的時候遇到一串error
Internal Error, ordering was unable to handle the media swap
如果遇到這個問題
我的解決方法是:將apt-get update
#sudo apt-get update
然後再安裝以上兩個套件即可
參考網頁:
http://www.ubuntu-tw.org/modules/newbb/viewtopic.php?topic_id=25172
http://sahabm.blogspot.tw/2009/04/resolving-fatal-error-call-to-undefined.html
2012年7月2日 星期一
Mysql 忘記密碼處理
常常把mysql的密碼忘掉orz
今天google 到一個適用的方法
系統版本:
Ubuntu 11.04
註:
#為linux command
>為mysql command
首先先將mysql stop
#service mysql stop
將mysql 啟動為無人控制mode(下玩指令後當它停止的時候要另開新的頁面[可以使用screen])
#mysql_safe --skip-grant-tables&
登入mysql
#mysql
重設密碼為'1234'(可自己改成你想要的密碼)
>update mysql.user set password=PASSWORD('1234') where user='root';
需手動生效
>flush privileges;
離開mysql
>quit
restart mysql
#service mysql restart
參考網站:http://blog.xuite.net/pippeng/blog/19152470
今天google 到一個適用的方法
系統版本:
Ubuntu 11.04
註:
#為linux command
>為mysql command
首先先將mysql stop
#service mysql stop
將mysql 啟動為無人控制mode(下玩指令後當它停止的時候要另開新的頁面[可以使用screen])
#mysql_safe --skip-grant-tables&
登入mysql
#mysql
重設密碼為'1234'(可自己改成你想要的密碼)
>update mysql.user set password=PASSWORD('1234') where user='root';
需手動生效
>flush privileges;
離開mysql
>quit
restart mysql
#service mysql restart
參考網站:http://blog.xuite.net/pippeng/blog/19152470
2012年7月1日 星期日
GPS實作(非使用google map 純使用android library)
最近需要寫有關利用手機去偵測現在的location(經度、緯度)
但不要透過Google map API實現
以下機型測試成功:
HTC Sencation XE(android 4.0.3)
Sony Xperia Arc(android 4.0.4)
HTC One X(android 4.0.3)
在AndroidManifest.xml的檔案裡面的< /application >後面加上
http://hejp.co.uk/android/android-gps-example/
http://www.javacodegeeks.com/2010/09/android-location-based-services.html
http://www.moke.tw/wordpress/computer/advanced/279
但不要透過Google map API實現
以下機型測試成功:
HTC Sencation XE(android 4.0.3)
Sony Xperia Arc(android 4.0.4)
HTC One X(android 4.0.3)
android.app.Activity;
android.content.Context;
android.location.Location; //可以在指定的時間提供location
android.location.LocationListener; //為自訂億的class android library沒有這個class
android.location.LocationManager; //提供可以存取系統location的service
android.os.Bundle; //傳送參數會使用
android.view.View;
android.view.View.OnClickListener;
android.widget.Button;
android.widget.Toast; //快顯訊息
public class GPS extends Activity {
private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1;
//設定超過一個距離(尺)他就會做更新location的動作
private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000;
//設定超過一個時間(毫秒)他就會做更新location的動作
protected LocationManager locationManager;
protected Button retrieveLocationButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
retrieveLocationButton = (Button)findViewById(R.id.retrieve_location_button);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
//get location service
//requestLocationUpdates(long minTime, float minDistance, Criteria criteria, PendingIntent intent)
//Criteria: 訂定尋找location provider的標準
//PendingIntent: 處理即將發生的事件
//PendingIntent與Intent的差異:Intent會隨著Activiy的消失而消失,PendingIntent不會
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, //Name of the GPS provider
MINIMUM_TIME_BETWEEN_UPDATES,
MINIMUM_DISTANCE_CHANGE_FOR_UPDATES,
new MyLocationListener()
);
retrieveLocationButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
showCurrentLocation();
}
});
}
protected void showCurrentLocation() {
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
//取得最後得知道provider資訊
if (location != null) {
String message = String.format(
"Current Location \n Longitude: %1$s \n Latitude: %2$s",
location.getLongitude(), location.getLatitude());
Toast.makeText(GPS.this, message,Toast.LENGTH_LONG).show();
}
}
private class MyLocationListener implements LocationListener {
public void onLocationChanged(Location location) {
String message = String.format(
"New Location \n Longitude: %1$s \n Latitude: %2$s",
location.getLongitude(), location.getLatitude());
//將想要印出的資料用string.format的方法存入string
Toast.makeText(GPS.this, message, Toast.LENGTH_LONG).show();
//Toast.LENGTH_LONG:以最長的時間週期呈現文字
}
public void onStatusChanged(String s, int i, Bundle b) {
Toast.makeText(GPS.this, "Provider status changed",
Toast.LENGTH_LONG).show();
//當provider cheange的時候會顯示
}
public void onProviderDisabled(String s) {
Toast.makeText(GPS.this,
"Provider disabled by the user. GPS turned off",
Toast.LENGTH_LONG).show();
//當device的GPS沒有開啟的時候他會顯示
}
public void onProviderEnabled(String s) {
Toast.makeText(GPS.this,
"Provider enabled by the user. GPS turned on",
Toast.LENGTH_LONG).show();
//當device將GPS打開的時候他會顯示
}
}
}
最後別忘了需要一些permission:在AndroidManifest.xml的檔案裡面的< /application >後面加上
< uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> //允許一個程式存取精確位置 < uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> //允許程式建立模組使用 < uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> //允許程式存取CellID或WiFi熱點來取得粗略的位置參考網址:
http://hejp.co.uk/android/android-gps-example/
http://www.javacodegeeks.com/2010/09/android-location-based-services.html
http://www.moke.tw/wordpress/computer/advanced/279
訂閱:
意見 (Atom)