// function to get the current width of the window
function getWidth(){
var x = 0;
if (self.innerHeight){
x = self.innerWidth;
}else if (document.documentElement && document.documentElement.clientHeight){
x = document.documentElement.clientWidth;
}else if (document.body){
x = document.body.clientWidth;
}
return x;
}
// function to get the current height of the window
function getHeight(){
var y = 0;
if (self.innerHeight){
y = self.innerHeight;
}else if (document.documentElement && document.documentElement.clientHeight){
y = document.documentElement.clientHeight;
}else if (document.body){
y = document.body.clientHeight;
}
return y;
}
Wednesday, January 14, 2009
Javascript: Getting Current Window Dimension
Monday, October 06, 2008
System Admin: EDGE/GPRS via Bluetooth in Linux Simplified
Start with the same command,
$hcitool scan
We get some info
<code>Scanning ...<br /> 00:1D:FD:36:9E:DB 3110c Emerald<br /></code><br />Here "00:1D:FD:36:9E:DB" is the blue-tooth address of my phone.
Time to put this address into good use. We're going to bind this blue-tooth address with a specific device identifier.
$sudo rfcomm bind 0 00:1D:FD:36:9E:DB 1
Let me put some light into this command, the second argument in this command (in this case 0) is the device identifier, the third is the blue-tooth address (distinct for each device) and the fourth is the channel number which is typically 1.
After executing this command this mobile phone is directly accessible through /dev/rfcomm0
As said earlier, we are going to use
wvdial this time. But we need to do another trick.
$sudo ln -s /dev/rfcomm0 /dev/ttyS4
Now we just run
$sudo wvdialconf
You should see some output in the terminal
Editing `/etc/wvdial.conf'.
Scanning your serial ports for a modem.
ttyS0<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud
ttyS0<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 115200 baud
ttyS0<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up.
Modem Port Scan<*1>: S1 S2 S3
WvModem<*1>: Cannot get information for serial port.
ttyS4<*1>: ATQ0 V1 E1 -- OK
ttyS4<*1>: ATQ0 V1 E1 Z -- OK
ttyS4<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyS4<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyS4<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyS4<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyS4<*1>: Modem Identifier: ATI -- Nokia
ttyS4<*1>: Speed 4800: AT -- OK
ttyS4<*1>: Speed 9600: AT -- OK
ttyS4<*1>: Speed 19200: AT -- OK
ttyS4<*1>: Speed 38400: AT -- OK
ttyS4<*1>: Speed 57600: AT -- OK
ttyS4<*1>: Speed 115200: AT -- OK
ttyS4<*1>: Speed 230400: AT -- OK
ttyS4<*1>: Speed 460800: AT -- OK
ttyS4<*1>: Max speed is 460800; that should be safe.
ttyS4<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
Found a modem on /dev/ttyS4.
Modem configuration written to /etc/wvdial.conf.
ttyS4: Speed 460800; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
Open up /etc/wvdial.conf with your favourite text editor and add this line
Init3 = AT+CGDCONT=1,"IP","gpinternet"
Set phone number to
*99***1# and Username and Password to anything you like.At last run
$sudo wvdial
If you did everything right, you would see samilar output to this
--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Sending: AT+CGDCONT=1,"IP","gpinternet"
AT+CGDCONT=1,"IP","gpinternet"
OK
--> Modem initialized.
--> Sending: ATDT*99***1#
--> Waiting for carrier.
ATDT*99***1#
CONNECT
~[7f]}#@!}!} } }2}#}$@#}!}$}%\}"}&} }*} } g}%~
--> Carrier detected. Waiting for prompt.
~[7f]}#@!}!} } }2}#}$@#}!}$}%\}"}&} }*} } g}%~
--> PPP negotiation detected.
--> Starting pppd at Mon Oct 6 12:22:38 2008
--> Pid of pppd: 17504
--> Using interface ppp0
--> pppd: ا[06][08][08]�[06][08][08]�[06][08]
--> pppd: ا[06][08][08]�[06][08][08]�[06][08]
--> pppd: ا[06][08][08]�[06][08][08]�[06][08]
--> pppd: ا[06][08][08]�[06][08][08]�[06][08]
--> local IP address 10.130.11.226
--> pppd: ا[06][08][08]�[06][08][08]�[06][08]
--> remote IP address 10.6.6.6
--> pppd: ا[06][08][08]�[06][08][08]�[06][08]
--> primary DNS address 202.56.4.120
--> pppd: ا[06][08][08]�[06][08][08]�[06][08]
--> secondary DNS address 202.56.4.121
--> pppd: ا[06][08][08]�[06][08][08]�[06][08]
Fire up your browser and enjoy the net.
[Update: Some have reported that the DNS don't get updated automatically, in that case you might need to update /etc/resolv.conf file manually.]
Friday, September 12, 2008
MacOS X: iSync AppleScript
tell application "System Events" to set isync_running to (name of processes) contains "iSync"
<code><br />tell application "iSync"<br /> activate<br /> if isync_running is not true then<br /> tell application "System Events" to set visible of process "iSync" to false<br /> end if<br /> synchronize<br /><br /> repeat until syncing is false<br /> delay 1<br /> end repeat<br /><br /> if sync status is 2 then<br /> if isync_running is false then<br /> quit<br /> end if<br /> else<br /> activate<br /> end if<br />end tell<br /></code>
save the file with a .scpt extension and add the script in iCal to run every day.
Saturday, July 19, 2008
Tips: Run Linux apps in Mac OSX Seamlessly
I was a little sad to find out there is no such feature for Linux. Guess what, I was wrong. While I was fiddling with different ssh options, I came across a feature called X11 forwarding. With the use of X11 forwarding, its easy to accomplish the same effect. All you need is just add '-X' option while you ssh and make sure you have a working X11 environment installed in your Leopard.
$ssh -X zaher@172.16.90.128
Its as simple as that. After login, just run any graphical program you want like a native application. You can also disable X11 in your VM since it has the added benefit of using low memory than usual as no X11 us running in your Virtual Machine.
Here is a screenshot of Firefox, Gimp and OpenOffice.Org running from my Ubuntu Hardy Heron in Leopard.
Friday, July 18, 2008
Mission: Recover Disk Space: Part 2
I was able to about 2.8 Gigs from my last run, as I only kept English and Bengali localizations and Intel specific installations.
I love the icon of this app very much, :P
Mission: Recover Disk Space: Part 1
I installed OmniDiskSweeper and gave it run. I noted a folder called /cores which was taking a whooping 5.4Gigs. Suspicious, I looked it up and came to know that this is the folder where my Leopard keeps its memory dump files after any system crash for debugging purposes. Since it didn’t concern me, I just safely deleted these annoying core.xxxxx files to reclaim my precious 5.4 Gigs.
So if you are also running out of space, don’t forget to check that folder.
Thursday, July 03, 2008
Debug PHP scripts in Netbeans IDE
- Download and install “Early Access for PHP” bundle of Netbeans from http://download.netbeans.org/netbeans/6.1/final/ .
- Download and install an appropriate PHP-Mysql distro. I’m using MAMP in my Mac OS. Another good platform independent option is XAMPP.
- Download the appropriate version of xdebug from http://www.xdebug.org/ matching your php version (use phpinfo() in your web server to grab that). In my case there was no Mac OS binary, so I had to download the source. If you are downloading binary package then you can skip to step 7.
- Unpack the source and open a terminal in that folder.
- Now run [Note: make sure phpize and php-config is in your path]:
$phpize
$./configure --enable-xdebug
$make- A file called xdebug.so (in Linux and Mac OS) or xdebug.dll (Widows) will get created. If you have downloaded binary package, your package will contain this file.
- Now copy this file into the extension folder of your server. In my case it was like this
$cp modules/xdebug.so
/Applications/MAMP/bin/php5/lib/php/extensions- Now open your php.ini file and add entries for this new extension
zend_extension = "/Applications/MAMP/bin/php5/lib/php/extensions/xdebug.so"xdebug.remote_enable=1 - Now fire-up Netbeans and create/open your php project. Now insert a breakpoint by clicking anywhere in the left margin, now try to debug the file by selecting debug from context menu. You should see your web browser being fired and probably a blank web page. Now press F7 to step into your code and see it execute step by step. Try adding some watches. As the whole page finishes executing, you get to see the result in your web browser.
Happy Debugging!!!
Update 5 July 2008:
Just found out this link for configuring xdebug with netbeans in Ubunutu 8.04.
Back to Blogging
After a failed attempt last year to get back to blogging, I'm trying it again this year. I really wanted to get back, but got busy will...
-
For my Univ project, I need 2 use graphics.h. Everyone knows graphics.h is not in C's standard library. Only Turbo C supports it and for...
-
Normally, when we are coding java in Eclipse , we do not see any javadoc help when we hover over a keyword. This is because by default, ecli...
-
Make sure you have grub installed in the same partition as the Ubuntu, not in MBR. Now boot into any linux Live CD and do this: $sudo dd if=...