May 31, 2011
May 25, 2011
udp port forward
------
Option 1: user-application based udp port forwarding
Ivan Tikhonov wrote a simple udp_redirect.c program to do just this. I like it.
The link: http://brokestream.com/udp_redirect.html
-------------
Option 2 is to use iptables.
You will need to set the middle computer (Linux) to
1. NAT
2. port forward to the local computer
iptables -t nat -A POSTROUTING -j MASQUERADE -o eth0
iptables -t nat -A PREROUTING -p udp -i eth0 --dport 161 -j DNAT --to 192.168.1.10
Then set the local computer's default gateway to the middle computer:
route add default gw 192.168.1.100
------------
If you are looking for TCP port forwarding, I use and recommend the open source program rinetd. It works on both Windows and Linux, and supports multiple TCP connections, and is very stable. The link: http://www.boutell.com/rinetd/
Option 1: user-application based udp port forwarding
Ivan Tikhonov wrote a simple udp_redirect.c program to do just this. I like it.
The link: http://brokestream.com/udp_redirect.html
-------------
Option 2 is to use iptables.
You will need to set the middle computer (Linux) to
1. NAT
2. port forward to the local computer
iptables -t nat -A POSTROUTING -j MASQUERADE -o eth0
iptables -t nat -A PREROUTING -p udp -i eth0 --dport 161 -j DNAT --to 192.168.1.10
Then set the local computer's default gateway to the middle computer:
route add default gw 192.168.1.100
------------
If you are looking for TCP port forwarding, I use and recommend the open source program rinetd. It works on both Windows and Linux, and supports multiple TCP connections, and is very stable. The link: http://www.boutell.com/rinetd/
php internal server error
If you just see a blank page instead of an error reporting and you have no server access so you can't edit php configuration files like php.ini try this:
- create a new file in which you include the faulty script:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
include("file_with_errors.php");
?>
- execute this file instead of the faulty script file
now errors of your faulty script should be reported.
this works fine with me. hope it solves your problem as well!
May 20, 2011
Ubuntu Host, Windows 7 Guest, Raw disk, Virtual Box
Command in Ubuntu to create the win7 virtual machine using the raw disk Windows 7 partition that comes with the Dell computer.
This is tested on Virtual Box 4.0.4
Make sure you run everything as root
Make sure you use "IDE controller" type ICH6, otherwise the win7 will blue screen (BSOD)
This is based on the following blogs:
http://www.rajatarya.com/website/taming-windows-virtualbox-vm
http://www.researchut.com/site/virtualbox-native-partition
First install Virtualbox. I found it easier to install it using the "all platform" exectuable. Make sure you also download and install the Oracle Extension Package, which is installed using this command:
VBoxManage extpack install Extention_file_name
Then do the following commands: make sure you are root, and you are at "/root".
----------------
VBoxManage createvm --name win7 --ostype Windows7_64 --register
VBoxManage modifyvm "win7" --memory 1024 --acpi on --boot1 disk --nic1 nat
VBoxManage storagectl "win7" --name "IDE Controller" --add ide --controller ICH6
VBoxManage internalcommands createrawvmdk -filename /root/win7.vmdk -rawdisk /dev/sda -partitions 1,2,3 -mbr /root/vm.mbr -relative
VBoxManage storageattach win7 --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium /root/win7.vmdk
------ Other useful commands------------
vboxmanage unregistervm win7 --delete
VBoxManage storageattach win7 --storagectl "IDE Controller" --port 0 --device 1 --type dvddrive --medium "/root/Windows 7 64-bit Repair Disc.iso"
VBoxManage storageattach win7 --storagectl "IDE Controller" --port 0 --device 1 --type dvddrive --medium /opt/VirtualBox/additions/VBoxGuestAdditions.iso
vboxmanage controlvm win7 reset
----If you still cannot boot your Windows 7, try to use the Windows 7 Rescue image to fix it. Use the above "vboxmanage" command to attach the repair disk ISO file and hit F12 when vbox boots to boot from CD, let it fixes it and then boot to regular Win7
This is tested on Virtual Box 4.0.4
Make sure you run everything as root
Make sure you use "IDE controller" type ICH6, otherwise the win7 will blue screen (BSOD)
This is based on the following blogs:
http://www.rajatarya.com/website/taming-windows-virtualbox-vm
http://www.researchut.com/site/virtualbox-native-partition
First install Virtualbox. I found it easier to install it using the "all platform" exectuable. Make sure you also download and install the Oracle Extension Package, which is installed using this command:
VBoxManage extpack install Extention_file_name
Then do the following commands: make sure you are root, and you are at "/root".
----------------
VBoxManage createvm --name win7 --ostype Windows7_64 --register
VBoxManage modifyvm "win7" --memory 1024 --acpi on --boot1 disk --nic1 nat
VBoxManage storagectl "win7" --name "IDE Controller" --add ide --controller ICH6
VBoxManage internalcommands createrawvmdk -filename /root/win7.vmdk -rawdisk /dev/sda -partitions 1,2,3 -mbr /root/vm.mbr -relative
VBoxManage storageattach win7 --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium /root/win7.vmdk
------ Other useful commands------------
vboxmanage unregistervm win7 --delete
VBoxManage storageattach win7 --storagectl "IDE Controller" --port 0 --device 1 --type dvddrive --medium "/root/Windows 7 64-bit Repair Disc.iso"
VBoxManage storageattach win7 --storagectl "IDE Controller" --port 0 --device 1 --type dvddrive --medium /opt/VirtualBox/additions/VBoxGuestAdditions.iso
vboxmanage controlvm win7 reset
----If you still cannot boot your Windows 7, try to use the Windows 7 Rescue image to fix it. Use the above "vboxmanage" command to attach the repair disk ISO file and hit F12 when vbox boots to boot from CD, let it fixes it and then boot to regular Win7
May 19, 2011
May 18, 2011
Headless Virtualbox on Ubuntu 10.04 LTS
Updated Scripts (06/07/2012):
VBoxManage createvm -name centos6 --ostype RedHat -register
VBoxManage modifyvm centos6 --memory 1024 --pae on --acpi on --boot1 dvd --nic1 nat --natpf1 "guestssh,tcp,,2222,,22"
To enable VRDE:
VBoxManage modifyvm centos6 --vrde on --vrdeport 3392
To add the second interface as bridged interface:
Original Post:
http://tuxnetworks.blogspot.com/2010/05/howto-virtualbox-31-headless-on-lucid.html
That's it, Virtualbox should be installed and ready to go.
Now we can move on to creating a virtual machine
Create a machine named "io"
Configure it with a nic bridged to eth0, 256Mb RAM, enable acpi and set to boot from DVD
Create a virtual IDE controller
Create a virtual HDD
Attach the virtual HDD
Create and attach a virtual DVD drive to the controller and insert the DVD image
The default vrdp port for machines is 3389, however, if you intend to run more than one guest then each one will need to listen on a different port. I use the 3xxx range with the xxx being the last octet of the machines IP address. For example, 192.168.0.1 would be 3001.
And thats it, your machine has been created. Time to start it up and give it a test drive!
Using the virtual machine
Start the machine
On a GUI workstation, establish a remote desktop connection to the machine. In my case, the host server is called "jupiter" so I type;
After you have installed the OS, you need to tell the machine to boot from the hdd.
You can also deregister the dvd image if you don't intend to use it again.
To Stop VM/Hibernate/Save Sate:
vboxmanage controlvm centos6 savestate
Here are some other useful commands;
VBoxManage createvm -name centos6 --ostype RedHat -register
VBoxManage modifyvm centos6 --memory 1024 --pae on --acpi on --boot1 dvd --nic1 nat --natpf1 "guestssh,tcp,,2222,,22"
VBoxManage modifyvm centos6 --natpf1 "www,tcp,,1888,,80"
VBoxManage storagectl centos6 --name IDE0 --add ide --controller ICH6
VBoxManage createhd -filename ~/centos6/sda.vdi -size 20000
VBoxManage storageattach centos6 --storagectl IDE0 --port 0 --device 0 --type hdd --medium ~/centos6/sda.vdi
VBoxManage storageattach centos6 --storagectl IDE0 --port 1 --device 0 --type dvddrive --medium ~/bigfiles/CentOS-6.2-i386-minimal.iso
To enable VRDE:
VBoxManage modifyvm centos6 --vrde on --vrdeport 3392
After installation is finished, boot hdd:
VBoxManage modifyvm centos6 --boot1 disk
To add hostonly interface:
# sudo tunctl -u $USER # add tap0 device
# sudo ifconfig tap0 192.168.100.1 netmask 255.255.255.0
VBoxManage modifyvm centos6 --nic2 hostonly --hostonlyadapter2 tap0
To add the second interface as bridged interface:
VBoxManage modifyvm centos6 --nic2 bridged --bridgeadapter2 eth0
Original Post:
http://tuxnetworks.blogspot.com/2010/05/howto-virtualbox-31-headless-on-lucid.html
That's it, Virtualbox should be installed and ready to go.
Now we can move on to creating a virtual machine
Create a machine named "io"
VBoxManage createvm -name io --ostype Ubuntu -register
Configure it with a nic bridged to eth0, 256Mb RAM, enable acpi and set to boot from DVD
VBoxManage modifyvm io --memory 256 --pae on --acpi on --boot1 dvd --nic1 bridged --bridgeadapter1 eth0
Create a virtual IDE controller
VBoxManage storagectl io --name IDE0 --add ide
Create a virtual HDD
VBoxManage createvdi -filename ~/.VirtualBox/Machines/io/sda.vdi -size 48000 -register
Attach the virtual HDD
VBoxManage storageattach io --storagectl IDE0 --port 0 --device 0 --type hdd --medium ~/.VirtualBox/Machines/io/sda.vdi
Create and attach a virtual DVD drive to the controller and insert the DVD image
VBoxManage storageattach io --storagectl IDE0 --port 1 --device 0 --type dvddrive --medium /store/archive/ISO/ubuntu-10.04-server-i386.iso
The default vrdp port for machines is 3389, however, if you intend to run more than one guest then each one will need to listen on a different port. I use the 3xxx range with the xxx being the last octet of the machines IP address. For example, 192.168.0.1 would be 3001.
VBoxManage modifyvm io --vrdpport 3001
And thats it, your machine has been created. Time to start it up and give it a test drive!
Using the virtual machine
Start the machine
nohup VBoxHeadless -startvm io &
On a GUI workstation, establish a remote desktop connection to the machine. In my case, the host server is called "jupiter" so I type;
rdesktop -a 8 jupiter:3001
After you have installed the OS, you need to tell the machine to boot from the hdd.
VBoxManage modifyvm io --boot1 disk
You can also deregister the dvd image if you don't intend to use it again.
VBoxManage unregisterimage dvd /store/archive/ISO/ubuntu-10.04-server-i386.iso
To Stop VM/Hibernate/Save Sate:
vboxmanage controlvm centos6 savestate
To Power Off VM:
vboxmanage controlvm centos6 poweroff
Here are some other useful commands;
VBoxManage showvminfo io VBoxManage list hdds VBoxManage list runningvms VBoxManage controlvm io poweroff VBoxManage unregistervm io --delete VBoxManage controlvm io savestate VBoxManage closemedium disk UUID VBoxManage modifyhd UUID --type immutable
May 17, 2011
Linux Command Line FTP/HTTP segemented download accelartor software
aria2c
axel
lftp (use the "pget" command of lftp)
ari2c and axel supports FTP, HTTP and HTTPS, while lftp supports more protocols such as FTPS, SFTP, etc.
May 16, 2011
/etc/hosts not working?
If you have a Linux machine and your /etc/hosts is not working, make sure you have a file called
/etc/nsswitch.conf
with the following content: passwd: files group: files hosts: files dns networks: files dns services: files protocols: files netmasks: files
May 13, 2011
Windows CE 5.0 QFE download
Microsoft has moved on to Windows CE 7 (Compact 7) and revamped their download site so that all the windows CE 5.0 downloads cannot be located anymore.
To patch your platform builder 5.0 to the latest, download the "rollup" files from here:
http://www.microsoft.com/windowsembedded/en-us/downloads/download-windows-embedded-ce-5.aspx
Once you installed any QFE, you will have a application called CEQFECHECK.exe under C:\WINDOWS\system32\ceqfecheck. This application checks which QFE you have installed and did not install. Check it out.
To patch your platform builder 5.0 to the latest, download the "rollup" files from here:
http://www.microsoft.com/windowsembedded/en-us/downloads/download-windows-embedded-ce-5.aspx
Once you installed any QFE, you will have a application called CEQFECHECK.exe under C:\WINDOWS\system32\ceqfecheck. This application checks which QFE you have installed and did not install. Check it out.
May 5, 2011
Linux Network Interface statistics
http://stackoverflow.com/questions/596590/how-can-i-get-the-current-network-interface-throughput-statistics-on-linux-unix
Tools include:
1. bwm-ng
2. iftop
3. iptraf
4. sar
5. dstat
Tools include:
1. bwm-ng
2. iftop
3. iptraf
4. sar
5. dstat
April 18, 2011
jQuery TableSorter "o is undefined" problem
If you use jQuery TableSorter and see the "o is undefined" problem, it is the probably the case that you are using "<td>" inside the <thead> section instead of <th>. Use <th> and you will be good.
March 17, 2011
sqlite pdo write lock problem solved
When using PHP and PDO to access an sqlite dababase, and when you do a "select *" using the $handle->query($sqlcmd), you must use "foreach" to read all the select results before you can issue the next "query" or "exec" call. Otherwise, the database will be locked.
March 4, 2011
Win32 applications GUI vs Console
This web page explains well the difference between a WIN32 GUI app vs. Console app.
March 3, 2011
php header redirect IE issue
In web development, a HTTP POST is often processed on the server ending with a header("Location:page.php") call, so that user can refresh their page without re-posting. This usually works well.
The only issue is IE. After posting or file upload, using the PHP header() call won't work with IE, although it works with Firefox. You will have to use the HTML direct instead.
The only issue is IE. After posting or file upload, using the PHP header() call won't work with IE, although it works with Firefox. You will have to use the HTML direct instead.
February 9, 2011
Windows CE ssh server and client
Windows CE development is not as fun as Linux because of the lack of open source tools. However, once I am able to make ssh server and client running on it, it becomes better. Here is how to get ssh server and client running on windows CE 5 (ARM based):
1. Download CESSH at http://www.codeplex.com/wikipage?projectname=CESSH
Download sshd_config at http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=CESSH&DownloadId=3561
Download file http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=CESSH&DownloadId=3562
2. copy the files to your windows CE device, suppose "\ssh"
3. mkdir "\Hard Disk"
4. copy sshd_config "\Hard Disk"
5. mkdir "\NandFlash"
6. mkdir "\NandFlash\ssh"
7. copy ssh_host_dsa_key to "\NandFlash\ssh"
8. run "adduser.exe root rootpass" to add the user "root" with password "rootpass"
9. copy SocketToFile.DLL to \windows
10. run "sshd.exe"
To test it, get pocketputty
(http://www.pocketputty.net/download.html)
If make this work over ActiveSync, use the remote port tunnel in putty.
Another great tool to have is netcat for CE: http://www.dr-bischoff.de/wince/Andreas_WINCE_stuff.html#netcat
Hope this helps.
1. Download CESSH at http://www.codeplex.com/wikipage?projectname=CESSH
Download sshd_config at http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=CESSH&DownloadId=3561
Download file http://www.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=CESSH&DownloadId=3562
2. copy the files to your windows CE device, suppose "\ssh"
3. mkdir "\Hard Disk"
4. copy sshd_config "\Hard Disk"
5. mkdir "\NandFlash"
6. mkdir "\NandFlash\ssh"
7. copy ssh_host_dsa_key to "\NandFlash\ssh"
8. run "adduser.exe root rootpass" to add the user "root" with password "rootpass"
9. copy SocketToFile.DLL to \windows
10. run "sshd.exe"
To test it, get pocketputty
(http://www.pocketputty.net/download.html)
If make this work over ActiveSync, use the remote port tunnel in putty.
Another great tool to have is netcat for CE: http://www.dr-bischoff.de/wince/Andreas_WINCE_stuff.html#netcat
Hope this helps.
February 4, 2011
Slick board and XML/SWF charts
SlickBoard and XML/SWF charts seem like very great products. Let me know if you have used it.
And also the google visualization tools which give you access to google finance like charts (http://code.google.com/apis/visualization/documentation/gallery/annotatedtimeline.html)
And also the google visualization tools which give you access to google finance like charts (http://code.google.com/apis/visualization/documentation/gallery/annotatedtimeline.html)
January 28, 2011
January 27, 2011
git, cgit and mini_httpd
git allows very easy local installation. We need a easy way to view the local git repository. mini_httpd is a great local web server to use, and git web app can either be "gitweb" or "cgit".
I tried "gitweb" but couldn't get it to see my projects. But I got "cgit" to work well. Here is how:
1. download and compile cgit. very simple, just follow the README file.
2. change cgit Makefile, "CGIT_CONFIG = /yourpath/cgitrc", then "touch cgit.c" and "make" again. We do this because by default cgitrc is located at /etc/ and we want it local.
3. Create your cgitrc file from the example file. I use something like this:
I tried "gitweb" but couldn't get it to see my projects. But I got "cgit" to work well. Here is how:
1. download and compile cgit. very simple, just follow the README file.
2. change cgit Makefile, "CGIT_CONFIG = /yourpath/cgitrc", then "touch cgit.c" and "make" again. We do this because by default cgitrc is located at /etc/ and we want it local.
3. Create your cgitrc file from the example file. I use something like this:
cache-size=0 css=/cgit.css enable-index-links=1 enable-log-filecount=1 enable-log-linecount=1 max-stats=quarter root-title=My git repository root-desc=Tracking my project development root-readme=about.html snapshots=tar.gz mimetype.git=image/git mimetype.html=text/html mimetype.jpg=image/jpeg mimetype.jpeg=image/jpeg mimetype.pdf=application/pdf mimetype.png=image/png mimetype.svg=image/svg+xml repo.url=linux repo.path=/opt/gittest/.git repo.desc=My project repo.owner=me@me.com repo.readme=info/web/about.html repo.snapshots=tar.gz repo.enable-log-linecount=0 repo.max-stats=month4. start minihttpd and your are in business. :-)
January 26, 2011
Vim non greedy regular expression search
* (0 or more) greedy matching
\+ (1 or more) greedy matching
\{-} (0 or more) non-greedy matching
\{-n,} (at least n) non-greedy matchinghttp://blog.vinceliu.com/2008/02/non-greedy-regular-expression-matching.html
CSS Positioning explained
http://www.barelyfitz.com/screencast/html-training/css/positioning/
Simple truth:
1. Use positon:relative in the outer box and then positoin:absolute in the inner box. This is very effective.
2. When using position:absolute with background image, make sure you explicitly specify "width" and "height", otherwise it won't work.
Simple truth:
1. Use positon:relative in the outer box and then positoin:absolute in the inner box. This is very effective.
2. When using position:absolute with background image, make sure you explicitly specify "width" and "height", otherwise it won't work.
Subscribe to:
Posts (Atom)
ioctl[IEEE80211_IOCTL_DELKEY]: Invalid argument
ioctl[IEEE80211_IOCTL_SETMLME]: Invalid argument
Try to add :
in hostapd.conf
This is documented in http://madwifi-project.org/ticket/1561 and it worked for me.