I have upgraded my eeePC to Ubuntu Karmic for quite some time and I miss my muti-touch, especially when I have been using Mac OS recently. Thus my quest to enable it begins. After googling around, I realized that it can be very simple.
To enable 2 finger scrolling, do the following.
Activate at "System -> Preferences -> Mouse -> Touchpad -> Scrolling -> Two-finger scrolling"
According to https://wiki.ubuntu.com/HardwareSupport/Machines/Netbooks#Asus Eee PC 1005HA , you need to install a script from the following,
http://blog.twinapex.fi/2009/10/11/setting-up-multi-touch-scrolling-for-ubuntu-9-10-karmic-koala-linux-on-asus-eee-1005ha-netbook/
however, my works when I have enable the 2 finger scrolling. Wonder what does that script do.
Wednesday, February 17, 2010
Wednesday, January 27, 2010
eeepc refuse to boot
One day, my eeepc refuse to boot when I was playing with MacOS installation. It keep stuck @ the blank screen. After sending to the service center, they revived my eeepc. few hours later, i killed it again.
So instead of sending it back again, I decided to solve it myself. After googling and also from the TIPS from the engineers, I know I need to reset something but duno what. After dismantle the whole machine and also google around, the below is the steps to recover.
1. Take out battery and power cable
2. Press power button for 15-20s (different source got different timing, I guess the longer the better)
3. Locate the CMOS "button". It is a two trangle shape, just below the RAM, you need to take out the RAM cover and the RAM itself. You should see two triangle side by side.
4. Short the CMOS with a paper clip.
Put everything back and restart. It should work.
So instead of sending it back again, I decided to solve it myself. After googling and also from the TIPS from the engineers, I know I need to reset something but duno what. After dismantle the whole machine and also google around, the below is the steps to recover.
1. Take out battery and power cable
2. Press power button for 15-20s (different source got different timing, I guess the longer the better)
3. Locate the CMOS "button". It is a two trangle shape, just below the RAM, you need to take out the RAM cover and the RAM itself. You should see two triangle side by side.
4. Short the CMOS with a paper clip.
Put everything back and restart. It should work.
Tuesday, January 5, 2010
It is possible to recover data from brick iPhone!
My iPhone brick after installing Tethering from Sinful and I have not back up for a very long. Sad to say, there is no other way except to RESTORE! :(
But, to recover the file, there is always Linux to the rescue!
1. Restore iPhone using iTune
2. Use blackra1n to jailbreak
3. Install Cydia in the iPhone
4. After launch Cydia, you will need to wait a while for it to be ready.
5. When done, install OpenSSH, BSD Subsystem and Terminal
6. Launch Terminal in the iPhone
7. change to root first,
duck:~ mobile$ su
duck:/ root#
8. Make sure you have a SSH server running on your desktop
9. Execute DD from the iPhone and make a disk image over
duck:/ root# dd if=/dev/disk0 | ssh username@mydesktop-ip 'dd of=iphone-dump.img'
10.Next use software such as photorec, scalpel, foremost
[Update]
1. Due to my iPhone wifi problem, I have access the iPhone through USB tethering on a Windows machine. Google around for the software. Once the USB tethering is setup, you can access to the iPhone from your Linux desktop.
ssh root@192.168.1.1 'dd if=/dev/disk0' | dd of=iphone.img
2. After DD out the files, I realize I am DD out the whole disk which I am not able to mount as one drive, however data can still be recoverable with that image. There are two partitions in the iPhone. The best way is to DD out separately and also as a whole, cos you never know how they are repartition after restored, which comes to the next point.
3. SSD is written randomly, unlike using normal harddisk, after one large file(s) is deleted, iPhone will not write from the first free space. It will write as random. What does this means? It means your old deleted data may be overwritten during restoration. This happens to me as I am not able to fully recovered my photos. However, I believe some of the header are gone but we still can recover from the remaining data, provided I know how to reconstruct them. More research is needed.
But, to recover the file, there is always Linux to the rescue!
1. Restore iPhone using iTune
2. Use blackra1n to jailbreak
3. Install Cydia in the iPhone
4. After launch Cydia, you will need to wait a while for it to be ready.
5. When done, install OpenSSH, BSD Subsystem and Terminal
6. Launch Terminal in the iPhone
7. change to root first,
duck:~ mobile$ su
duck:/ root#
8. Make sure you have a SSH server running on your desktop
9. Execute DD from the iPhone and make a disk image over
duck:/ root# dd if=/dev/disk0 | ssh username@mydesktop-ip 'dd of=iphone-dump.img'
10.Next use software such as photorec, scalpel, foremost
[Update]
1. Due to my iPhone wifi problem, I have access the iPhone through USB tethering on a Windows machine. Google around for the software. Once the USB tethering is setup, you can access to the iPhone from your Linux desktop.
ssh root@192.168.1.1 'dd if=/dev/disk0' | dd of=iphone.img
2. After DD out the files, I realize I am DD out the whole disk which I am not able to mount as one drive, however data can still be recoverable with that image. There are two partitions in the iPhone. The best way is to DD out separately and also as a whole, cos you never know how they are repartition after restored, which comes to the next point.
3. SSD is written randomly, unlike using normal harddisk, after one large file(s) is deleted, iPhone will not write from the first free space. It will write as random. What does this means? It means your old deleted data may be overwritten during restoration. This happens to me as I am not able to fully recovered my photos. However, I believe some of the header are gone but we still can recover from the remaining data, provided I know how to reconstruct them. More research is needed.
Sunday, November 8, 2009
Credit Card Validator in C#
Credit Card Validator in C#
I needed a credit card validator for a few of my projects. I found a few snippets of code throughout google, but nothing really just giving me what I needed, so I wanted to post my class. Maybe it will help others doing the same thing I did.
public class CardValidator
{
public string CardType { get; private set; }
public bool IsValid { get; private set; }
public string ResultingError { get; private set; }
public string CardNumber { get; set; }
public DateTime CardExpiration { get; set; }
public void Validate()
{
IsValid = false;
if (string.IsNullOrEmpty(CardNumber))
{
ResultingError = "Card number empty....";
return;
}
if (CardNumber.Length > 16)
{
ResultingError = "Card number too long";
return;
}
foreach (char digit in CardNumber)
{
if (!char.IsDigit(digit))
{
ResultingError = "Card number contains invalid characters";
return;
}
}
if (CardExpiration < DateTime.Now)
{
ResultingError = "Card has expired.";
return;
}
int sum = 0;
for (int i = CardNumber.Length - 1; i >= 0; i--)
{
if (i % 2 == CardNumber.Length % 2)
{
int n = int.Parse(CardNumber.Substring(i, 1)) * 2;
sum += (n / 10) + (n % 10);
}
else
{
sum += int.Parse(CardNumber.Substring(i, 1));
}
}
IsValid = (sum % 10 == 0);
if (IsValid == true)
{
switch (CardNumber.Substring(0, 1))
{
case "3":
CardType = "AMEX/Diners Club/JCB";
break;
case "4":
CardType = "VISA";
break;
case "5":
CardType = "MasterCard";
break;
case "6":
CardType = "Discover";
break;
default:
CardType = "Unknown";
break;
}
}
else
{
CardType = "Invalid";
}
}
}
Credits to http://volatile-minds.blogspot.com/2009/11/credit-card-validator-in-c.html
I needed a credit card validator for a few of my projects. I found a few snippets of code throughout google, but nothing really just giving me what I needed, so I wanted to post my class. Maybe it will help others doing the same thing I did.
public class CardValidator
{
public string CardType { get; private set; }
public bool IsValid { get; private set; }
public string ResultingError { get; private set; }
public string CardNumber { get; set; }
public DateTime CardExpiration { get; set; }
public void Validate()
{
IsValid = false;
if (string.IsNullOrEmpty(CardNumber))
{
ResultingError = "Card number empty....";
return;
}
if (CardNumber.Length > 16)
{
ResultingError = "Card number too long";
return;
}
foreach (char digit in CardNumber)
{
if (!char.IsDigit(digit))
{
ResultingError = "Card number contains invalid characters";
return;
}
}
if (CardExpiration < DateTime.Now)
{
ResultingError = "Card has expired.";
return;
}
int sum = 0;
for (int i = CardNumber.Length - 1; i >= 0; i--)
{
if (i % 2 == CardNumber.Length % 2)
{
int n = int.Parse(CardNumber.Substring(i, 1)) * 2;
sum += (n / 10) + (n % 10);
}
else
{
sum += int.Parse(CardNumber.Substring(i, 1));
}
}
IsValid = (sum % 10 == 0);
if (IsValid == true)
{
switch (CardNumber.Substring(0, 1))
{
case "3":
CardType = "AMEX/Diners Club/JCB";
break;
case "4":
CardType = "VISA";
break;
case "5":
CardType = "MasterCard";
break;
case "6":
CardType = "Discover";
break;
default:
CardType = "Unknown";
break;
}
}
else
{
CardType = "Invalid";
}
}
}
Credits to http://volatile-minds.blogspot.com/2009/11/credit-card-validator-in-c.html
Sunday, November 1, 2009
install ubuntu without cd
netboot
install bootp
vim /etc/bootptab
bootp start file
install bootp
vim /etc/bootptab
client:\
ha="00:22:15:75:BC:B1":\
ip=192.168.3.107:\
gw=192.168.3.1:\
sm=255.255.255.0:\
td=/: hd=/: bf=pxelinux.0
bootp start file
vDaemon=bootpd
vCd=/var/lib/tftpboot
Start () {
echo -n "Starting $vDaemon: default current directory is at $vCd ... :"
/usr/sbin/$vDaemon -d 4 -c $vCd >/tmp/$vDaemon.log 2>/tmp/$vDaemon.err &
sleep 1
Status
}
Stop () {
echo "Stopping $vDaemon ..."
kill `pidof $vDaemon`
}
Reload () {
if [ "`pidof $vDaemon`" ] ; then
echo "Reloading config file for $vDaemon ..."
kill -HUP "`pidof $vDaemon`"
fi
Status
}
Status () {
vPid="`pidof $vDaemon`"
if [ "$vPid" ] ; then
echo "$vDaemon running, pid=$vPid"
else
echo "$vDaemon not running"
fi
}
case "$1" in
start) Start ;;
stop) Stop ;;
reload) Reload ;;
restart) Stop ; sleep 2; Start ;;
status) Status ;;
""|*) echo `basename $0` parameter: start stop status reload or restart ;;
esac
Thursday, September 10, 2009
Setting for SSD
Four Tweaks for Using Linux with Solid State DrivesPublished in September 4th, 2008 Posted by Tom in tips
SSDs (solid state drives) are great. They’re shock resistant, consume less power, produce less heat, and have very fast seek times. If you have a computer with an SSD, such as an Eee PC, there are some tweaks you can make to increase performance and extend the life of the disk.
The simplest tweak is to mount volumes using the noatime option. By default Linux will write the last accessed time attribute to files. This can reduce the life of your SSD by causing a lot of writes. The noatime mount option turns this off.
Open your fstab file:
sudo gedit /etc/fstab
Ubuntu uses the relatime option by default. For your SSD partitions (formatted as ext3), replace relatime with noatime in fstab. Reboot for the changes to take effect.
Using a ramdisk instead of the SSD to store temporary files will speed things up, but will cost you a few megabytes of RAM.
Open your fstab file:
sudo gedit /etc/fstab
Add this line to fstab to mount /tmp (temporary files) as tmpfs (temporary file system):
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
Reboot for the changes to take effect. Running df, you should see a new line with /tmp mounted on tmpfs:
tmpfs 513472 30320 483152 6% /tmp
Firefox puts its cache in your home partition. By moving this cache in RAM you can speed up Firefox and reduce disk writes. Complete the previous tweak to mount /tmp in RAM, and you can put the cache there as well.
Open about:config in Firefox. Right click in an open area and create a new string value called browser.cache.disk.parent_directory. Set the value to /tmp.
An I/O scheduler decides which applications get to write to the disk when. Because SSDs are so different than a spinning hard drive, not all I/O schedulers work well with SSDs.
The default I/O scheduler in Linux is cfq, completely fair queuing. cfq is works well on hard disks, but I’ve found it to cause problems on my Eee PC’s SSD. While writing a large file to disk, any other application which tries to write hang until the other write finishes.
The I/O scheduler can be changed on a per-drive basis without rebooting. Run this command to get the current scheduler for a disk and the alternative options:
cat /sys/block/sda/queue/scheduler
You’ll probably have four options, the one in brackets is currently being used by the disk specified in the previous command:
noop anticipatory deadline [cfq]
Two of these are better suited to SSD drives: noop and deadline. Using one of these in the same situation, the application will still hang but only for a few seconds instead of until the disk is free again. Not great, but much better than cfq.
Here’s how to change the I/O scheduler of a disk to deadline:
echo deadline > /sys/block/sda/queue/scheduler
(Note: the above command needs to be run as root, but sudo does not work with it on my system. Run sudo -i if you have a problem to get a root prompt.)
You can replace sda with the disk you want to change, and deadline with any of the available schedulers. This change is temporary and will be reset when you reboot.
If you’re using the deadline scheduler, there’s another option you can change for the SSD. This command is also temporary and also is a per-disk option:
echo 1 > /sys/block/sda/queue/iosched/fifo_batch
You can apply the scheduler you want to all your drives by adding a boot parameter in GRUB. The menu.lst file is regenerated whenever the kernel is updated, which would wipe out your change. Instead of this way, I added commands to rc.local to do the same thing.
Open rc.local:
sudo gedit /etc/rc.local
Put any lines you add before the exit 0. I added six lines for my Eee PC, three to change sda (small SSD), sdb (large SSD), and sdc (SD card) to deadline, and three to get the fifo_batch option on each:
echo deadline > /sys/block/sda/queue/scheduler
echo deadline > /sys/block/sdb/queue/scheduler
echo deadline > /sys/block/sdc/queue/scheduler
echo 1 > /sys/block/sda/queue/iosched/fifo_batch
echo 1 > /sys/block/sdb/queue/iosched/fifo_batch
echo 1 > /sys/block/sdc/queue/iosched/fifo_batch
Reboot to run the new rc.local file.
[update] Commenter dondad has pointed out that it’s possible to add boot parameters to menu.lst that won’t be wiped out by an upgrade. Open menu.lst (Remember to make a backup of this file before you edit it):
sudo gedit /boot/grub/menu.lst
The kopt line gives the default parameters to boot Linux with. Mine looks like this:
# kopt=root=UUID=6722605f-677c-4d22-b9ea-e1fb0c7470ee ro
Don’t uncomment this line. Just add any extra parameters you would like. To change the I/O scheduler, use the elevator option:
elevator=deadline
Append that to the end of the kopt line. Save and close menu.lst. Then you need to run update-grub to apply your change to the whole menu:
sudo update-grub
[end update]
Want to know how fast your SSD or other storage device is? Using hdparm you can test the read performance of your disk:
sudo hdparm -t /dev/sda
The 4 GB SSD on my Eee PC 901 gets about 33 MB/s. My desktop PC’s hard drive gets about 78 MB/s. (What hdparm doesn’t show is that the seek time for an SSD is much, much lower than a hard disk.)
Have any other suggestions for SSDs, or disagree with any of these? Leave a comment to let me know.
SSDs (solid state drives) are great. They’re shock resistant, consume less power, produce less heat, and have very fast seek times. If you have a computer with an SSD, such as an Eee PC, there are some tweaks you can make to increase performance and extend the life of the disk.
The simplest tweak is to mount volumes using the noatime option. By default Linux will write the last accessed time attribute to files. This can reduce the life of your SSD by causing a lot of writes. The noatime mount option turns this off.
Open your fstab file:
sudo gedit /etc/fstab
Ubuntu uses the relatime option by default. For your SSD partitions (formatted as ext3), replace relatime with noatime in fstab. Reboot for the changes to take effect.
Using a ramdisk instead of the SSD to store temporary files will speed things up, but will cost you a few megabytes of RAM.
Open your fstab file:
sudo gedit /etc/fstab
Add this line to fstab to mount /tmp (temporary files) as tmpfs (temporary file system):
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
Reboot for the changes to take effect. Running df, you should see a new line with /tmp mounted on tmpfs:
tmpfs 513472 30320 483152 6% /tmp
Firefox puts its cache in your home partition. By moving this cache in RAM you can speed up Firefox and reduce disk writes. Complete the previous tweak to mount /tmp in RAM, and you can put the cache there as well.
Open about:config in Firefox. Right click in an open area and create a new string value called browser.cache.disk.parent_directory. Set the value to /tmp.
An I/O scheduler decides which applications get to write to the disk when. Because SSDs are so different than a spinning hard drive, not all I/O schedulers work well with SSDs.
The default I/O scheduler in Linux is cfq, completely fair queuing. cfq is works well on hard disks, but I’ve found it to cause problems on my Eee PC’s SSD. While writing a large file to disk, any other application which tries to write hang until the other write finishes.
The I/O scheduler can be changed on a per-drive basis without rebooting. Run this command to get the current scheduler for a disk and the alternative options:
cat /sys/block/sda/queue/scheduler
You’ll probably have four options, the one in brackets is currently being used by the disk specified in the previous command:
noop anticipatory deadline [cfq]
Two of these are better suited to SSD drives: noop and deadline. Using one of these in the same situation, the application will still hang but only for a few seconds instead of until the disk is free again. Not great, but much better than cfq.
Here’s how to change the I/O scheduler of a disk to deadline:
echo deadline > /sys/block/sda/queue/scheduler
(Note: the above command needs to be run as root, but sudo does not work with it on my system. Run sudo -i if you have a problem to get a root prompt.)
You can replace sda with the disk you want to change, and deadline with any of the available schedulers. This change is temporary and will be reset when you reboot.
If you’re using the deadline scheduler, there’s another option you can change for the SSD. This command is also temporary and also is a per-disk option:
echo 1 > /sys/block/sda/queue/iosched/fifo_batch
You can apply the scheduler you want to all your drives by adding a boot parameter in GRUB. The menu.lst file is regenerated whenever the kernel is updated, which would wipe out your change. Instead of this way, I added commands to rc.local to do the same thing.
Open rc.local:
sudo gedit /etc/rc.local
Put any lines you add before the exit 0. I added six lines for my Eee PC, three to change sda (small SSD), sdb (large SSD), and sdc (SD card) to deadline, and three to get the fifo_batch option on each:
echo deadline > /sys/block/sda/queue/scheduler
echo deadline > /sys/block/sdb/queue/scheduler
echo deadline > /sys/block/sdc/queue/scheduler
echo 1 > /sys/block/sda/queue/iosched/fifo_batch
echo 1 > /sys/block/sdb/queue/iosched/fifo_batch
echo 1 > /sys/block/sdc/queue/iosched/fifo_batch
Reboot to run the new rc.local file.
[update] Commenter dondad has pointed out that it’s possible to add boot parameters to menu.lst that won’t be wiped out by an upgrade. Open menu.lst (Remember to make a backup of this file before you edit it):
sudo gedit /boot/grub/menu.lst
The kopt line gives the default parameters to boot Linux with. Mine looks like this:
# kopt=root=UUID=6722605f-677c-4d22-b9ea-e1fb0c7470ee ro
Don’t uncomment this line. Just add any extra parameters you would like. To change the I/O scheduler, use the elevator option:
elevator=deadline
Append that to the end of the kopt line. Save and close menu.lst. Then you need to run update-grub to apply your change to the whole menu:
sudo update-grub
[end update]
Want to know how fast your SSD or other storage device is? Using hdparm you can test the read performance of your disk:
sudo hdparm -t /dev/sda
The 4 GB SSD on my Eee PC 901 gets about 33 MB/s. My desktop PC’s hard drive gets about 78 MB/s. (What hdparm doesn’t show is that the seek time for an SSD is much, much lower than a hard disk.)
Have any other suggestions for SSDs, or disagree with any of these? Leave a comment to let me know.
Sunday, September 6, 2009
HTC Magic Reloaded
Time to free ur magic.
http://wiki.xda-developers.com/index.php?pagename=HTC_Sapphire_Hacking
http://wiki.xda-developers.com/index.php?pagename=HTC_Sapphire_Hacking
Subscribe to:
Posts (Atom)
