Friday, October 24, 2008

OS 10.5 upgrade headaches and solutions

Finally got to upgrade to 10.5 and of course various stuff was broken - one of the reasons why I did not upgrade for so long - never touch a running system. But actually my tiger was not running well - over last 8 weeks the OS X gui was simply crashing on me 2-3 time  and any work-in-progress was lost. This is just like windoze BSOD coz I had to kill the graphic subsytem to get back to work (see this apple entry w m comments somewhere).

So here the things I had to fix after my upgrade:

1) Apache - OSX now uses apache2 per dfault aka config files need to be updated:

a) apache config file now in /etc/apache2/http.conf

change:
Listen  
LoadModule php5_module libexec/apache2/libphp5.so
Alias

2) PHP - the defaut install has not enabled PHP properly:

a) copy /etc/php.ini.default to php.ini
b) Change this in file:
; define error_log file
error_log /var/log/apache2/error_log
;turn logging on:
display_errors=On

;use same socket as PHP on 10.4
mysql.default_socket=/tmp/mysql.sock

mysqli.default_socket=/tmp/mysql.sock


3) MySQL prepane does not work.

After some googling I found a patch released by my sql - grab it here

Tuesday, July 22, 2008

GPRS settings for carriers (China, US,etc)

This as a notepad for self - I always mess-up settings when going on a trip


These settings apply to a Samsung Blackjack I phone running an updated WM6 OS.

China Mobile prepaid:
------------------
Note if your prepaid card does *not* have any dataplan you pay 0.03RMB/Kb. Alternative signup for 10RMB/5MB, 20 RMB/10MB, 50RMB/400MB plan per month.

1) GPRS settings:
Create new settings: cmnet
Connection->GPRS->AddNew: APN=CMNET, Connect to internet
*note* MUST delete any old settings otherwise WM6 seems to reuse existing profiles

2) IE:
Check auto detect
Select connect to WAP network

3) MMS settings: (MMS profile):
cmobile
http://mmsc.monternet.com
check proxy
adddress: 10.0.0.172, port 9201
GPRS: pick cmnet

ATT postpaod:
------------------

1) GPRS settings:
Create new settings: att
APN=wap.cingular, Connect to internet. Leave all else blank

2) IE:
Check auto detect
Select connect to WAP network

3) MMS settings: (MMS profile):
ATT
http://mmsc.cingular.com
check proxy
adddress: wireless.cingular.com, port 80
GPRS: pick att

Sunday, December 23, 2007

Setup MFC6800 network printer AND scanner

Instructions on how to access my MFC6800 printer/scanner via my Linux server (PCLinuxOS4.0)

PRINTER:
A) Linux setup:
1) Connect printer via Linux USB and it will be autodetected - PCLinuxOS has/installs all the required drivers.
2) Use the ControlCenter to setup printer sharing, make printer available to all users
3) Setup linux server as a workgroup server w shared printer

B) OS X
1) SystemPrefs->Printers->Printing add new network printer - MFC will be auto detected and connected
(I think this is all.. I forgot.. it was so easy cannot remember all steps)

SCANNER:
A) Install network capable scanner on Linux using the xsaned scanning daemon
1) Install sane, xsaned if not installed - use the packagemanager
2) Edit /etc/service and ensure this entry exists (sane-port 6566)
3) Get the brother driver from brothers website (http://solutions.brother.com/linux/sol/printer/linux/sane_install.html) (brscan-0.2.4-0.1386.rpm)
4) rpm -ivH brscan-0.2.4-0.1386.rpm
5) umount /proc/bus/usb; mount /proc/bus/usb; mknod -m 666 /dev/usbscanner c 180 48
6) Scanner should now be accessible locally - try "scanimage -L"

B) Setup OS X
1) Get TWAIN drivers from here http://www.ellert.se/twain-sane/
must install the usb, backend and the two TWAIN drivers
2) SystemPrefs->SANE just select net and unselect rest. For net click config and add the IP address of Linux host
3) In terminal session try "scanimage -L" - system should now recognice the network device
4) WinWord and "Image Capture" both can use the scanner - make sure you pick the device called SANE.

Saturday, June 23, 2007

OSX, mySQL,PHP5.x & java, connection-pool quick start in 5mi

Quick start for mySQL,PHP5.x on OS X + java drivers:

1) Download the MySQL server package from here http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg

As root:
2) Install the server - just follow wizard and install the SystemPreferences package (easy UI start/stop)

3) update your /etc/bashrc by adding these lines (so that all users have SQL in their path):
PATH=${PATH}:/usr/local/mysql/bin

4) Start SQL from preference panel.

5) Default mySQL comes with root and anonymous users w/o password - change these! To set
pwd to mysql:
mysql -u root
set password for 'root'@'localhost' = password('mysql');
set password for 'root'@'' = password('mysql');


(if you dont know your hostname do "select Host, User, password from mysql.user;")

As normal user:
5) go to bsh shell and enter the below to quickly learn some simple things about your DB

mysql - u root -p
enter password
Show databases;
use test;
show tables;
show user(); //current logged in users

Install PHP5.x integrated with built-in apache:
2) Update your /etc/httpd/httpd.conf with an alias - for example:
Options Indexes FollowSymlinks MultiViews
AllowOverride None
Order allow,deny
Allow from all 

Alias /dir/dummytst/ "/Users/foobar/eclipse_workspace/dummytst/"

and you can now access PHP files from http://localhost/dir/dummytest/helloworld.php



Install JDBC:

1) Download the JDBC driver here http://dev.mysql.com/downloads/connector/j/5.0.html

2) Best option is to install the driver in the extension for the jvm - this way all programs (tomcat, eclipse,etc) will have access. On OS X this is in /Library/Java/Extensions/
PS: Apache/tomcat says its recommended to put in CATALINA_HOME/common/lib - might be true for other OS but for OSX the above works fine.


3) Code snippet for a java/jsp/etc program:


try {

Statement stmt;

Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/test";
Connection con =DriverManager.getConnection(url,"root", "mysql");
stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("select Host, User, password from mysql.user;");


while(rs.next()){
Object c1 = rs.getObject(1);
Object c2 = rs.getObject(2);
Object c3 = rs.getObject(3);
System.out.print("Column1="+c1.toString()+"|");
System.out.print("Column2="+c2.toString()+"|");
System.out.print("Column3="+c3.toString()+"\n");
}
con.close();
}catch( Exception e ) {
e.printStackTrace();
}



Connection pooling in tomcat 5.5:

These work only on 5.5.x
a) CREATE the file WEB-INF/context.xml for your webapp with similar to the following:






Then in your servlet use this code snippet


Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/TestDB");
Connection con = ds.getConnection();
Statement stmt= con.createStatement();
ResultSet rs = stmt.executeQuery("select Host, User, password from mysql.user;");
while(rs.next()){.....}
con.close();


OR use JSP SQL tags:



select Host, User, password from mysql.user;


Results



Host ${row.Host}

User ${row.User}

Pwd ${row.password}



Wednesday, May 23, 2007

Quick tip on command line short cut in OS X

How many times you’ve type “ssh www.mywebsite.com -l username -p 23423″? want to simplify that?

Here is how you can simplify your shell command:

1. go to shell, type : vi ~/.bash_profile

2. in the following vi editor window, press “a” to switch to insertion mode.

3. put in your short cut command line by line: example: alias sshmyweb=’ssh www.mywebsite.com -l username -p 23423′

4. finish and save your shortcut config by press “ESC” in vim window, then type “:wq”, press enter.

start a new shell window, type in “sshmyweb” and see the magic

this post is originated at Justin's personal blog (click here to see the original post and many others)

Tuesday, May 01, 2007

OS X Tiger Trouble Shooting Tips - /Library/preferences folder

recently my MBP (10.4.9) refuse to shutdown/reboot, and the power button which suppose to trigger the sleep/restart/shutdown command window no loner works either. The only way to restart my MBP is to press and hold the power button. I was wondering what can go wrong, repair permission does not work, clear cache etc does not work either. Searching around and not getting straight answer, then from some other users comment on solving an unrelated problem, I got my solution !

Step 1: create a new user and login as the new user to see if the same problem exists.
step 2: if the problem disappeared, the problem is likely lies in your existing user’s profile (especially ~/Library/preferences/ folder), if the problem does not disappear, try to move the main Library’s preferences folder to to somewhere else temporary (e.g. I moved /Library/preferences to my desktop), then restart to see if the problem disappear.

in my case, once I moved the main /Library/preferences, the shutdown problem is solved. Certainly if I want to , I can try to trial and error to see exactly which preference file caused the problem, but I did not bother to do that.

be aware, since preferences folder is where lots of applications saves their settings, once you moved them away, some application may loose their settings, you can then either put back the particular preference file or just re-do the settings for that application.

the same method should help to identify certain system problems which caused by corrupted preferences file etc.

enjoy . .

this post is originated at Justin's personal blog (click here to see the original post and many others)

Setup Tomcat + Eclipse Dev environment

A quick guide on how to get running:

Tomcat Setup
1) Get your preferred tomcat version from here. In this example I picked 5.x (specifically 5.5.23). Get the 2 zip files Core and Admin (only needed if you want to use the admin app)

2) Unzip these files to /usr/local (typical unix location) ,change the attrib for .sh scripts to 755 (executable) and create a symlink for tomcat so you easily can move between versions:
cd /usr/local
gunzip apache-tomcat-5.5.23.zip
gunzip apache-tomcat-5.5.23-admin.zip
ln - s /usr/local/apache-tomcat-5.5.23 /usr/local/tomcat
cd tomcat/bin
chmod 755 *.sh

For more fancy readers - you can setup a special tomcat account and change owner of the whole tomcat dir to tomcat.

3) Create a user with the admin and manager roles to the default user database in $CATALINA_HOME/conf/tomcat-users.xml - example
role rolename="manager"
role rolename="admin"
user username="admin" password="changeme" roles="admin,manager"

4) Configure tomcat admin and manager to only accept local requests (just in case you're wide open on the internet..):
$CATALINA_HOME/conf/[enginename]/[hostname]/manager.xml add this within the segment
valve classname="org.apache.catalina.valves.RemoteAddrValve" allow="127.0.0.1" valve

Repeat the same for
$CATALINA_HOME/conf/[enginename]/[hostname]/admin.xml

5) Setup a simple webserver access log so you can track who's on your site: In
$CATALINA_HOME/conf/server.xml add this line within the Engine default host:


6) Start tomcat using the bin/startup.sh and /bin/shutdown.sh scripts and go to http://localhost:8080/manager - provide uid/pwd as per above and you should see the manager app.

Integrating w Eclipse

Debugging simple HTTP+javascript apps using local OS X apache:

A) Install the Ajax Toolkit framework (ATF) for nice debugging of ajax apps and javascript in Firefox/Mozilla - detailed instructions on the eclipse site - summary here:
1) Download ATF build to local
2) Help -> Software Updates -> Find and Install...
3) Select Search for new features to install then Select Next then Select New Archived Site...
4) Select the location of the downloaded update site zip file then Select Finish
5) Make sure all ATF features are selected and Follow the remaining prompts to install ATF
6) restart elipse form cmdline using eclipse - clean and close. Then start normally

B) Setup eclipse to use debug apps using mozilla+apache:
1) Setup a new HTTP server resource prefs->server->installed runtimes->add HTTP - suggest you define a prefix so that all your HTML projects get deployed into a specific directory mapped somewhere in local disk

2) Edit httpd.conf to setup new document root that map the prefix to some directory on your local HD

Now debug Tomcat JSP apps:

1) Get com.sysdeo.eclipse.tomcat_3.2.1 - copy into plugin directory
2) Start Eclipse and go to Preferences-> tomcat and configure the tomcathome plugin for 5.x
3) Pref->Server->Install runtime Apache Tomcat 5.5.x
4) Create HelloWorld.jsp using New->Project->Web->DynamicWeb

Debugging:
To-DO: how to run w external tomcat/deploy WARs to have well known

Optional: Eclipse cal also start tomcat within eclipse - in this case the content root is something like ~/eclipse_workspace/.metadata/.plugins/org.eclipse.wst.server.core


more details later..

Saturday, April 28, 2007

How-to use built-in webserver; Setup a English<->Chinese dict

First a simple example on how to sue the built-in apache and perl to setup a english-chinese web dictionary

1) Enable the Apache server System Pref->Sharing->Service->Personal Web Sharing

This will start the apache webserver - httpd.
Default cgi exe directory is /Library/WebServer/CGI-Executables
Uses default /etc/httpd/httpd.conf directory

You can now access the
-systemwide home page on http://ip-address and
-your personal homepage on http://ip-address/os-x-login-id/

2) Get the necessary chinese-english files to setup your web dictionary:
a) Program (1 perl file) from here Download the zip-file
b) Dictionary (large zipfile) from here
Unzip worklook.pl and cedict_tc.u8 into the cgi-directory
/Library/WebServer/CGI-Executables

3) Now access your offline dictionary in webbrowser via this url

Monday, March 05, 2007

Windows on OSX - Parallels Coherence - slick slick..

Parallels came out with an update late Feb that makes using the occasional windows app even more smooth within an OS X environment:

Basically you start the Parallels virtual machine and let it run in background (give it 256MB RAM or the like). When you need a windows app you click the dock window to access the XP start-menu. Every windows app will be displayed as an OSX window and you can access running windows apps in the dock just like OSX apps.. This is very slick. **

I have used it briefly and works well - I mainly used it for winword/powerpoint (coz Word4Mac still does not have a native intel app) and IE to test some websites for UI.

Screenshots/video here

** For most seamless experience configure Parallels+Windows this way:
a) Start and then use View->Coherence
b) View->Customize -> uncheck windows task bar. This way you have no task-bar and just the windows apps. If you for whatever reason temporary need task-bar just check this back.
c) IN Windoze turn OFF screensaver.
d) In Windoze setup a network drive (like X:) that access your OSX home folder (FileExplorer->MapNetWorkdDrive and enter \\\ and enter your password). PS This require your OSX has turned on Windows Sharing (Apple->SystemPref->Sharing->Windows Sharing checked)
Now whenever you work in windows simply use the X: drive and docs will be shared amongst both systems.

Friday, February 16, 2007

GPRS/3G modem using BlackJack and OS X

In previous post I listed the steps to get my HTC/ImateSP5/Dopod577 working as modem w OS X and tmobile. Now I am trying out the BlackJack from Cingular and with some googling and combination of various tips I got it to work using the USB cable - bluetooth not working yet..

Steps to make BlackJack work as 3G/GRPS modem using Cingular's service:

!!!NOTE: Make sure you have a all-inclusive dataplan from cingular or you will get a heartattack with your next phone bill.

  1. Download the Blackberry 3G Driver
  2. Unzip and copy the 3 Blackberry CID files into /Library/Modem Scripts
  3. Goto Start>Settings>Connections>USB on the Blackjack and change it to Modem
  4. Connect your Blackjack to your Macintosh via USB Cable
  5. Goto your Macintosh and select Apple>Location->Network Preferences.
  6. Pick Location Edit and "Add New Location" - call it whatever you like - for example "GPRS/3G via BlackJack"
  7. Go To the Show Edit and pick "Network port Config". In the edit below you should now see a "SAMSUNG CDMA TECHNOLOGIES". Select this and unselect everything else
  8. Go To the Show Edit and pick "SAMSUNG CDMA TECHNOLOGIES" - it will now enable you to configure TCP options. Select ppp tab and enter in
    1. WAP@CINGLARGPRS.COM <--USERNAME
    2. CINGULAR1 <---PASSWORD (and check the remember password"
    3. WAP.CINGULAR <--- TELEPHONE NUMBER
  9. In your PPP options check Send PPP echo packets and uncheck: Use TCP header compression. Uncheck redial if busy
  10. Goto Modem Tab and select Blackberry CID1 (this worked for me - if it doesn't for you try CID 3).
Now whenever you want to use your BlackJack as a modem simply
a) plug it in USB port and change modem setting as in step 3 above
b) go to Apple->Location->GPRS/3G via BlackJack

When you're finished make sure you change the USB setting on BlackJack back to "ActiveSync" else you syncing will not work.



Updates Mar '08: on WM6 can now use PAN - however I had to manually update my Blackjack registry settings to the below to make it work (original data from here: http://forum.xda-developers.com/showthread.php?t=297833&page=4):

The problem here is that some ROMs use a BT Personal Area Network profile rather than a BT Network Access Point profile by default. OS X 10.4.9 only supports NAP. I was able to get things working under WM VI BE 1.2 (planning to upgrade to 2.0 shortly) by modifying a few registry values. This should work with other WM6 builds, too.

Here's a complete listing of relevant keys:

[HKEY_LOCAL_MACHINE\Software\Microsoft\Bluetooth\l2 cap]
"ScanModeControl"=dword:1
"ConnectPacketType"=dword:0
"PicoCapable"=dword:0
"LinkPolicy"=dword:f
"NoRoleSwitch"=dword:1
"ConfigTimeout"=dword:78
"IdleConnect"=dword:a
"IdlePhys"=dword:a
"ERTX"=dword:12c
"RTX"=dword:3c

[HKEY_LOCAL_MACHINE\Software\Microsoft\Bluetooth\pa n]
"ActivateOnBoot"=dword:0
"Encrypt"=dword:1
"Authenticate"=dword:1
"InquiryLength"=dword:8
"MediaDelay"=dword:493e0

[HKEY_LOCAL_MACHINE\Comm\BTPAN]
"ImagePath"="btd.dll"
"Group"="NDIS"
"DisplayName"="Bluetooth PAN Driver"

[HKEY_LOCAL_MACHINE\Comm\BTPAN\Linkage]
"Route"=multi_sz:"BTPAN1

[HKEY_LOCAL_MACHINE\Comm\BTPAN1]
"ImagePath"="btd.dll"
"Group"="NDIS"
"DisplayName"="Bluetooth PAN Driver"

[HKEY_LOCAL_MACHINE\Comm\BTPAN1\Parms]
"PublishSdpOnBoot"=dword:1
"MaxConnections"=dword:1
"Description"="Bluetooth NAP Service"
"FriendlyName"="Network Access Point"
"ServiceId"="{00001116-0000-1000-8000-00805f9b34fb}"
"AdapterType"="NAP"
"ProtocolsToBindTo"=multi_sz:"NOT", "NDISUIO"
"AcceptConnections"=dword:1
"ConnectionTimeout"=dword:7530
"BusType"=dword:0
"BusNumber"=dword:0

[HKEY_LOCAL_MACHINE\Comm\BTPAN1\Parms\TcpIp]
"SubnetMask"="255.255.255.0"
"IpAddress"="192.168.0.1"
"UseZeroBroadcast"=dword:0
"DefaultGateway"=dword:0
"EnableDHCP"=dword:0

Here's some light reading: http://msdn2.microsoft.com/en-us/library/ms883411.aspx

Tuesday, February 13, 2007

VNC Server and Client for OSX and remote desktop options..

A quick summary of a setup for remote desktop for OSX..

OPTION 1 - Using VNC:
(note client and servers exist for every platform - if you're windoze client/server do a quick google or look here: http://www.realvnc.com/)

Server (you are sharing your screen):
==========
1) Get a free VNC server here: http://www.redstonesoftware.com/products/vine/server/
2) Do usual OS X install - drag to your Applications folder or wherever you store this type of apps
3) Start application. Recommended settings if YOU are the host and just want others to view (but NOT take control)
--Connection Tab: set a password (duh)
--Sharing tab: Disable remote control, Allow only oe VNC at a time (unless you're doing multi-client view)
4) Poke a hole in your firewall (assuming you are at home or behind some firewall)
--Use your router admin app to open and forward port for VNC (many have this predefined) or manualy 5500, 5800,5900 - forward to your PC's local IP


Client (used to view the screen of a server)
==========
1) get a FREE VNC client here http://sourceforge.net/projects/cotvnc/
(Or get a $$ client here http://www.redstonesoftware.com/products/vine/viewer/index.html - the redstone client has nice features like zoom, copy/pastem,etc..)
2) Install you clinet - same as step 2) for server
3) Start your client and connect to the externalIP for the network where your server run - typically get the external IP from the routers admin page (if you're advanced setup dyndns)

PROs: Works across all platforms - VNC client exist for almost any OS.
CONs: require to poke hole in server's firewall.



OPTION 2:
(later I'll add other options - there are fee and paid services....)