It has become appallingly obvious that our technology has exceeded our humanity

The era of Computer Buisness!!!

Friday, 7 August 2015

Blog moved to Wordpress

Sorry for the late update, but this blog has been moved to wordpress.com .
Now onwards you may access Technologica from here. Stay updated with Technologica!
Happy Opensourcing  :)

Monday, 8 September 2014

FLAPPY BIRD- PYGAME

Finally feels like i have completely utilized another vacation. We malayalis have a lot of special festivals and traditions, and the months of August-September are the most important among all.. because during this time its ONAM. No college for 10 days and its goddamn boring especially when your cousins are not around. And the only solution left out to drive away your boredom..... LAPTOP and CODING!! 
Well, the idea of Flappy-bird popped long back.. but i wasn't actually into coding it, because i thought, this is a game thats so famous and people die playing it.. then should be really hard to code. Well I am not that an expert. But at last i thought lets give it a try... and TaDa..... I am here with code. It took almost 3 days to complete this to be more specific 2 days and 4 hrs. 

Here is the github link, you can get all the files you need to successfully run the code there.


Im posting only the source code here..

~/Documents/flappy bird/game.py.html
#   Modules

import pygame,sys
from pygame.locals import *
pygame.init()
import random


#global variables
width,height=1000,600
clock=pygame.time.Clock()
point=pygame.mixer.Sound('sfx_point.ogg')
wing=pygame.mixer.Sound('sfx_wing.ogg')
whoosh=pygame.mixer.Sound('sfx_swhooshing.ogg')
hit=pygame.mixer.Sound('sfx_hit.ogg')
die=pygame.mixer.Sound('sfx_die.ogg')

#Sprite class
class _pipe(pygame.sprite.Sprite):


    def __init__(self,x,y,transform,bird):
        super(_pipe, self).__init__()
        self.x = x
        self.y = y
        if bird==False:
                self.object=pygame.image.load('pipe.jpeg')
                self.object=pygame.transform.scale(self.object,(50,y))
                self.gap=random.randint(130,150)
                self.transform=transform
                self.bird=bird
        else:
                self.bird=bird
                self.object=pygame.image.load('flappy2.png')
                self.object=pygame.transform.scale(self.object,(100,100))
                self.transform=transform
                self.gap=random.randint(100,150)
        self.rect = self.object.get_rect(center=(self.x,self.y))


    def blit_pipe(self,screen):
        if self.bird==True:
            screen.blit(self.object,(self.x,self.y))
        elif self.transform:
            self.object=pygame.image.load('pipe.jpeg')
            self.object=pygame.transform.scale(self.object,(50,self.y))
            self.object=pygame.transform.rotate(self.object,90)
            self.object=pygame.transform.rotate(self.object,90)
            screen.blit(self.object,(self.x,0))
            self.rect.move_ip(self.x,0)
        elif self.bird==False and self.transform==False:
            self.object=pygame.image.load('pipe.jpeg')
            c=600-(self.y-self.gap)
            self.object=pygame.transform.scale(self.object,(50,c))
            screen.blit(self.object,(self.x,(self.y+self.gap)))
        if self.transform:
            self.rect = self.object.get_rect(center=(self.x+23,0))
            self.rect=self.rect.inflate(4,self.y-10)
        elif self.bird==False:
            self.rect = self.object.get_rect(center=(self.x+23,(600-(self.y-self.gap))))
            p = pygame.Rect(self.x,(self.y+self.gap),70,self.y*10)
            self.rect=p.clip(self.rect)
        else:
            self.rect=self.object.get_rect(center=((self.x+90),(self.y+70)))
            p = pygame.Rect(self.x-3,self.y+13,70,53)
            self.rect=p.clip(self.rect)



def initialise():
    score=0
    pygame.display.set_caption('My flappy bird')
    y_scale=0
    x_pos=500
    rect_speed=1
    y_pos=0
    level=0

    screen=pygame.display.set_mode((width,height))
    s = pygame.display.get_surface()

    bird=_pipe(200,300,False,True)
    bg=pygame.image.load('bg.jpeg')
    bg=pygame.transform.scale(bg,(width,height))

    size=random.randint(200,350)
    pipe1_up=_pipe(500,size,True,False)
    pipe1_down=_pipe(500,size,False,False)

    size=random.randint(200,350)
    temp=random.randint(400,500)
    pipe2_up=_pipe(500+temp,size,True,False)
    pipe2_down=_pipe(500+temp,size,False,False)

    size=random.randint(200,350)
    temp=random.randint(800,950)
    pipe3_up=_pipe(500+temp,size,True,False)
    pipe3_down=_pipe(500+temp,size,False,False)

    pipe_gang=pygame.sprite.Group()
    pipe_gang.add(pipe1_up,pipe1_down,pipe2_up,pipe2_down,pipe3_up,pipe3_down)

    game_loop(y_pos,pipe1_up,pipe1_down,pipe2_up,pipe2_down,pipe3_up,pipe3_down,y_scale,rect_speed,bird,bg,s,screen,score,pipe_gang)


def game_over(screen,bird):

    font=pygame.font.Font(None,100)
    text=font.render('GAMEOVER',1,[0,0,0])
    screen.blit(text,[300,250])
    font=pygame.font.Font(None,50)
    text=font.render('Press Enter To Replay...',1,[0,0,0])
    screen.blit(text,[350,400])
    pygame.display.flip()
    done=False
    bird.y=580
    i=1
    while done==False:
        clock.tick(20)
        for event in pygame.event.get():

            if event.type==pygame.QUIT:
                done=True
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_RETURN:
                    initialise()
            bird.blit_pipe(screen)
            pygame.display.flip()

    sys.exit()


def game_loop(y_pos,pipe1_up,pipe1_down,pipe2_up,pipe2_down,pipe3_up,pipe3_down,y_scale,rect_speed,bird,bg,s,screen,score,pipe_gang):

    global point
    global wing
    global whoosh
    global hit
    global die

    i=1
    flag=1

    while True:
        seconds=clock.tick()/1000.0
        if flag==1:
            y_scale=3*i
            i+=0.1
            flag=0
        if flag==0:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    sys.exit()
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_SPACE:
                        wing.play(loops=0,maxtime=0)
                        y_scale=-2

                if event.type == pygame.KEYUP:
                    if event.key == pygame.K_SPACE:
                        y_scale=3*i
                        i+=0.1


        screen.blit(bg,(0,0))
        bird.blit_pipe(screen)
        pipe1_up.blit_pipe(screen)
        pipe1_down.blit_pipe(screen)
        pipe2_up.blit_pipe(screen)
        pipe2_down.blit_pipe(screen)
        pipe3_up.blit_pipe(screen)
        pipe3_down.blit_pipe(screen)
        p=pygame.draw.rect(screen,(0,0,0),[0,height-30,width,30],2)
        s.fill(Color('brown'), p)

        if bird.y>=(height-100):
            die.play(loops=0,maxtime=0)
            flag=1
            break

        if not bird.y>height:
            bird.y+=y_scale
        if not (pipe1_up.x<-50 or pipe1_down.x<-50):
            pipe1_up.x-=rect_speed
            pipe1_down.x-=rect_speed
        else:
            pipe1_up.x=1000
            pipe1_down.x=1000
            i=1
        if not (pipe2_up.x<-50 or pipe2_down.x<-50):
            pipe2_up.x-=rect_speed
            pipe2_down.x-=rect_speed
        else:
            pipe2_up.x=1000
            pipe2_down.x=1000
            i=1
        if not (pipe3_up.x<-50 or pipe3_down.x<-50):
            pipe3_up.x-=rect_speed
            pipe3_down.x-=rect_speed
        else:
            pipe3_up.x=1000
            pipe3_down.x=1000
            i=1
        if bird.x>pipe1_up.x and bird.x < pipe1_down.x+2:
            score = (score + 1)
            point.play(loops=0,maxtime=0)
        elif bird.x>pipe2_up.x and bird.x < pipe2_down.x+2:
            score = (score + 1)
            point.play(loops=0,maxtime=0)
        elif bird.x>pipe3_up.x and bird.x < pipe3_down.x+2:
            score = (score + 1)
            point.play(loops=0,maxtime=0)
        if score>=15:
            rect_speed=1.5



        font=pygame.font.Font(None,50)
        text=font.render('Score:'+str(score),1,[0,0,0])
        screen.blit(text,[600,100])
        if pygame.sprite.spritecollideany(bird,pipe_gang):
            hit.play(loops=0,maxtime=0)
            game_over(screen,bird)
        pygame.display.update()
    game_over(screen,bird)


if __name__=="__main__":
    initialise()
    sys.exit()
Happy Coding..  :)

Saturday, 1 March 2014

MY SECOND PYTHON GAME

Well, it was really a huge surprise for me that i made myself up for coding a new game in python. after a weeks work on a shooting game I had left it all thinking that, "this is not my kind of stuff!". But my passion for coding did never end, and out of nowhere, the spark came up, and i started up my work on the code again. It took just 24 hrs to complete my whole code for the game which i named  as BALL SHOOTER. Actually i wanted to shoot out falling aliens, but unfortunately i couldn't get suitable image files. I have also included sound effects in this game, thought it is a flop try.
Well, here is the link for my code in github. Any programmer may try.
Here are a few screenshots.




Friday, 24 January 2014

RUBY ON RAILS WORKSHOP

 We had a two day workshop on ‘RUBY ON RAILS’ organized under the FOSS cell of Government Engineering College Sreekrishnapuram  from 18th January 2014 to 19th January 2014.
The resource person, Mr. Sumit M Ashok, is an engineer currently serving BangTheTable as their Developer with Ruby on rails.
First Session started with an introduction to Git, a version control tool and later the class was mainly confined to the basic concepts of Ruby, object oriented concepts of the language, classes, objects and methods. The session was very interesting due to the simple and interactive mode of teaching.

Second session dealt with more complex concepts of the language like operators, iterators and the concept of Meta programming as well as the use and actions possible on arrays. The class came to an end with a detailed description on request response cycle (MVC).
Second day morning session covered fundamental ideas of ruby on rails, a review of concepts like model, view, controller and their interconnections. The class gave a very smooth introduction to RVM, GEMS and RAILS along with the concepts of web application development.
The afternoon session was a practical implementation of the previously learned concepts. The students were ably guided in working on ruby on rails console and further created a simple web page.
On the whole this workshop on ‘Ruby on Rails' with Mr. Sumit was really a whole new experience, and was really helpful in gaining some basic knowledge on Ruby as a language and web development using Ruby on rails. The programming concepts learned will be very useful in establishing a carrier as a programmer.



Wednesday, 25 December 2013

MONSTER SWEEP

This is my first GUI game code. This is a mere luck based game where you have to click on any of the 25 blocks given on the screen to open it. You can continue your game till you click on a monster containing box. Once you click on the monster containing box.. YOU DIE!! GAME OVER!!
This is purely codded in python language, inspired from the traditional minesweeper game with a little bit change in the game logic.
This is the code but might not properly work because it uses some image files. Unfortunately i don't know how to upload a file into a blog!

#***************************************************************************#
#        Author: Chaythanya SK                                                                                                 #
#        Name of project: MONSTER SWEEP GAME                                                             #
#        RULES: open the boxes containing numbers only if you open the monster           containing box.. you die!! GAMEOVER!                                                                          
#            mere luck based game                                                                                              #
***************************************************************************


import pygame
import random
# declaring colours
black=(0,0,0)
white=(255,255,255)
green=(1,255,0)
yellow=(15,100,0)
red=(255,0,0)
blue=(19,37,173)
orange=(240,69,12)
pygame.init()
size=[375,300]                  # size of the game window
screen=pygame.display.set_mode(size)   
pygame.display.set_caption('MONSTER SWEEP')    # title of the game window
done=False
smile=pygame.image.load("smiley.jpeg").convert()    #getting images
index=pygame.image.load("index.jpeg").convert()        #getting images

clock=pygame.time.Clock()
screen.fill(white)       
r1=[]
r2=[]
r3=[]
r4=[]
r5=[]
grid=[r1,r2,r3,r4,r5]        # game array
minecount=0   
remaining_no=0
GI=-1                # row to be selected initialised as -1
GJ=-1                # col to be selected initialised as -1
open_count=0            # no of boxes opened
def make():            #making the first look
    cord_y=0+50
    cord_x=0
    screen.fill(white)   
    for i in range(5):
        for j in range(5):
            pygame.draw.rect(screen,black,[cord_x,cord_y,75,50],2)        # draw the grid
            cord_x=cord_x+75
        cord_x=0
        cord_y=cord_y+50
    pygame.display.flip()            #update the screen
    assign(grid)
   
def assign(grid):        # assign monsters and numbers in the grid
    global minecount
    global remaining_no
    for i in range(5):                #fill the grid with random nos
            for j in range(5):
                    grid[i].append(random.randrange(0,5))

    for b in range(10):                # put "bomb"(monsters) in some random places
        temp1=random.randrange(0,5)
        temp2=random.randrange(0,4)
        grid[temp1][temp2]='bomb'
    for i in range(5):
            for j in range(5):
                    if grid[i][j]=='bomb':
                            minecount=minecount+1        #count the no: of monsters
    remaining_no=25-minecount                #count the remaining boxes
    font=pygame.font.Font(None,25)
        text=font.render("monster count:"+str(minecount),True,black)    #blit the monster count in the screen
        screen.blit(text,[20,17])
    pygame.display.flip()            # update the screen

def checkbomb(x,y):                #identify the selected box.. x,y are the coordinates of mouse click
    global grid
    global open_count
    global temp_remaining_nos
    open_count=open_count+1            #box opened
    block_no=0
    selected_no=0
    flag=0
    lcord_x=0                # left x coordinate
    ucord_y=50                # up y coordinate
    dcord_y=100                # down y coordinate
    rcord_x=75                # right x coordinate
    for i in range(5):           
        for j in range(5):
            block_no=block_no+1
            if(x>lcord_x and x<rcord_x and y>ucord_y and y<dcord_y ):# find the selected box no (1-25)
                selected_no=block_no
                flag=1
                break
           
            lcord_x=lcord_x+75
            rcord_x=rcord_x+75
       
        if(flag==1):
            break
        lcord_x=0
        rcord_x=75
        ucord_y=ucord_y+50
        dcord_y=dcord_y+50
    find_grid_pos(selected_no)         # find row and col of the selected block no (1-25)
    grid_display(x,y,lcord_x,rcord_x,ucord_y,dcord_y)
def find_grid_pos(selected_no):        #find the row and col of the selected block no (1-25)
    global GI
    global GJ
    if selected_no==1:
        GI=0
        GJ=0
    if selected_no==2:
                GI=0
                GJ=1
    if selected_no==3:
                GI=0
                GJ=2
    if selected_no==4:
                GI=0
                GJ=3
    if selected_no==5:
                GI=0
                GJ=4
    if selected_no==6:
                GI=1
                GJ=0
    if selected_no==7:
                GI=1
                GJ=1
    if selected_no==8:
                GI=1
                GJ=2
    if selected_no==9:
                GI=1
                GJ=3
    if selected_no==10:
                GI=1
                GJ=4
    if selected_no==11:
                GI=2
                GJ=0
    if selected_no==12:
                GI=2
                GJ=1
    if selected_no==13:
                GI=2
                GJ=2
    if selected_no==14:
                GI=2
                GJ=3
    if selected_no==15:
                GI=2
                GJ=4
    if selected_no==16:
                GI=3
                GJ=0
    if selected_no==17:
                GI=3
                GJ=1
    if selected_no==18:
                GI=3
                GJ=2
    if selected_no==19:
                GI=3
                GJ=3
    if selected_no==20:
                GI=3
                GJ=4
    if selected_no==21:
                GI=4
                GJ=0
    if selected_no==22:
                GI=4
                GJ=1
    if selected_no==23:
                GI=4
                GJ=2
    if selected_no==24:
                GI=4
                GJ=3
    if selected_no==25:
                GI=4
                GJ=4

   
   

def grid_display(x,y,lcord_x,rcord_x,ucord_y,dcord_y): # display the content of the opened box
    global GI
    global GJ
    global grid
    #print grid
    font=pygame.font.Font(None,25)
    if(str(grid[GI][GJ])=='bomb'and open_count>=1): # if the opened box contains bomb show game over
        showgrid_gameover()            # diaply whole grid
    else:                        # else display the no:   
        text=font.render(str(grid[GI][GJ]),True,black)
        screen.blit(text,[lcord_x+30,ucord_y+15])
        if (open_count==remaining_no+1):        #if open count equals remining no you win!
            showgrid_win()            #display whole grid
    pygame.display.flip()                # update screen to show no:
def showgrid_gameover():                # show game over screen
    global grid
    x_cord=0
    y_cord=50
    for i in range(5):
        for j in range(5):
            if (grid[i][j]=='bomb'):
                screen.blit(index,[x_cord+20,y_cord+5])
            else:
                font=pygame.font.Font(None,25)
                text=font.render(str(grid[i][j]),True,black)
                screen.blit(text,[x_cord+30,y_cord+15])
           
            x_cord=x_cord+75
        x_cord=0
        y_cord=y_cord+50
    pygame.draw.rect(screen,white,[0,0,375,50])

    screen.blit(smile,[170,7])
        font=pygame.font.Font(None,25)
        text=font.render("press me--->",True,black)    # show press me smiley to restart game
        screen.blit(text,[55,17])
    font=pygame.font.Font(None,55)
    text=font.render("GAME OVER!!!",True,blue)
    screen.blit(text,[80,150])
        pygame.display.flip()
           
def showgrid_win():            # show "you won" screen
    global grid
        x_cord=0
        y_cord=50
        for i in range(5):
                for j in range(5):
                        if (grid[i][j]=='bomb'):
                                screen.blit(index,[x_cord+20,y_cord+5])
                        else:
                                font=pygame.font.Font(None,25)
                                text=font.render(str(grid[i][j]),True,black)
                                screen.blit(text,[x_cord+30,y_cord+15])

                        x_cord=x_cord+75
                x_cord=0
                y_cord=y_cord+50
    pygame.draw.rect(screen,white,[0,0,375,50])
           screen.blit(smile,[170,7])
        font=pygame.font.Font(None,25)
        text=font.render("press me--->",True,black)        # show press me smiley to restart the game
        screen.blit(text,[55,17])
    font=pygame.font.Font(None,50)
        text=font.render("BRAVO YOU WIN!!!",True,blue)
        screen.blit(text,[60,150])

def check_reset(x,y):            # check if the press me smiley is pressed
    global r1
        global r2
        global r3
        global r4
        global r5
        global grid
    global minecount
    global remaining_no
    global GI
    global GJ
    global open_count
    if(x>=170 and x<=210 and y>=7 and y<=47):    # trace the coordinates
        r1=[]                    # reinitialise everything
               r2=[]
            r3=[]
                r4=[]
               r5=[]
              grid=[r1,r2,r3,r4,r5]
        minecount=0
        remaining_no=0
        GI=-1
        GJ=-1
        open_count=0
        temp_remaining_nos=0
        screen.fill(white)
        make()                # make the screen again



make()
while done==False:
    clock.tick(20)
    for event in pygame.event.get():    # for each thing you do in the screen
       
        if event.type==pygame.QUIT:    # if it is quit exit the loop
            done=True
        elif(event.type==pygame.MOUSEBUTTONDOWN and pygame.mouse.get_pressed()[0]): # if the mouse is pressed
            x,y=pygame.mouse.get_pos()        # get the position
            check_reset(x,y)            # check if the reset button is pressed
            checkbomb(x,y)                # check for the bomb
       
    pygame.display.flip()                    # update the screen
pygame.quit()                            # quit the game
   















































Sunday, 10 November 2013

Google God??

Ever thought about the "Google" as a god?
Google technology has advanced so much that today it referred to provide a god like service.Today Google has become much more than a mere search engine. In fact "google" is nowadays commonly used as a verb, probably it is the most common thing which all of us indulge in.

Search Engines in the limelight

A search engine is defined as “a program for the retrieval of data, files, or documents from a database or network.”  The most common type of search engines was developed to search, what we term, the Internet.  Though within academic and other databases, such as Ebsco, there are search engines to search the content within the database holdings.  You may be familiar with Westlaw and LexisNexis; they both have internal search engine programs that search the content behind the password wall.
I used a search engine to help me find the above-mentioned definition.  I used Google.  That is my search engine of choice.  However, there are a quite a few other well-known search engines, such as Dogpile, Yahoo!, or Bing.  Did you know that there were over 150 different types of search engines available to search for web content?  So rather than looking at one particular search engine as a one-stop-shop location for all resources available online, you might consider choosing your search engine, or engines, by what type of resources you are looking to review.  There are two ways to evaluate search engines:
(1) by content, meaning what they are searching, and
(2) by how the information is compiled that they are searching, meaning that you are searching within a directory versus an index.
Search engines can be broken down into different categories of expertise for searching.   You might consider the following categories in determine what you’re looking for in your search: Blog Search Engines; Book Search Engines; Business Search Engines; Forum Search Engines; Image and Multimedia Search Engines; International Search Engines; Job Search Engines; Legal and Law Enforcement Search Engines; Map Search Engines; Medical Search Engines; News Search Engines; People Search Engines; Price/Shopping Search Engines; and Social Search Engines.[i]  Specific search engines may be better suited for one type of search over another.  For example, if you were looking for someone’s phone number, you might want to use a people search engine versus a social media search engine, which would give you any Facebook, Twitter, MySpace information over actual phone numbers and addresses.
Another factor in considering which search engine you want to use is to evaluate how that search engine searches for information.  You might consider whether the search engine is human-powered directory, searching the invisible or deep web, or is an all-purpose crawler search engine.  Here are the differences.  Human-powered search engines are also known as web directories, which is an index that is compiled by humans.  Humans add links that they determine to be high quality to a directory, and when you run a search using this human-driven search engine, you are searching that directory of links for information relevant to your query.  The following list includes human-based search engines:
  • Mahalo (Web directory that uses human editors and displays the results beside a Google search)
  • Eurekster Swickis (Web directory that you create and have complete control over. Still in Beta form).
  • Open Directory ( The “largest, most comprehensive human-edited directory of the Web. It is constructed and maintained by a vast, global community of volunteer editors.”[ii] The Open Directory project is also known as DMOZ, or Directory Mozilla.)
  • Yahoo!Search Directory (“The Yahoo Directory is a human-created and maintained library of web sites organized into categories and subcategories. Yahoo editors review these sites for potential inclusion in the Directory, and to evaluate the best place to list them.”[iii])
All-purpose search engines that use crawlers, such as Google, search information a bit differently.  Rather than having humans add information and links to an index, a company, such as Google, runs a program (also known as a spider) that follows links throughout the Internet.  While it is following, or crawling, through the web, the program is grabbing information from websites and adding it to an index. Additionally, “the crawler doesn’t rank the pages, it only goes out and gets copies which it stores, or forwards to the search engine to later index and rank according to various aspects.”[iv]















With a sea of information all around Google is the " fish net" that finds you exactly what you need. Better call it god!

First animation code in Python

One of the best online tutorial to get started with Coding games in python. I just started my first step towards game coding, and now iam able to animate things around the screen and makes things bounce like balls etc..
http://programarcadegames.com/
This is the tutorial which helped me a lot to do these things.This tutorial uses very legible language that is easy to understand for beginners.  Only thing i doubt about this tutorial is whether the coding is in round about way. Because when i went through some of the codes written by my friends they don't seem this lengthy.  Probably it is better for beginners to learn from the basics than to jump to the advanced stuff with few lines of code and getting all confused.
Well here is the link to my github repo for what i have dome so far using this tutorial. I've just read two chapters so far, so don't misinterpret the standard of the tutorial with my code. :)

http://programarcadegames.com/

Tuesday, 5 November 2013

Indian start-ups provides a Billion dollar oppurtunity

Indian start-ups' billion dollar opportunity

Today Indian startups provide billions of opportunities for the upcoming software "techies". A new breed of Indian software companies is now profiting from the hunger for small scale cutting-edge works.
Among the up and coming lot are business phone services provider Exotel, helpdesk software manufacturer Freshdesk, medical practice management-focused Practo , customer engagement solutions provider Capillary, and digital commerce solution provider MartJack, all of which cater to the needs of small businesses, both in India and abroad. Rather than established companies that prefer to go on a safe basis, startups that are experimenting on ideas are coming more on to the limelight. More job opportunities and core applications add to the beauty of Indian Startups.

Monday, 4 November 2013

First Aid for your pc(TIMES OF INDIA)

ClamWin, CCleaner, Recuva, Revo Uninstaller and AutoRuns for Windows

 are some of the softwares suggested for making your own first aid kit.The kit is nothing but a simple thumb drive which you can take it with you all the time, and help anyone with their PC problems.

CLAM WIN
It is a portable version of Clam Win antivirus.Sometimes the virus affected in your system may disable the antivirus software installed in your system, with clam win it is easy to detect and remove such malwares.

CCLEANER
If your Pc has turned too slow and takes minutes to open a folder, then it is because of the temporary files created by your softwares that are not anymore necessary, These occupy a huge ram space and makes the system perform sluggish.
Launch CCLEANER in your system and purge your system of this junk

RECUVA
Recuva comes with a simple  magical interface that brings you back all the permanently deleted files in your system.Some files like image files can be viewed but I  think only a list of the deleted files could be retrieved.
Hope there are better softwares on market these days.

REVO UNINSTALLER
Uninstalled software sometimes leave residue in the form of files and Registry entries. These are not easy to find and they often end up filling the precious space. 
Revo Uninstaller saves you the trouble of manually clearing these files by thoroughly uninstalling a program. 


AUTORUNS FOR WINDOWS 
If your system takes too much time to boot, then it is because of the unwanted programs that are configured to launch at the boot time. AutoRuns cut down these programs so that your system boots up faster than ever before. 


These are not all that a PC needs for a better performance. but these can be considered as a first aid before the thorough checkup.

Monday, 21 October 2013

SCOPE

There are mainly two types of scopes for python variables:

  • Local scope
  • Global scope
Global variables are accessible from all functions whereas local variables are accessible only from the function where it is declared.
Consider the following example.
----------------------------------------------------------------------------------------------------------------------------------
x = 1

def fun():
    x = 2
    print x

fun()
print x

Here the output is
2
1
-----------------------------------------------------------------
First the function fun() is invoked, when the print x statement is encountered, it looks for local variables named x if found it prints the value of local x if not it goes for global x.Since in this problem local x is available the value of global x is overwritten by local x within the function.
-----------------------------------------------------------------

x = 1

def fun():
    p = 2
    print p

fun()
print x
print p #this gives an error

Here the output is
2
1
Traceback (most recent call last):
  File "nested_scope.py", line 7, in 
    print local_var  # this gives an error
NameError: name 'local_var' is not defined
-----------------------------------------------------------------
If at all you invoke global variable within a function, if you declare another variable with the same name, then the global value will be over written(only within the function).
For eg:
-----------------------------------------------------------------
x = 1

def fun():
    global x
    x = 10
    print x

fun()

print x
 
The output will be:
10
10
-----------------------------------------------------------------

./ method to execute a python file

A file can be executed from the terminal using
./filename.py
by typing a special command in the beginning of the filename.
The very first byte of the file must start with a # symbol followed by a !,followed by the path.
For eg,
#!/usr/bin/python

Tuesday, 1 October 2013

REGULAR EXPRESSIONS

Regular expressions are used for pattern matching.The Python "re" module provides regular expression support.

import re

s1 = 'this is a nice line!'

pat1 = 'nice'

print re.search(pat1, s1)

If pattern matching is successful a match object is returned else the function returns None.
pat1 = r'^is'

print re.search(pat1, s1)

'r' before the string gives a special meaning to it. By using that we say the string is raw or the special characters used withing the string doesn't have special meaning.
 
Ordinary characters just match themselves exactly.
The characters which do not match themselves because they have special meanings are:
 . ^ $ * + ? { [ ] \ | ( ) 
  • . (a period) -- matches any single character except newline '\n'
  • \w -- (lowercase w) matches a "word" character: a letter or digit or underscore. Note that although "word" is the mnemonic for this, it only matches a single word char, not a whole word. \W (upper case W) matches any non-word character.
  • \b -- boundary between word and non-word
  • \s -- (lowercase s) matches a single whitespace character -- space, newline, return, tab, form. \S (upper case S) matches any non-whitespace character.
  • \t, \n, \r -- tab, newline, return
  • \d -- decimal digit [0-9]
  • ^ = start, $ = end -- match the start or end of the string
  • \ -- inhibit the "specialness" of a character. So, for example, use \. to match a period or \\ to match a slash. If you are unsure if a character has special meaning, such as '@', you can put a slash in front of it, \@, to make sure it is treated just as a character.

Friday, 20 September 2013

Lambda forms

By popular demand, a few features commonly found in functional programming languages like Lisp have been added to Python.
With the lambda keyword, small "anonymous" functions can be created.
Here’s an example:
>>> a=map(lambda x:x*x,range(10))
>>> a
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]


Lambda forms can be used wherever function objects are required. They are syntactically restricted to a single expression. Semantically, they are just syntactic sugar for a normal function definition. Like nested function definitions, lambda forms can reference variables from the containing scope:
While using lambda there is no scope for using loops and all.
Only a single statement can be included.

Filter(), Map() and Reduce()-----> Tools for functional programming

Filter() map() and reduce() are built in functions. These are very useful while used with lists. Here are the details.

Filter()


Syntax:
                filter(function,sequence)


returns a sequence consisting of those elements from the sequence for which function(element) is true. If sequence is a string or tuple, the result will be of the same type, otherwise, it is always a list.
 For example, to compute a sequence of numbers not divisible by 2 and 3:
 >>> def f(x):
...     return ((x%2!=0) and (x%3!=0))
...
>>> filter(f,range(0,10))
[1, 5, 7]

Map()

Syntax:
               map(function,sequence)
Calls the function() for each value in the sequence and stores the return value in a list. For example:
>>> def cube(x):
...     return x*x*x
...
>>> map(cube,range(10))
[0, 1, 8, 27, 64, 125, 216, 343, 512, 729]
>>> 
More than one sequence may be passed; the function must then have as many arguments as there are sequences and is called with the corresponding item from each sequence (or None if some sequence is shorter than another). For example:
>>> def f(x,y):
...     return x+y
...
>>> seq=range(8)
>>> map(f,seq,seq)
[0, 2, 4, 6, 8, 10, 12, 14]
>>>

 

Reduce()

Syntax:
                  reduce(function,sequence)              

returns a single value constructed by calling the binary function "function" on the first two items of the sequence, then on the result and the next item, and so on. For example, to compute the sum of the numbers 1 through 10:
>>>
>>> def f(x,y):
...     return x+y
... 
>>>reduce(f,range(1,11));
55

If there’s only one item in the sequence, its value is returned; if the sequence is empty, an exception is raised.A third argument can be passed to indicate the starting value.

My first game code...

/*                              Chaythanya
   If you are using turbo cpp compiler try to include conio.h ang uncomment the
   function clrscr() for better looks */
#include<stdio.h>
#include<stdlib.h>
//#include<conio.h>
char a[5][5];
char pa[5][5];
int pc=0;
int r,c;
void intro(char* player);
int find(int choice);
void firstdisplay();
void make();
void play();
void display(char a[5][5]);
void play();
void intro(char* player)
{
    printf("\n\t Welcome %s.. here are the rules of the game\n",player);
    firstdisplay();
    printf("\n\t This is the board, there are no empty columns each column is filled with either mine or character ");
    printf("\n\t choose the appropriate no: to open the block\n\t Game begins!!...\n\n\n"); 
}
void make()
{
    int i,j;
    int d=65;
    for(i=0;i<5;i++)
    {
        for(j=0;j<5;j++)
        {
            pa[i][j]=' ';
            if(pc==1)
            {
            if(5*(i+j)%3==0)
                a[i][j]='X';
            else
            {
                if((d!=120)&&(d!=88))
                {
                    a[i][j]=d;
                    d++;
                }
            }
            }
            else
            {
            if((i+j)%(pc+1)==0)
                                a[i][j]='X';
                        else
                        {
                                if((d!=120)&&(d!=88))
                                {
                                        a[i][j]=d;
                                        d++;
                                }
                        }
            }

        }
    }
    firstdisplay();
}
void firstdisplay()
{
    printf("\t _____ _____ _____ _____ _____ \n");
        printf("\t|     |     |     |     |     | \n");
        printf("\t| 1   |  2  |  3  | 4   |  5  |\n");
        printf("\t|_____|_____|_____|_____|_____|\n");
        printf("\t|     |     |     |     |     |\n");
        printf("\t| 6   |  7  |  8  |  9  | 10  |\n");
        printf("\t|_____|_____|_____|_____|_____|\n");
        printf("\t|     |     |     |     |     |\n");
        printf("\t| 11  | 12  | 13  | 14  | 15  |\n");
        printf("\t|_____|_____|_____|_____|_____|\n");
    printf("\t|     |     |     |     |     |\n");
        printf("\t| 16  | 17  | 18  | 19  | 20  |\n");
        printf("\t|_____|_____|_____|_____|_____|\n");
    printf("\t|     |     |     |     |     |\n");
        printf("\t| 21  | 22  | 23  | 24  | 25  |\n");
        printf("\t|_____|_____|_____|_____|_____|\n");
}
void play()
{
    int b;
    printf("\n\t Enter the block you want to open:");
    scanf("%d",&b);
    int success= find(b);
    if(!success)
    {
       
        pa[r][c]=a[r][c];
        if(a[r][c]=='X')
        {
            display(a);
            return;
        }
        else
        {        display(pa);
                play();
        }
    }
    else
    {
        printf("\n\n\t Wrong choice!!.. try again!!\n\n");
        display(pa);
        play();
    }
}

int find(int choice)
{
    if(choice==1){
                r=0;
                c=0;
        return 0;
        }
        else if(choice==2){
                r=0;
                c=1;
        return 0;

        }
        else if(choice==3){
                r=0;
                c=2;
        return 0;

        }
        else if(choice==4){
                r=0;
                c=3;
        return 0;

        }
        else if(choice==5){
                r=0;
                c=4;
        return 0;

        }
        else if(choice==6){
                r=1;
                c=0;
        return 0;

        }
        else if(choice==7){
                r=1;
                c=1;
        return 0;

        }
        else if(choice==8){
                r=1;
                c=2;
        return 0;

        }
        else if(choice==9){
                r=1;
                c=3;
        return 0;

        }
    else if(choice==10){
                r=1;
                c=4;
        return 0;

        }
        else if(choice==11){
                r=2;
                c=0;
        return 0;

        }
        else if(choice==12){
                r=2;
                c=1;
        return 0;

        }
        else if(choice==13){
                r=2;
                c=2;
        return 0;

        }
        else if(choice==14){
                r=2;
                c=3;
        return 0;

        }
        else if(choice==15){
                r=2;
                c=4;
        return 0;

        }
        else if(choice==16){
                r=3;
                c=0;
        return 0;

        }
        else if(choice==17){
                r=3;
                c=1;
        return 0;

        }
        else if(choice==18){
                r=3;
                c=2;
        return 0;

        }
        else if(choice==19){
                r=3;
                c=3;
        return 0;

        }
        else if(choice==20){
                r=3;
                c=4;
        return 0;

        }
        else if(choice==21){
                r=4;
                c=0;
        return 0;

        }
        else if(choice==22){
                r=4;
                c=1;
        return 0;

        }
        else if(choice==23){
                r=4;
                c=2;
        return 0;

        }
        else if(choice==24){
                r=4;
                c=3;
        return 0;

        }
        else if(choice==25){
                r=4;
                c=4;
        return 0;

        }
        else
        return 1;
}
  

void display(char a[5][5])
{
   

    printf("\t _____ _____ _____ _____ _____ \n");
        printf("\t|     |     |     |     |     | \n");
        printf("\t|  %c  |  %c  |  %c  |  %c  |  %c  |\n",a[0][0],a[0][1],a[0][2],a[0][3],a[0][4]);
        printf("\t|_____|_____|_____|_____|_____|\n");
        printf("\t|     |     |     |     |     |\n");
        printf("\t|  %c  |  %c  |  %c  |  %c  |  %c  |\n",a[1][0],a[1][1],a[1][2],a[1][3],a[1][4]);
        printf("\t|_____|_____|_____|_____|_____|\n");
        printf("\t|     |     |     |     |     |\n");
        printf("\t|  %c  |  %c  |  %c  |  %c  |  %c  |\n",a[2][0],a[2][1],a[2][2],a[2][3],a[2][4]);
        printf("\t|_____|_____|_____|_____|_____|\n");
        printf("\t|     |     |     |     |     |\n");
        printf("\t|  %c  |  %c  |  %c  |  %c  |  %c  |\n",a[3][0],a[3][1],a[3][2],a[3][3],a[3][4]);
        printf("\t|_____|_____|_____|_____|_____|\n");
        printf("\t|     |     |     |     |     |\n");
        printf("\t|  %c  |  %c  |  %c  |  %c  |  %c  |\n",a[4][0],a[4][1],a[4][2],a[4][3],a[4][4]);
        printf("\t|_____|_____|_____|_____|_____|\n");

}
void main()
{
    char player,choice;
    do
    {
    pc++;
//    clrscr();   
    printf("\t\t MINE SWEEPER------> DEMO");
    printf("\n\t\t*************************");
    printf("\n\n\tEnter the name of the player:");
    scanf(" %s",&player);
    intro(&player);
    make();
    play();
    printf ("\n\n\t GAME OVER!!\n\n");
        printf("\n\n\tDo you wish to continue?(Y/n)");
        scanf(" %c",&choice);
    if(pc>3)
        {
                printf("\n\n\tOOops!! You have exceeded your maximum no: of chances well.. Better luck next time..\n\n");
                exit(1);
        }

    }
        while((choice=='Y'||choice=='y'));

                             
}