Sunday, November 23, 2008

Downloading Photos from Orkut Album

Photo Download?
Orkut has done a good job in "trying" to prevent downloads from orkut photo albums. They have blocked right clicking. But using Firefox we can still download the photo (ie If you can see the photo, you can download)

Drag drop the photo to the URL (Address Bar) and then save the page.
(works for both IE and Firefox)

-OR-

These are the steps for Firefox alone:

  • Browse to the appropriate Photo / Album

  • Now select Tools > Page Info

  • Click on Media, and in the list search for the photo, and Press Save As (Right of the Media Preivew Label)




TADA: Thats all!

Tuesday, November 18, 2008

Digitalpbk is now 2 years old

Another year passes and digitalpbk is now 2 years!! Happy Birthday today...
And the stats till now goes as ..

231000+ Visitors...
112 Posts
300+ Comments I dint count ;)

Thank you world!
Keep clicking..
.digitalpbk.

8086 Assembly Language Program to find the factorial upto 255!

Intro
The following assembly language program is for MASM 5.1 up calculates factorial of numbers upto 255!, that is quite a large number to compute a factorial. See below:


Number:255
Factorial
3350850684932979117652665123754814942022
5840635917407025767798842862087990357327
7100562613812676331425928080211850228244
5926550135522251856727692533193070412811
0833303256593220417000297921662507342533
9051375446604571124033846270103402026299
2581378423147276636643647155396305352541
1055414394348401099150682854306750685916
3858198060416294038335658673919826878210
4924614076605793562865241982176207428620
9697768031494674313868079724382476891586
5600000000000000000000000000000000000000
0000000000000000000000000


for the Faint Hearted
The program calculates and computes big numbers by simulating the traditional way of multiplication and division of numbers. Hence it can do this upto any number of digits as much as the memory can hold. In this example, I have used 512 digited numbers, which is more than enough for holding 255!.

The key parts of the following program is bignum_mul and bignum_add macro which simulates the traditional method of multiplying and adding numbers (not using any vedic maths, which can certainly improve the efficiency I guess).

The following is the assembly language program, try digesting...

.asm Program

data segment
b1 db 512 dup(0)
b2 db 512 dup(0)
msg db 0dh,0ah,"Number:$"
fac db 0dh,0ah,"Factorial",0dh,0ah,"$"
data ends

bignum_get macro var
local exit,get,loo,skip
xor cx,cx
lea si,var
mov di,si
mov ah,01h
get:
int 21h
cmp al,0dh
je exit
sub al,30h
mov [si],al
inc si
inc cx
jmp get
exit:
shr cx,1
jz skip
dec si
loo:
mov ah,[si]
mov al,[di]
mov [si],al
mov [di],ah
dec si
inc di
loop loo
skip:
endm

geti macro
local exit,get
xor bx,bx
mov dx,bx
mov cx,00ah
get:
push bx
;Read character
mov ah,01h
int 21h
xor ah,ah
pop bx
;If enter stop
cmp al,0dh
jz exit
sub al,30h
;Multply By 10
push ax
mov ax,bx
mul cx
mov bx,ax
pop ax
;add
add bx,ax
;redo
jmp get
exit:
mov ax,bx
endm

bignum_put macro var
local put,en,nxt,exit
lea si,var
mov di,si
mov cx,0200h
add di,cx
dec di
en:
cmp BYTE PTR [di],00h
jne nxt
dec di
jmp en
nxt:
mov ah,02h
put:
mov dl,[di]
add dl,30h
int 21h
cmp si,di
je exit
dec di
loop put
exit:
endm



bignum_add macro b1,b2
local ader,exit
lea si,b1
lea di,b2

mov cx,0200h
mov bl,10
ader:
mov al,[di]
mov ah,[si]
add al,ah
jz exit
xor ah,ah
div bl
mov [si],ah
inc si
add [si],al
inc di
loop ader
exit:
endm

bignum_mul macro b1
local loo,exit
cmp dl,01h
jz exit
lea si,b1
mov dh,10
xor bx,bx
mov cx,0200h
loo:
mov al,[si]
xor ah,ah
mul dl
add ax,bx
div dh
mov [si],ah
inc si
mov bl,al
loop loo
exit:
endm

puts macro msg
push ax
push dx
mov dx,offset msg
mov ah,09h
int 21h
pop dx
pop ax
endm


assume cs:code,ds:data
code segment
start:
mov ax,data
mov ds,ax

lea si,b1
mov BYTE PTR [si],01h

puts msg
geti
mov dl,al
loo:
push dx
bignum_mul b1
pop dx
dec dl
jnz loo

puts fac
bignum_put b1
mov ah,4ch
int 21h
code ends
end start


The Simple Factorial code upto 8!

geti macro
local exit,get
xor bx,bx
mov dx,bx
mov cx,00ah
get:
push bx
;Read character
mov ah,01h
int 21h
xor ah,ah
pop bx
;If enter stop
cmp al,0dh
jz exit
sub al,30h
;Multply By 10
push ax
mov ax,bx
mul cx
mov bx,ax
pop ax
;add
add bx,ax
;redo
jmp get
exit:
mov ax,bx
endm

puti macro buffer
local exit,put
mov bx,0ah
lea si,buffer
add si,06h
mov BYTE PTR [si],'$'
put:
xor dx,dx
dec si
div bx
add dl,30h
mov [si],dl
cmp ax,0h
jnz put

mov dx,si
mov ah,09h
int 21h

endm

puts macro msg
push ax
push dx
mov dx,offset msg
mov ah,09h
int 21h
pop dx
pop ax
endm

data segment
msg1 db 0dh,0ah,"Enter Number : $"
msg2 db 0dh,0ah,"Factorial : $"
buff db 20 dup(?)
data ends

assume cs:code,ds:data
code segment
start:
mov ax,data
mov ds,ax
puts msg1
geti
push ax
puts msg2
pop ax
mov cx,ax
dec cx
jz over
xor dx,dx
re:mul cx
loop re
over:
puti buff
mov ah,4ch
int 21h
code ends
end start


Thanks to ABA (Bellari) for challenging me to do the 255!.. Yo!!!

Friday, November 7, 2008

Remove old kernels in Ubuntu

Whenever a new kernel is applied ubuntu keeps the old one. This clogs up the grub and hard disk space and ends up having a lot of kernels to boot in the grub.
To know the version that is currently running:

uname -r


and to remove all other kernels use
sudo apt-get remove --purge 2.6.24-16-*


change the 2.6.2x-xx- parts to remove those kernel. Make sure you dont remove the kernel you are using, or you will end up breaking the system. It is wise to keep a recent kernel and a second one just prior to the new one, just in case your system doesn't do well with the new kernel.

Update

Please be sure to type the command exactly as such, dont miss any of the hyphens (-) and dots (.)
Missing something would end up uninstalling all of your kernels and hence making the system not bootable.


Correct commands :
sudo apt-get remove --purge 2.6.27-7-*
sudo apt-get remove --purge 2.6.27-9-*

etc

Command Line Output:

arun@server4:~$ sudo apt-get remove --purge 2.6.27-9-*
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting linux-headers-2.6.27-9-generic for regex '2.6.27-9-*'
Note, selecting linux-image-2.6.27-9-generic for regex '2.6.27-9-*'
Note, selecting linux-image-2.6.27-9-server for regex '2.6.27-9-*'
Note, selecting linux-headers-2.6.27-9 for regex '2.6.27-9-*'
Note, selecting linux-headers-lbm-2.6.27-9-generic for regex '2.6.27-9-*'
Note, selecting linux-headers-2.6.27-9-server for regex '2.6.27-9-*'
Note, selecting linux-restricted-modules-2.6.27-9-server for regex '2.6.27-9-*'
Note, selecting linux-backports-modules-2.6.27-9-generic for regex '2.6.27-9-*'
Note, selecting linux-restricted-modules-2.6.27-9-generic for regex '2.6.27-9-*'
Note, selecting linux-headers-lbm-2.6.27-9-server for regex '2.6.27-9-*'
Note, selecting linux-backports-modules-2.6.27-9-server for regex '2.6.27-9-*'
Note, selecting linux-image-2.6.27-9-virtual for regex '2.6.27-9-*'
The following packages will be REMOVED:
linux-headers-2.6.27-9* linux-headers-2.6.27-9-generic*
linux-image-2.6.27-9-generic* linux-restricted-modules-2.6.27-9-generic*
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
After this operation, 149MB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 127310 files and directories currently installed.)
Removing linux-headers-2.6.27-9-generic ...
Removing linux-headers-2.6.27-9 ...
Removing linux-restricted-modules-2.6.27-9-generic ...
update-initramfs: Generating /boot/initrd.img-2.6.27-9-generic
Purging configuration files for linux-restricted-modules-2.6.27-9-generic ...
Removing linux-image-2.6.27-9-generic ...
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/dkms
Uninstalling: nvidia 177.82 (2.6.27-9-generic) (i686)

-------- Uninstall Beginning --------
Module: nvidia
Version: 177.82
Kernel: 2.6.27-9-generic (i686)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

nvidia.ko:
- Uninstallation
- Deleting from: /lib/modules/2.6.27-9-generic/updates/dkms/
- Original module
- No original module was found for this module on this kernel.
- Use the dkms install command to reinstall any previous module version.
depmod......

DKMS: uninstall Completed.
run-parts: executing /etc/kernel/prerm.d/last-good-boot
Running postrm hook script /sbin/update-grub.
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-2.6.27-11-generic
Found kernel: /boot/memtest86+.bin
Replacing config file /var/run/grub/menu.lst with new version
Updating /boot/grub/menu.lst ... done

The link /vmlinuz.old is a damaged link
Removing symbolic link vmlinuz.old
you may need to re-run your boot loader[grub]
The link /initrd.img.old is a damaged link
Removing symbolic link initrd.img.old
you may need to re-run your boot loader[grub]
Purging configuration files for linux-image-2.6.27-9-generic ...
Running postrm hook script /sbin/update-grub.
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-2.6.27-11-generic
Found kernel: /boot/memtest86+.bin
Updating /boot/grub/menu.lst ... done

rmdir: failed to remove `/lib/modules/2.6.27-9-generic': Directory not empty
dpkg - warning: while removing linux-image-2.6.27-9-generic, directory `/lib/modules/2.6.27-9-generic' not empty so not removed.