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.