Wednesday, 28 August 2013

The Power of Python

"Power is PYTHON's mistress. It has worked too hard and taken too many risks at her conquest to allow anyone to take her away from it."

Truth be spoken , it is indeed true. But without going on how's and when Python achieved this let's focus on Why? This post is dedicated to the things that make Python GODLIKE _/\_ . The image below defines what I am trying to say .

 
  Hmmm, that was something :P . Now let me some python power aside from no brackets and semicolons.

''' To swap two numbers ''' 
 >>> a,b = b,a

''' To find the longest line in file  '''
 >>>  max(open('test.txt'), key=len) 

''' To sum the digits in an unsigned integer '''
  >>> sum(map(int, str(n))) 

''' Transposing a matrix: '''
>>> l = [[1, 2, 3], [4, 5, 6]]
>>> zip(*l)
  [(1, 4), (2, 5), (3, 6)]

''' Ever used if-condition like this '''
 >>> x = 3 if (y == 1) else 2

''' To extract only unique elemnts from a list(array) '''
  >>> list(set(list_name)

''' The amazing Regular Expression library '''       
 >>> import re
>>> a=" hello world this 58 re is 69 "
>>> re.findall('\d+',a)
 ['58','69']

 


Hmm, that was something again . Normal C , JAVA would require you to write large lines of codes to perform those functions. And this is only a start , when you dive in the deep sea of python and its libraries you will find amazing modules and functions and your task will be only a few words away.

Enjoy PYTHON. Cheers.
 

 
     

Wednesday, 21 August 2013

Want to crack Sublime Text 3? Are you sure?

Well, Sublime Text 3 is in fact a great text editor. And many have tried to crack its license. But when the new cracked Sublime Text is run, you will miss some of the features. Before going into that lets have a look at how to crack it on ubuntu.
  • Download the sublime text debian package from http://www.sublimetext.com/3.
  • To install the Sublime Text package type sudo dpkj -i 'file location' on terminal.
  •  Now install vim uf you don't have it. sudo apt-get install vim.
  • Now type the following commands.                                                                 1. cd /opt/sublime_text/
    2. sudo vim sublime_text 
  • Now vim will open the 'sublime_text' file which already has some text.
    Type the following commands in green as it is.

    1.    :%! xxd                        <press Enter>
    2.   / 4333 3342 3032         <press Enter>
    Click Esc
  • :%! xxd -r
  • :wq 
  • Almost Done. Open Sublime Text. Go to Help>Enter License
         Copy the follwing text including
                -------BEGIN LICENSE-------- and ---------END  LICENSE----------
        and paste it in the license text box(Ensure that there is no trailing  space ).
—--BEGIN LICENSE—--
Jat
Unlimited User License
EA7E-4656
D6B5CE42CFFD356FD6F782BE4D8D6E9A
F2DD8A265E67DD14C9B6627E9103E290
16FEB67F9DBE65D8434A31D2352A9C80
D7DDCC7BCCCA381D521F5DF49B0F7E5C
5A1B8F4ADE30EF20BEF4020B4D899AE4
60FE1355D8A8B71FE7350B52B4D88969
F42E6248426E64B6BB85A1217AFB7F04
51432FBA46AA531550D638910BAD6FE3
—--END LICENSE—--  



Now having cracked it lets look into its demerits. You won't be able to change the font and neither font size. Sometimes you will end up losing Sublime Text itself as happened with first time.
Many other operations and shortcuts will be missed.
And last it's a cracked version damnit!!




Do suggest any other improvements if you have any !! :D



Sunday, 11 August 2013

Starting with Python GUI

Well , after having several thoughts I thought of going ahead with Python GUI.
I am thinking of building a emailing app.Well I wrote a code which gave me a splash screen and a main window.Here Goes the image.
Here's the code I used to do it.
from PyQt4 import Qt, QtCore, QtGui
from PyQt4.QtGui import *
import sys
import time
class firstApp:
    def __init__(self):
        super(firstApp, self).__init__()
        self.initUI()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    pixmap = QPixmap("images/splash.png")
    splash = QSplashScreen(pixmap)
    splash.setMask(pixmap.mask())
    splash.show()
    w = QtGui.QWidget()
    w.resize(250, 150)
    w.move(300, 300)
    w.setWindowTitle('Simple')
    w.show()
    sys.exit(app.exec_())



Well that done the next step is to remove the splash screen before the main window opens.
MISSION Continues.
cheers.

Thursday, 17 January 2013

How to prepare an usb thumb drive, to boot windows 7 in UEFI mode?


Prepare an usb thumb drive, to boot windows 7 in UEFI mode 


Working of UEFI:
Once you power on the UEFI based PC, the Pre-EFI is executed which initializes only the CPU, memory and the chipset. This followed by Driver Execution Environment (DEX) where other hardware is initialized.

Advantages of UEFI:
    It can integrate various drivers this will not require to load during booting so saves time.
    PC can connect to network without OS.
    Also integrated drivers allow rendering GUI based control panel which out dates the old school bluish BIOS screen.
    Not all the installed hard drives are scanned as boot drive is set during the installation of OS in UFFI.
    Applications like anti-virus and diagnostic tools can be stored on virtually any non-volatile storage devices attached to a PC.

For a system to boot and install in UEFI the partition table of the HDD should be GPT (GUID Partition Table), not the old school MBR (master boot record). GPT has many advantages, can have virtually an unlimited number of partitions (windows will allow only 128) and impressively big partitions.

Since UEFI has a lot of advantages why not having a system install and boot in UEFI mode? AFAIK new Lenovo notebooks/netbooks are UEFI capable and OS’s are already installed in pure UEFI mode.

So, let’s go now to the point. Do you want to have more control over your HDD? Let say, you have a 320GB HDD and you have divided it in two partitions, one of 50GB, for your Windows 7, and the remaining for your data. If something goes wrong and you need to restore your system to factory default, with the recovery disks, it will wipe your partition scheme, set the system to default and this way your data will be lost.

You may want to make a “vanilla” installation of windows from a USB thumb drive and avoid using factory recovery disks. Now here things get complicated. A standard preparation of the USB with Microsoft’s software (Windows 7 USB/DVD Download Tool), or other tools, will give you a bios installation, not a UEFI one. So for the system to boot, you will need to change some settings in bios, and changing it from UEFI to legacy bios. The installation will prepare the HDD in MBR partition table, and you will lose all the advantages of UEFI, described above.

Now this can be avoided, by properly preparing an USB to boot and install in UEFI mode. Here are the steps:

Step by step tutorial:

1.    In a windows computer, download a legal copy (although trial) of the windows 7 os. You can do this from here: http://www.mydigitallife.info/official-windows-7-sp1-iso-from-digital-river/
Be sure to download the same version that came preinstalled in your computer. For example, if you have a Lenovo x120e, with a Windows 7 professional, 64bit, download an iso image of the Windows 7 professional 64bit.

2.    Once downloaded burn the iso to a USB thumb (at least 4GB) using Windows 7 USB/DVD Download Tool.

3.    After preparing this, create a folder on your computer, name it whatever (i.e. W7pro64bit). Go to the root of your USB
and select all the files and folders there (9 in total) copy, and paste to your folder you created, W7pro64bit.

4.    Using windows format the usb again in FAT32. Windows 7 USB/DVD Download tool, formats it in NTFS. We need a FAT32 formatted disk to achieve our goal. Formating again the USB in FAT32 will not touch the MBR of the USB thumbdrive. And after copying back the files (see step 6) the USB will still be bootable. (nice, and simple, isn't it?)

5.    Now go to the folder W7pro64bit and do the following:

a.    Browse to W7pro64bit\sources\ and open install.wim file. It’s a big file, and can be opened as an archive with 7zip (free software). Do not extract it, do not modify it, just browse the file with 7zip. Just to be sure you do not mess with that file, you can copy it somewhere else in your computer, and than procede.

b.    Browse this file (install.wim) to \1\Windows\Boot\EFI\ and locate the file bootmgfw.efi. Do not move, delete it, but just drag that file to the desktop. (if you have copied the file install.wim to another place in your computer, than you are safely do whatever you want with that file  ) Close the 7zip program to release the install.wim file.

c.    Rename the file you just copied to the desktop from bootmgfw.efi to bootx64.efi.

d.    Now go back to w7pro64bit folder and browse \efi\Microsoft. Form there copy the folder boot and paste it one level up, on the folder: \efi. It will look like this: \efi\boot.

e.    Now copy the file you saved on your desktop and renamed (bootx64.efi) to \efi\boot (inside the boot folder you copied on step 5d

6.    Now go to the root of the folder W7pro64bit and select all folders and files (9 in total) copy, and paste all those files back to your USB thumb drive. (see step 4 for more info)

7.    Go to the computer that you are going to reinstall, and before restarting it, use the program ABR (activation backup and restore) to backup the license of your windows os. (use google to find ABR). Advanced Tokens Manager (ATM  ) is great too. This link may be of help: Backup and restore W7 activation. After the program finishes its magic, it will create a few files inside the folder where the program itself reside. Copy these files to a new folder in your usb.  Rename it to ABR so you will quickly find it later. (if you decide to use ATM, the procedure may be a little different. But you are smart enough to figure out how to use it)

8.    Backup to an external storage all your data before continuing.(reminder: are you sure you saved the license as explained in step 7, to a safe place? To a external drive, to another computer? If you are sure, than go on with step 9)

9.    Now restart your laptop, and enter your bios settings. Go to the boot settings, and set the computer to boot in UEFI only. Not both, not UEFI first, or legacy, BUT UEFI only. Save and restart.

10.    Press f12 (or the corresponding key for your machine) to choose the boot device and chose to start from the USB thumb drive with your windows 7 pro 64 bit.

11.    If everything is done correctly, your computer will boot from the USB.

12.    Follow the wizard and choose a custom install, not upgrade. At the disk partition window delete all the partition you see there until you have only one unallocated space.

13.    Select it, and click next to install windows, without making partition in this point. The installer will create a GPT partition table not a MBR since the USB booted in UEFI mode.

14.    Immediately after the first restart remove your USB thumb, and the installation will continue from the HDD. Wait until installation finishes.

15.    When you will be finally on your desktop, on the installed OS plug your USB go to the ABR folder and click on restore.exe. It will restore your license and your copy of windows will be activated.

16.    Now you can go in computer management/disk management and shrink the HDD to create your partitioning scheme. Make sure to leave enough space to your windows os. (30gb or more for extra programs you will install at your choice)

Installing Linux beside Windows(Dual Boot)

There can be many problems which prevent installing Linux for dual boot. Some of the solutions are:

1.  To get it dual booting:

a. Disable UEFI in the BIOS.
b. Install your Linux distro.

If UEFI is enabled, the installer assumes you're using it (even though the partition table is MBR and Windows is therefore not booting via EFI) and sets things up for UEFI.  Once it's disabled, the installer sets up GRUB on the MBR as expected.

2.   Some other considerations you have to take into account:
  • Make sure to have the first Linux installing grub or grub 2 on the MBR.
  • The second installed Linux should install grub on its root partition (Or if you want, do not install grub or grub 2 at all)
  • Use the UID and GUID for the users on both Linux distributions
You can also have a Dual boot PC with the same Distro, just to have one for experimenting and the second for your stable work.
There are two ways to do this:
  1. Have both Linux distributions share /home partition
  2. Have each distribution with its own /home, and have a third partition to share documents.
The former may have problems with Gnome, KDE or any DE you are using, as they save its configurations files in your home folder. And that may lead to problems. I recommend the latter, but the former may work, specially if you are dual booting two Linux .
3. This one is detailed procedure:
  • Download an Ubuntu LiveCD image (.iso) from Ubuntu Downloads and burn it to a disc .
  • Insert the LiveCD into your CD-ROM drive and reboot your PC.
  • If the computer does not boot from the CD (e.g. Windows starts again instead), reboot and check your BIOS settings by pressing F2, F12, Delete, or ESC. Select "boot from CD".
  • Proceed with installation until you are asked this question: "How do you want to partition the disk?".
  • If you have already partitioned the disk and left space for Ubuntu, install it to that and then follow the rest of the steps.
  • Otherwise, choose one of the next two steps.

Automatic partition resizing (recommended)

  • Choose the first option, which should say "Install them side by side, choosing between them each startup".
  • Specify the size of the new partition by dragging the slider at the bottom of the window.
  • Click on "Forward".
  • Continue on to Finishing Ubuntu Installation.

Manual partitioning

  • Choose "Manually edit partition table".
  • Listed will be your current partitions.
  • Select the partition you want to resize and press Enter.
  • Select "Size:", press Enter.
  • Select Yes, press Enter.
  • Type in a new size in gigabytes for your partition, it's recommended you free up at least 10 GB of free space for your Ubuntu install. Press Enter when happy with your changes. It may take some time to apply the changes.
  • Create a swap partition of at least your amount of RAM (if you don't know, 2000 MB is a good value).
  • Create a partition for your Ubuntu installation.
  • Create other partitions if necessary: see DiskSpace
  • Select "Finish partitioning and write changes to disk".

Enjoy the war with Linux.

How to earn money in blogging trough ads?

Want to earn money from blogging?


Well are some methods I suggest.


1. Ad Sense

AdsenseThe best you can say for every blogger. It gives you quite a bit money and it is one of the dominating share in every blogger's income.

2. Affiliate Programs

Many companies and websites offer affilaite programs to earn from the share they earn from your users , like Flipkart affiliate program ,Amazon affiliate program and many other websites as such.

3. E-Book Sales

Well this is like advertising your own goods. Write eBooks and sell them.

Besides them their are many other ways like blogging in some paid blogging websites or adopting even other methods.
But to keep in it all depends on how your users like your posts .

Best of Luck with your blogging.