sábado, 3 de enero de 2009

Automate and improving the web

Actually we use some pages like a desktop programs, Webmail as mail clients, some flavour of offices, dictionaries, etc...

But this web software hasn't enough features, functions, menus, etc as the desktop option, in some cases because a free web apps has advertisements and you must see it.

But we can solve these problems and program repetitive task, modify the showed text, appearance...

I've used two tools Chickenfoot and GreaseMonkey accompanied by our dear Firefox and a bit of Javascript knowledge (useful in pages with Javascript).

Our code or actions are transparent to the web server, however our code can interact with the web app, sending forms with our values, going links, opening new windows,...
Our code need to locate the html or Javascript code to interact with it, for it we can use DOM(Document Object Model) or XPath.

Mozilla Developer Centre:Javascript

Example of Chickenfoot code and a useful real case :

CF find all the "expand" links and click'em all

Example of Javascript function used in Chickenfoot:

Chickenfoot have functions to locate elements in a web page, such as find() but many times we must use javascript to locate the elements, so we should the following functions:

array=ref_window.document.getElementsByClassName(buscarpor) array=ref_window.document.getElementsByName(buscarpor)

Other positive thing about Chickenfoot vs Greasemonkey is access to local files (maybe it is insecure but it is so easy and useful for me):

  include ("fileio.js") 
 if (exists(file_origen)) { 
else output("ERROR !!!! fichero no existe") 

How to use JQuery

$ = window.$;
jQuery = window.jQuery;


jueves, 1 de enero de 2009

hacking the palm lifedrive

Procedure to replace MD(Hitachi Microdrive HD) for a CF II(compact flash memory) in a Palm LifeDrive.(aka LifeFlash mod)

The reasons for this modification are:

-Increase battery duration (more than double)
-Decrease weight of pda
-Increase resistance to blow (no mechanic parts)

Too many people lose their LD after a strong fall, this is because Palm Os is saved in Hard drive, and when it crash, LD don't work (using this mod the more weakly part in the pda will be the screen).


My method is based in Linux livecd(standalone linux), concretally Ubuntu/Kubuntu.
I read other docs about this modification and i decide to write a new one for help to newbies)

(All people in the world would have linux livecd, but if you haven't it you can free download or request from internet,
http://www.ubuntu.com/getubuntu )


1. Boot computer with linux livecd

2. Take a seeing of unit drive with qtparted (this app show us all computer drives, and my case LD has 3 partitions and the name /dev/sdc)

3. Open a terminal shell (like cmd, command mode in windows)

4. We need to have administrator rights (default: ubuntu give you less rights)
>sudo passwd
(we must put the password we want)
(Now ubuntu request us a passw, and this one is the password what we defined in previous step, now we are root or administrator, we have all rights)

5. Now we will make an image of MicroDrive(ld hd) and we store it in our "windows" partition.
(You need replace with you name device and the label of your partition).
>dd if=/dev/sdc of=/mnt/my_windowsxp/imageLD.img
(if=input file of=output file)
(It takes a lot of time (30min or more), you must wait to card reader light go off)

6. Replace MD from cardreader for CF memory card)

7. Execute the next command
>dd if=/mnt/my_windowsxp/imageLD.img of=/dev/sdc
(Now the source is our stored image, and target is the CF Device)

*NOTES /Recommendations:

-dd command, don't show a progress bar, because of it, we must have patiente and don't think that process is hang up, if it doesn't show an error is because the process is OK.

-/mnt/my_windowsxp this a mounted partition, normal UBUNTU automount all your partitions, BUT other linux distributions for example KUBUNTU do not automount the partitions and if you have no experience with linux could require more time to learn to mount partitions in my case with the following commands:
"mkdir /mnt/my_windowsxp"
"mount -t vfat /dev/hda5 /mnt/my_windowsxp"

-I don't recommend to lose time with windows, I tried some apps to make the image, for example Acronis True Image 10 home (true image cdbootloader don't detect MD in the card reader). I can make an image of the first partition 65mb but after it, the acronis show an error.

- Probably there are card readers which support CF mems but not md hitachi. (f.ex. card reader of a epson printer).

- I've used a SANDISK Xtreme III (expensiver than others brands), but because i wanted no risks, but now i think that many 4GB CF should run correctly. (CF mems simulates physical harddrives, and i think what should be possible to change its main structure, cylinders, heads, etc to adjust to MD structure). ***What do experts say about it? ***

>fdisk -l /dev/sdc (a commando to see the device partitions

Good luck!