Summer training students' planet

November 16, 2017

Jason Braganza

Do You PEP?

Short new series for me. Quick and Dirty Programming Posts
They’ll be tagged qdpp.
They’ll be raw, error prone and mostly works in progress.

A few reasons

  • to help me write for a few minutes (publicly) daily.
    I’ve realised slow and steady is a good way to build a body of work, (Godin, Kushal).
    Even if the beginning is slow and shitty.
  • to save myself searching the web for stuff I need to have handy.
  • these are primarily for me. If they help you as well, that’s a bonus!

Let’s start with PEP.

I’ve learnt that to learn anything well, it’s best to learn from the source.
Go to the well.
Don’t read about the Black Swan, or try to figure out from blogs what Antifragility is.
Go read the darned Incerto!
So when it comes to programming, I should do the same.

use-the-source-luke[1]


And everytime I learn something new with Python, I’m referred to a PEP as the source.

  • When is Python 3.7 out? Check the PEP.
  • What on God’s green earth are docstrings? Check the PEP.
  • Will PyPI crumble under its own weight? Or will there be redundant options? Check the PEP.
  • How do you write Python so that it’s comprehensible? Readable? Is there a style guide of sorts? Check the PEP.
  • A short treatise on what Python is about? Its Zen if you will? Check the PEP.
  • What is a PEP? Go, check the PEP!

So, a PEP (Python Enhancement Proposal) is a design document,

And as to why, the very first one explains it much better than I ever could.

So if you must know, where the Python rabbit hole conclusively ends, it most probably does in a PEP.


  1. Image source: https://adastraerrans.com/archivos/use-the-source-luke.png ↩︎

by Mario Jason Braganza at November 16, 2017 07:38 AM

November 15, 2017

Shashank Kumar

Python Game Challenge by PyDelhi

PyDelhi organized Python Game Challenge on 11th November, Saturday, 2017. Here’s what happened!

Python is multi-talented friend of ours which can assist on all our crazy projects irrespective of the type. PyDelhi came up with the idea of showcasing an underrated potential of making games via competition. Participants were asked to follow only 2 rules for doing so
1) Game should be developed using Python
2) It should be developed on the venue during the given time
and there begins the competition. We’ve recorded some of the game pitches by participants and gathered few words from them about their experiences below. And after the pitches we’ll announcing winners later in the blog.

Chessmate

Github Repository

https://medium.com/media/1869d52fd16c38d275b1b07882e4d7a0/href
It started 1 Hour late, but the 1 Hour wait was worth it. It started by a talk on Open Source Data, exploring different data sources and Public APIs and how they can be used as a potent tool in a country like India with fewer Hardware resources for countering Air pollution which was at its worst in NCR in the ongoing week.
2 Hours into the challenge, we working on figuring out the design and the schema of the codebase to create the game. An hour later our chessboard was fully functional and we were coding on tasks like-
- Moves validation
- Checkmates
- Knights and Pawn special cases
We finished the game 30 minutes before the end time and performed end to end testing and were the first team to finish and present the hack out of the total two who completed it.

Arrow Monster

Github Repository

https://medium.com/media/59592a0633ab8f6867f34abd5ff24fc8/href

Hit and Win

Github Repository

https://medium.com/media/beb369ce13a2ed1edbd53fa9f83d4486/href
The idea to make this game “thor” is to showcase how easy can it be to interact with physical computing hardware devices with Python programming language, we knew most of the participants if not everyone will be making software games so we decided to make “Thor” a miniature version of hammer game you must have seen/played in arcade game centers.
We made it using Force sensitive resistor as sensor a micro-controller and few LEDs, the score is sent to PC via serial port and a daemon handler written in Python parses that using PySerial library! The result was not perfect but we achieved proof of concept and we will surely work on improving it.
The event was really good and happening, we look forward to attend more such events/hackathons by PyDelhi. Initially we get less support/interests from volunteers who stopped by seeing us playing with circuits on a software based hackathon but when we demonstrated everyone was curious to learn more about our game which was our primary goal! The presentation experience was lukewarm and an area to work on, if it could be more interactive where every team is involved (apart from just judges) asking questions, suggesting improvements it’d be more fun. Cheers to PyDelhi for conducting such a successful event. :)

Maria

Github Repository

https://medium.com/media/b3ac3155c8dd2ccbf2f7c41dc2922462/href
It was great pleasure to be a part of this event. I entered in any
competition out of my college for the first time and it was a great
experience. I just a completion post on meetup group and the main
purpose i came there was to see how other people make game. I on the
other hand had no knowledge how these games are made.When the event
started someone said game can be made only using python as well. I also
entered the completion without any knowledge of anything and then i
started discussing the game with my partner and started building the
game at around 2. I had no knowledge of PyGame so we starting doing what
we wanted to instead of making a perfect game.
We first made a base (box) using PyGame, just googled it. Then we
started loading images of character, keys and bricks into the box, then
wrote an algorithm so that character won’t go out of the box or does not go
behind the bricks and a few other things in the remaining time.
But its not about what we did, its about what we learned. With no
knowledge of any game library like PyGame we made a small game. Now,
when i read a little about PyGame it’s completely clear what were we
doing wrong. Overall it was a great experience and the organizers were
great as well who gave goodies to participants as well.

Up Up Away

Github Repository

https://medium.com/media/c872da76db1890651698f8ff75b62626/href

And the winners for Python Game Challenge are Chessmate, Arrow Monster and Hit and Win. Congratulations to all the participants who won and thank you all for coming to the PyDelhi meetup. Keep in touch on our meetup, twitter and facebook page for updates on upcoming events.


Python Game Challenge by PyDelhi was originally published in Shanky’s Brainchild on Medium, where people are continuing the conversation by highlighting and responding to this story.

by Shashank Kumar at November 15, 2017 05:30 PM

November 14, 2017

Mohit

The Last Key!

Hope you guys have watched the trailer, The Last key.  If not I dare you to watch it.



Okay, joke aside, this blog post is about cryptography and public keybase keybase.io.

Crypto-What?

So these days when cyber crime, identity theft as common as bug in your code, people are getting insecure with their internet transactions, chat over various media and the threat of being spied remains the same.  This threat leads some security enthusiast to find a way for a secure transactions over internet and we call this field as Cryptography.

Cryptography is the study to find secure methods to transact securely between two parties which may or may not be on internet.  Cryptography is as old as human politics :p

Kings of different nations need to transmit messages securely so that the message do not get tampered or leaked by any medium in between and to overcome this threat they use various methods which in today's modern world known as "algorithms".

Encryption

Encryption is nothing but the process of encoding message into a form of jargon which can only be understood if you have appropriate key.  It is more like, you can only read the contents of a locked diary unless you have the key to unlock it.

More resources on encryption are provided here.

Why encrypt?

Why encypt?...

Like anyone you might not like when someone peeks at your life without your consent.  Say, how would you react if someone reads your personal diaries without your consent? I guess, you would be infuriated, right?

Now, how helpful it would be if anyone tries to read your diary but can't understand what is written because of the bad writing you have :p
Or say if you have written the diary in mirrored language just like DaVinci.

This is what is called encryption and everyone needs it unless you know a language nobody understands other than you :p.

What is Public Key and Private key?

Keys, like any general key are nothing but a way to unlock the path to your secrets.  In cryptography, keys are the codes required to decode the encrypted secrets we all try to hide from others. So, whatever happens to you, never loose your key or you will be locked out of your own secrets.

In Cryptography, there are two types of keys, public key and private key.  Anyone with encrypted message for your public key can't access the message unless he have your both the keys, public and private one.

Since public keys are meant to be published publicly and distributed to all, you should never disclose your private with anyone and carefully protect your private keys with a strong password, maybe diceware one :D

So, how to publish your public key to all, here are two ways:
1. Mail to them your public key so that they can understand your jargon.
2. Publish your public key on the key base like keybase.io.

To understand the public key cryptography, watch the following video, it will sure help you :)




Keybase

Keybase is a PGP key directory that maps social media identities to encryption keys in a publicly auditable manner. It provides various utilities like, chatting with someone else using pgp encryption.

It is another method to publicly publish your public key so that only trusted people can transact with you over internet.



 So, follow me on keybase to understand my jargon messages.


Note: Whenever I says transact, it can be any kind of transaction like money transfer, chatting, information exchange and so on.

Till then,

To infinity and Beyond!

by Abstract Learner (noreply@blogger.com) at November 14, 2017 09:28 AM

Pycon India: Journey begins!


Ok! everyone. Get ready to hear a very interesting story about a Python: a vicious snake in the memory of our computers. The story has many twist, drama, suspense and adventure. Try to keep it up with me.

It was hot long summer day when I landed on the webland of DGPLUG, searching for some fun online training to help me find the magic world of opensource softwares, and “Google” told me about this very famous webland “DGPLUG” where the wizard Kushal and his friends helps people like me to find the magic doors of open source world without even meeting them in person.

With time, those wizards helped us well in learning various new magic spells and then there comes a day when to achieve a great skill, we all need to meet in person, but… how? Every wizard is from different dimension! So we all settled down to meet on Earth on a very special occasion of Python: rejuvenation day. I was little sceptical at first, but I am glad I chose the sacred path of Python. And all thanks to DGPLUG webland to introduce me to magic of Python and open source.

I was kind of new to all these Python spells and all, so I decided to help people in arranging the Python day we call “Pycon India”, to learn more about other python wizards whom I don’t know.

All new wizards(including me) who wants to help in organising the python’s Pycon India should reach the Earth a day before and help other wizards.

I reached Earth, found many new wizards out there who wants to help just like me and we all had great discussion about the event to be come in upcoming days. I also found some remote wizards from another dimensions who were there to help and were also from DGPLUG webland. Few of the wizard I met was known by @thebigj, @cyber_freak and @championshuttler.

Okay! That’s enough for today, will continue next on my first day experience.

by Abstract Learner (noreply@blogger.com) at November 14, 2017 09:25 AM

November 13, 2017

Kshithij Iyer

The best answer I could ever find on the internet.



The best answer I could ever find on the internet.

November 13, 2017 01:26 PM

"People will always fear what they don’t understand and what’s beyond their limit of..."

“People will always fear what they don’t understand and what’s beyond their limit of understanding.”

- Kshithij Iyer

November 13, 2017 01:14 PM

If some people could understand this, life would have been a lot...



If some people could understand this, life would have been a lot easy!

November 13, 2017 01:06 PM

November 12, 2017

Kshithij Iyer

Ashwani Kumar Gupta

List comprehensions in Python and their advantages

List comprehensions in Python are a simple and concise way to create lists from an expression. The syntax for list comprehension was introduced in PEP 202. It is a very natural way to create lists, just like the mathematicians use to do. For example,

S = {x² : x in {0 ... 9}}
V = (1, 2, 4, 8, ..., 2¹²)
M = {x | x in S and x even}

The syntax for list comprehensions are pretty straighforward. It consists of an expression followed by one or more for clauses followed by one or more optional if clauses. All this are written inside a pair of square brackets [ and ]. List comprehensions make our code more readable and concise as it reduces the number of lines of our code. As an example see the following snippet.

>>> # The following snippet creates a list of squares for numbers from 0 to 9
>>> # Using for loop and appending to list
>>> squares = []
>>> for x in range(10):
...     squares.append(x*x)
...
>>> squares
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
>>>
>>> # Using list comprehensions
>>> squares_using_list_comprehension = [x*x for x in range(10)]
>>> squares_using_list_comprehension
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

As you can see, both of the methods generate the same list as the result. The second method taken only 1 line as compared to the first method taking 3 lines. Clearly, list comprehension is a winner here.

Apart from making the code more readable and concise, list comprehension has another noteworthy advantage, performance. Yes, the execution time for list comprehension is much faster as compared to the normal method of appending to the list. Let’s time our two methods to see. Let’s create a file list.py with the following code and execute it.

import time

def clock_execution_time(function):
    def wrapper_function(*args, **kwargs):
        start_time = time.time()
        function(*args, **kwargs)
        end_time = time.time()
        print('The {} function took {} seconds'.format(function.__name__, end_time-start_time))
    return wrapper_function


@clock_execution_time
def gen_squares_normal(n):
    squares = []
    for x in range(n):
        squares.append(x*x)
    return squares


@clock_execution_time
def gen_squares_listcomp(n):
    return [x*x for x in range(n)]


if __name__ == '__main__':
    result1 = gen_squares_normal(100000) # Choosing a large number for visible time difference
    result2 = gen_squares_listcomp(100000) 
    if result1 == result2:
        print('Both results are equal')
    else:
        print('Inequal results')

$ python list.py
The gen_squares_normal function took 0.013292074203491211 seconds
The gen_squares_listcomp function took 0.00794363021850586 seconds
Both results are equal

Clearly list comprehensions are way faster than the appending method. But, why?
Turns out that, every time you call the append function, the append attribute has to be loaded and called as a function which slows down the process. Also, as the list is dynamically growing, it adds to the damage. On the other hand, for list comprehensions the elements are generated before putting them into the result list. So it has better execution time. So these are some of the advantages of using list comprehensions.


by Ashwani Gupta at November 12, 2017 04:42 PM

Kshithij Iyer

"Have you ever wondered how a cockroach survives a nuclear blast and dies when you spray..."

“Have you ever wondered how a cockroach survives a nuclear blast and dies when you spray Hit(pesticide) on it?”

- Kshithij Iyer

November 12, 2017 06:24 AM

November 10, 2017

Kshithij Iyer

Who am I? The arrogant young programmer or The shy polite...



Who am I?
The arrogant young programmer or The shy polite guy,
The moron or The larrkin,
The childish son or The matured friend,
The bandit or The guy who goes by the rules,
The best grandson or The worst grandson,
The playboy or The boy who was played,
The loved one or The hated one
Or am I all of it or none of it.
I guess I’ll never have an answer for it.
#WhoAmI
(at Nh48 Pune)

November 10, 2017 01:43 PM

Mannu Gupta

Got this error, when i ran `web3.eth.accounts`

Got this error, when i ran `web3.eth.accounts`

Error: Invalid JSON RPC response: undefined
at Object.InvalidResponse (/home/abhi/Documents/ethereum/node_modules/web3/lib/web3/errors.js:38:16)
at HttpProvider.send (/home/abhi/Documents/ethereum/node_modules/web3/lib/web3/httpprovider.js:95:18)
at RequestManager.send (/home/abhi/Documents/ethereum/node_modules/web3/lib/web3/requestmanager.js:58:32)
at Eth.get [as accounts] (/home/abhi/Documents/ethereum/node_modules/web3/lib/web3/property.js:107:62)
at repl:1:10
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at REPLServer.defaultEval (repl.js:240:29)
at bound (domain.js:301:14)
at REPLServer.runBound [as eval] (domain.js:314:12)
at REPLServer.onLine (repl.js:441:10)

I tried `web3.isConnected()` it returned `false`. Any help would be great

by Mannu Gupta at November 10, 2017 01:12 PM

November 08, 2017

Kshithij Iyer

Baked beans and toasts. #bakedbeans #toasts (at Alkapuri)



Baked beans and toasts.
#bakedbeans #toasts (at Alkapuri)

November 08, 2017 03:09 PM

November 06, 2017

Himanshu Awasthi

Impact of PyCon India ’17

Hello Friends ! I attended PyCon India over this weekend which was one of the greatest & biggest tech event in India . PyCon India is  the premier conference in India conducted annually by the Python developer community & I feel really proud to be the part of this event. First of all I would like to congratulate organizers & volunteers for making this event successful . This time PyCon India was biggest event in each dimensions , in four days event  their was 54 speakers  , 16 workshops  & 34 talk which shows the beauty of this event .

Impact of PyCon India ?

As I mentioned above PyCon India ’17 was one of the biggest event of India & I share my experience about the event. lets start from the venue :

Venue : Initially Conference venue was JNU but due to some management issue Shaheed Sukhdev College of Business Studies finalized as venue for the Event & College have one of the best auditorium  hall . Infrastructure of the college is truly  amazing. DNjFOtPXkAErygM

Key-note Speakers : Key -note speaker of any conference are the soul of that event & this time in PyCon India their are three key -note speakers Peter Wang  , Noufal IbrahimElizabeth Ferrao   . listen talk of  Noufal Ibrahim always a great experience , and Community centralized talk of Peter Wang & Elizabeth inspired me to stick with community & improve more things in my home town .

DN2N3vuVoAEchVE.jpg:large

Food : PyCon Conferences always popular for their delicious  food I’m not going to tell more about this I have few screen shots which describe all story about food.

& If you are volunteer then you get extra wages like invitation to attend after party :

 

Swags : Apart from Key -note speakers most of the  people always attracts for the swags & If you are speaker , mentor or volunteer of any PyCon you gets lots of swags like stickers , t- shirts & in PyCon India you get ,,,,,, lets checkout the tweet of  TechDeviant

pycon3

& also a beautyful pendrive from google. Thank You ! PyCon India for these swags .

Dev Sprint & WorkShops : PyCon India is the best platform for students where students can understand how to start contribution to open source projects , Dev Sprint helps people to learn how to contribute to upstream projects. Approx 60% of the attendee of the conference was students which shows how much student eager to learn more about python & workshop help them a lot.  Atmosphere of Dev Sprint was really amazing .

DNr7u0IX4AEZ4Ky

All these things was the part of conference,  apart from all these thing what this conference give me ?

& the answer is lots of new friends again getting chance to meet awesome community members , & most important very first time interaction with DGPLUG people .

always feels good to listen Kushal Das , the way he guided us really fruitful for every one. Thanks to PyCon Pune ’17 which gives me mentors like Kushal , Sayan & Chandan .

So In PyCon India DGPLUG guys meet each other , Kushal takes a feedback session in tea time ,  some captures of DGPLUG meetup during the conference here :

Can’t wait to meet you again , See you all at PyCon Pune’18 .

People who still not the part of DGPLUG , hurry up join us @IRC channel #dgplug

Book you tickets for PyCon Pune ’18 Book Your Ticket Here  .

I’m really proud be part of Python Community . Sure very soon KanpurPython will be organize a Python Conference in Kanpur .

In the end of the conference in feedback session we get some good reviews which was the hard work of organizer & volunteers & some bad reviews which we try to improve next time . These all volunteers make this event possible & I’m also one of them .

DN9Q2QFVoAAJTRR

So this was my experience about grand tech event PyCon India .

Now people who belongs to Kanpur & near by Kanpur who was not able to attend PyCon India , Kanpur FOSS provide them a opportunity to understand the world of FOSS & Open Source.  Their is an event Introduction to Open Source at 11 November , 2017 in Allenhouse Institute of Technology , Kanpur . People who wants to attend this event Kindly book their ticket from link given below :

https://www/bit.ly/KanpurFossEvent

Thank You!


by Himanshu Awasthi at November 06, 2017 09:48 PM

Kshithij Iyer

And my M.Sc ends at this note. (at Pune, Maharashtra)



And my M.Sc ends at this note. (at Pune, Maharashtra)

November 06, 2017 05:32 AM

Semester end cleanup this semester. #35liters #caffeineaddict ...



Semester end cleanup this semester.
#35liters #caffeineaddict (at Pune, Maharashtra)

November 06, 2017 05:27 AM

November 02, 2017

Bhavin Gandhi

Weird color rendering on Google Chrome

Recently I updated my machine with dnf update and suddenly noticed that Chrome was showing really weird colors. I was like, what? seems like something happened to my eyes 🙁 😲 Later I realized that it was just Chrome which was…

The post Weird color rendering on Google Chrome appeared first on GeekSocket.

by Bhavin at November 02, 2017 07:15 PM

November 01, 2017

Mohit

E-yantra is your mantra!

This year, I registered for e-yantra and this post is the part of my Journey to it.

E-Yantra eYRC guide

E-yantra home page describes e-yantra as:
An initiative by IIT Bombay that aims to create the next generation of embedded systems engineers with a practical outlook to help provide practical solutions to some of the real world problems. Sponsored by MHRD under the National Mission on Education through ICT program.
E-yantra is an initiative taken by IIT-Bombay, sponsored by MHRD to create better learning oppportunites for teachers, students and colleges. There are various programmes that run under the roof of e-yantra to help improve both the society and education standard in India.

Formation or Foundation

IT Bombay envisages the ‘e-Yantra’ platform to harness the intellectual talent of young India to create utility based robotic applications for usage across variety of applications such as: agriculture, manufacturing, defense, home, city maintenance and services industries

Initiatives

For Students

  1. e-Yantra Robotics Competition, eYRC
  2. e-Yantra Summer Internship Program, eYSIP

For Colleges

  1. e-Yantra Lab Setup Initiative, eLSI
  2. e-Yantra Ideas Competition, eYIC
  3. e-Yantra Symposium, eYS

For Teachers

  1. Two-day Workshop on Introduction to Robotics, link
  2. Task Based Training, link
  3. Task Based Training Challenge

Others:

  1. e-Yantra Farm Setup Initiative, eFSI
  2. e-Yantra Resource Development Center, eYRDC
Note: For further information, please follow the links provided.

How to get involved in …

  • Go to their website before deadline and register for any of the above mentioned competitions to improve yourself and your college.
  • Subscribe to their Facebook page to get updates.

Reference

Till then:
  • To infinity and beyond!

by Abstract Learner (noreply@blogger.com) at November 01, 2017 05:25 PM

Kshithij Iyer

"In the race between the tortoise and the rabbit, the rabbit lost the race because he was..."

“In the race between the tortoise and the rabbit, the rabbit lost the race because he was overconfident and inconsistent but what if we had a rabbit who was not overconfident and consistent then what?”

- Kshithij Iyer

November 01, 2017 01:50 PM

"What if I made decision trees for every decision in my life would I be in a better state, Who cares..."

“What if I made decision trees for every decision in my life would I be in a better state, Who cares whatever happened was for my own good!”

- Kshithij Iyer

November 01, 2017 12:38 PM

October 30, 2017

Deepika Upadhyay

Wind of realisation

It’s like I have entered a world , I had teleported to development, open-source world where continuously something is getting created , when I used to think of some practical implementation of a thing that mere thought that it could be done was not so simple to imagine with the amount of work and research , but when you enter a world where this is the primary motto and see people driven to help , put a hand forward to support you , it feels like dreams do come to reality with the magical world not yet discovered but present around you, do diversify your connections , you might never know another new world might be waiting for you i got to know about open source from college senior o last year because I participated in a debate , and when you form a neural connection of these worlds something amazing , something out of the box will be innovated ,afterall it’s in connecting the dots  , it seems like I can overcome that state of monotonous cursing to have not accomplished learning and that turned it into effortless task cause when you build things learning comes as a by product
learn from people especially their failures cause they will elaborate and give reasons for why they failed ,but on success maybe this might be not so easy for even them to find a thing that worked cause it’s a mingle of many
Hear out some interesting people you will make more discoveries of how they see the world ask a poet , what is there in the words that’s beautiful, ask an algorithmist how he sees algorithm in daily life , ask a painter how he create beautiful masterpiece with just a simple pen and the back of his notebook,ask how a musician visualise the tones , which kind of music gives him goose bumps
 Thats how you can taste life in different forms , reading books , hearing tales, creating a workaround out of a failure cause success doesn’t taste as good as rising from hardship does 🙂
#notetoself

by deepika at October 30, 2017 10:43 PM

Kshithij Iyer

22

When you are small you always want to grow up so that you can do whatever you want. But as time passes you realize that life was a lot easy when you were young. You know it’s a lot easy to blame someone for what wrongs they did to you but accepting that you gave them the chance to do wrong to you is difficult but that’s what growing up means, understanding and moving on cause time never stops.

In these last 22 years, I have seen many ups and downs, lefts and rights, celebrations and mournings. It was all experiences where some were good and some were not so good. I have been into trouble(I have to say quite often! :P) but have always found my way out of it every time. I have made the same mistake multiple times or should I say every time? And yet not learned from them. I have made friends and terrorists( Because I used to play as the counter-terrorist in CounterStrike {The video game}). I have seen people who fell for me and people who’ll push me out of the window if they get a chance. Sometimes I had everyone behind me and sometimes it was a lonely walk down the unchartered roads. I have been just like Anakin Skywalker and unfair like Darth Vader. I have shown both the maturity of Batman and the craziness of Joker. I have fallen in love with many women and eventually fallen out of it every time. I have made the perfect corner as well as I have crashed. I have played the failure as well as the topper(The secret was not to care about marks.). I wouldn’t say it was easy to grow up but yeah it was fun.Growing up taught me a lot, somethings were easy to grasp and others were learned through the hard way. All these years taught me that everything is possible you just need a stubborn heart and a crazy mind. 

In the end, I would like to quote John.A.Shedd:

A ship is safe in harbor, but that’s not what ships are for. 

So my advice to all those who are younger than me is to have the courage to make the jumps or should I say have the courage to at least try to make them? And lastly, thank you to everyone who stuck together for all these years and thank you to everyone who left for the good, you guys have made all these 22 years worth living, worth enjoying, worth exploring, worth celebrating and a whole lot entertaining.

Love now and always,

Kshithij 

October 30, 2017 06:30 PM

"When fear hits your brain really hard then after a while you just become senseless towards it."

“When fear hits your brain really hard then after a while you just become senseless towards it.”

- Kshithij Iyer

October 30, 2017 06:54 AM

October 29, 2017

Mohit

Everything about Libreboot!

LibreBoot

In this blog post, details about Libreboot, its purpose and all is provided in detail. To understand the concept of libreboot better, read my posts on BIOS vs Bootloader, and all the other related blog posts, referenced here.

All computers need BIOS firmware for it to initialise and run programs, games and other software. Refer my blog post on BIOS and bootloader. At this time the most supported hardware is older because it sounds like Intel is not very friendly to this movement and does not like to release documentation or information about their products.

What is it?

Libreboot (formerly known as GNU Libreboot[5]) is a free software project aimed at replacing the proprietary BIOS firmware found in most computers with a libre, lightweight system designed to perform only the minimum number of tasks necessary to load and run a modern 32-bit or 64-bit operating system.[1]

Libreboot is established as a distribution of coreboot without proprietary binary blobs. Libreboot is not a straight fork of coreboot; instead, it is a parallel effort that works closely with and re-bases every so often on the latest coreboot as the upstream supplier, with patches merged upstream whenever possible. In addition to removing proprietary software, libreboot also attempts to make coreboot easy to use by automating the build and installation processes.[2]


Why use it?

You might be wondering why should you even be worried about such a thing that does not affect much. But let me tell you, if you are an open source enthusiast and don’t like the hidden curtains behind your softwares and computers. You should give it a shot and also it is faster, safer and more open than your current BIOS firmware.

But the real reason being, If you are privacy freak and worried about the backdoors that few software companies and government agencies might have implanted on your system without your consent, you should consider using libreboot as your BIOS firmware. You might have replaced all of the hardware, operating system and all utility programs to their open-source equivalent to have more control over those. But, did you really changed all the softwares?, even those required to put your system live to run other softwares? Yes, I am talking about BIOS firmware, hardware realted firmwares like bluetooth, wifi(which are not most-probably be open-source) and bootloader.

You might have also replaced to an open-source bootloader, may be GRUB, but what about your BIOS firmware? The hardware manufacturers usually install their closed source version of BIOS to fuel up your system over which you have no control and you don’t know, if it might contain any malicious software uptil now…

According to Libreboot website:

Why use libreboot? Many people use non-free boot firmware, even if they use GNU/Linux. Non-free BIOS/UEFI firmware often contains backdoors, can be slow and have severe bugs, where you are left helpless at the mercy of the developers; you have no freedom over your computing.

Advantages of LibreBoot

  • Fast
  • Secure with no backdoors
  • Open Source and released under GPL V3.0

Libreboot provides the missing jigsaw puzzle piece which you must be finding for ages but didn’t find. So, you need libreboot to fix your whole system but there’s a catch! Since, these BIOS firmware are very low level and hardware dependent programs, libreboot is not supported by all hardware that exist in market, mostly because the hardware related specifications are not open to all.

But also, there’s a good news which you must be waiting, how to install it on your system?

  1. Buy the supported hardware, a system with all the open source hardware and software. Here are some suggestions and some suppliers which provide preinstalled libreboot in their system.

  2. Install qemu, a virtualization software and put the piece back to its place. Refer my Blog post on Qemu to know more.Here

Founder/Creator

LibreBoot is created by Leah Rowe, who created this project to make a “Binary Blob” free version of “CoreBoot”. She is also the founder of Minifree, only company that sells GNU+Linux computers with the Libreboot firmware and Trisquel GNU+Linux operating system preinstalled.


History

Libreboot was launched in 2013 to make a free software version of coreboot (by removing “binary blobs” included in the coreboot source code). Since February 2015 the project has been endorsed by Free Software Foundation (FSF). The project became part of the GNU Project in May 2016.

Coreboot

Coreboot (formely known as LinuxBIOS) is another opensource firmware project that further leads to Libreboot but there’s a difference between both of them. Coreboot, although being opensource, use various propietary firmwares along to support more number of hardware and devices.

Nothing better than simply said: Libreboot is basically Coreboot without “Binary blobs”.

According to wikipedia:

coreboot has a number of variants from its original code base each with slightly different objectives:

  • librecore - A variant with more focus on freedom, non-x86 and firmware development frameworks.
  • libreboot - A variant with a primary focus to remove all binary blobs.

To know more about coreboot follow its wikipedia page here or its documentation here.

Journey to GNU family

In September 2016 the lead developer announced that the project would leave the GNU Project and in January 2017, Richard Stallman announced that Libreboot was released from the GNU project and later in April 2017, Libreboot again join forces with GNU family. Refer this.


Supported Systems

As stated above, since Libreboot and coreboot, both have to ported to every chipset and motherboard, they are available for only a limited number of hardware and motherboard platform. The list of supported hardware can be found here.

‘Supported’ means that the build scripts know how to build ROM images for these systems, and that the systems have been tested (confirmed working). There may be exceptions; in other words, this is a list of ‘officially’ supported systems.

It is also possible to build ROM images (from source) for other systems (and virtual systems, e.g. QEMU).


How to install it?

Since to install libreboot various dependencies have to be met, most important being the hardware support. So, The install instruction requires you to install “Qemu” as a dependency. Read this post to get more insights. Also, Since libreboot might not be supported by hardware, the following install procedure is meant for the libreboot installation on Qemu virtual machine.

Download from source/git[3

  • git clone https://notabug.org/libreboot/libreboot.gitFollow this page for further reference.

Installation

* * * * *

Note: If for some reason, you fail to install libreboot yourself. You may have a GNU+Linux User Group, free software workshop or hackerspace near you that can help you with installing Libreboot, for instance.


Wanna Contribute!

Great, You landed exactly the place you wished for. I am contributing to it and will document everything for you to help. This post and others are part of my contribution journey.

Contact the project maintainers on:


References

To all the blog posts required by anyone to get the grasp of the BIOS, bootloader, LibreBoot, OpenSource and its contribution, and other softwares like qemu.

  • To understand how your computer initialises, follow this post.
  • Binary Blobs
  • To contribute to open source softwares, read this guide
  • My Blog post on how to contribute to open source software (OSS).
  • Free as in Freedom.
  • LibreBoot documentation.

Till then,

To infinity and Beyond!

by Abstract Learner (noreply@blogger.com) at October 29, 2017 11:59 AM

Kshithij Iyer

"As time passed they were lost in each other so much that they didn’t know when to come out of..."

“As time passed they were lost in each other so much that they didn’t know when to come out of that labyrinth.”

- Kshithij Iyer

October 29, 2017 10:22 AM

October 28, 2017

Mohit

Everything about QEmu!

Qemu

(Created by: Fabrice Bellard )

It is the blog post where all the required details are gathered for you to get the insights of Qemu software, its installation and how to get started with it and open source softwares.

What is it?

QEMU is a generic and open source machine [emulator] and [virtualizer]. When used as a machine emulator, QEMU can run OSes and programs made for one machine (e.g. an ARM board) on a different machine (e.g. your own PC). By using dynamic translation, it achieves very good performance.

When used as a virtualizer, QEMU achieves near native performance by executing the guest code directly on the host CPU. QEMU supports virtualization when executing under the Xen hypervisor or using the KVM kernel module in Linux. When using KVM, QEMU can virtualize x86, server and embedded PowerPC, 64-bit POWER, S390, 32-bit and 64-bit ARM, and MIPS guests.[1]

According to wikipedia:
QEMU is a hosted virtual machine monitor: it emulates CPUs through dynamic binary translation and provides a set of device models, enabling it to run a variety of unmodified guest operating systems. It also can be used with KVM to run virtual machines at near-native speed (requiring hardware virtualization extensions on x86 machines). QEMU can also do CPU emulation for user-level processes, allowing applications compiled for one architecture to run on another.

In a nutshell, You can run your system as a completely different hardware configuration without affecting anything on your system.

History

The history of qemu is still a mystery to me. Hope you understand git history :)
The git history of Qemu is here.

If you find more about qemu's history, comment below to share.

How to install it?

1. From .tar.xz

Follow these steps:
  1. wget https://download.qemu.org/qemu-2.xx.x.tar.xz
  2. tar xvJf qemu-2.xx.x.tar.xz
  3. cd qemu-2.10.1
  4. ./configure
  5. make

Note: Replace qemu-2.xx.x.tar.xz with the correct version number. (qemu-2.10.1.tar.xz)

2. From Linux Package Managers

QEMU is packaged by most Linux distributions[2]:

  • Arch:
    pacman -S qemu
  • Debian/Ubuntu:
    apt-get install qemu
  • Fedora:
    dnf install @virtualization
  • Gentoo:
    emerge --ask app-emulation/qemu
  • RHEL/CentOS:
    yum install qemu-kvm
  • SUSE:
    zypper install qemu

3. From Source/Git

  1. git clone git://git.qemu.org/qemu.git
  2. cd qemu
  3. git submodule init
  4. git submodule update --recursive
  5. ./configure
  6. make

4. MacOs

  1. brew install qemu


How to set up your system using qemu?

(Follow this qemu documentation if need further reference.)

Unlike other virtualization programs such as VirtualBox and VMware, QEMU does not provide a GUI to manage virtual machines (other than the window that appears when running a virtual machine), nor does it provide a way to create persistent virtual machines with saved settings. All parameters to run a virtual machine must be specified on the command line at every launch, unless you have created a custom script to start your virtual machine(s). However, there are several GUI front-ends for QEMU:

  •     virt-manager
  •     gnome-boxes
  •     qemu-launcher
  •     qtemu
  •     aqemuAUR

Additional front-ends with QEMU support are available for libvirt.[3]

QEMU is a processor emulator and supports emulation of ARM, PowerPC, SPARC, x86, x86-64 and more. QEMU has two operating modes[4]:
  •  User mode emulation: QEMU can launch Linux processes compiled for one CPU on another CPU, translating syscalls on the fly.
  •  Full system emulation: QEMU emulates a full system (virtual machine), including a processor and various peripherals such as disk, ethernet controller etc.

To setup a working environment, a virtual machine on qemu, follow following steps:
  •  


Wanna Contribute!

Like any open-source project, anyone excited enough, can contribute to qemu.  First to get started in open source world is to start using them.
  1. Install qemu on your device.
  2. Test it for a few days and check if it is your type or not.
  3. If it suits you, take a step ahead towards its contribution, peek into its source code. (You can download its source code from its git repository here or its Github repository here.
  4. Contact with the project maintainers and ask them to help if needed.
  5. Get yourself assigned to few simple and basic issue/tasks by the project maintainers to dive a little deeper.

You can also take help from various open source awareness programs like:

To Contact the project maintainers:
  • Join the project mailing list for their updates and to ask any doubts if you have.
  • Join their group on whatever medium they have (Slack, IRC, Telegram, Google Groups...).  The irc channel for qemu is #qemu on freenode network.




References

About:

Setup:

Others:


Check my blog posts on LibreBoot and its contribution to get more insights.
Till then, To infinity and Beyond !

by Abstract Learner (noreply@blogger.com) at October 28, 2017 04:33 PM

October 26, 2017

Kshithij Iyer

"If you ever want to see a technical student cry, add a few management papers in his curriculum."

“If you ever want to see a technical student cry, add a few management papers in his curriculum.”

- Kshithij Iyer

October 26, 2017 05:41 PM

"I just want you to drag me by my collar, slap me on my face, punch me in my stomach and then kiss..."

“I just want you to drag me by my collar, slap me on my face, punch me in my stomach and then kiss me.”

- Kshithij Iyer

October 26, 2017 05:39 PM

October 25, 2017

Kshithij Iyer

"She said, “you are not that good looking.” When she said, “You look sexy!”..."

“She said, “you are not that good looking.” When she said, “You look sexy!” And now I was lost between these two women.”

- kshithij Iyer

October 25, 2017 10:46 AM

Himanshu Awasthi

Pycon Pune ‘2018

Ticket for PyCon Pune is live now

Python

Today I have seen that date for Pycon Pune ‘2018 is out.

for more Information click here   PyconPune’18 .

I was attended Pycon Pune 2017 and that  event change my thinking about my future. I am 3rd year student of B.Tech computer science and belongs to Kanpur city of U.P.

When was I attend this event I don’t know more about Python Programming Language but during the event I met so many brilliant people who have brilliant knowledge about Python Language. I had seen that people who attended this event belongs to all category of people like students, employees, geeks, entrepreneur etc.

Talks was tremendous . people can see it here Talks_pyconpune.

Now when I see that Pycon Pune date is out so I want to be a part of this event as volunteer. I drop e-mail to Pycon Pune let see!!!!!! ^ ^

In upcoming year I am…

View original post 19 more words


by Himanshu Awasthi at October 25, 2017 09:27 AM

Kshithij Iyer

When someone asks you about your future plans!



When someone asks you about your future plans!

October 25, 2017 06:06 AM

October 24, 2017

Kshithij Iyer

"My dad said “you sound like some love failed kid on your blog”, I didn’t know what..."

“My dad said “you sound like some love failed kid on your blog”, I didn’t know what to tell him.
Dad! I just have a different perspective towards life or People are abusing the love these days.”

- Kshithij Iyer

October 24, 2017 06:34 PM

October 23, 2017

Kshithij Iyer

"Paradise, show me a real place Where all of our dreams come home Where our forever and always Is the..."

“Paradise, show me a real place
Where all of our dreams come home
Where our forever and always
Is the only kind we know
Jupiter gave us an empire
A ring to wrestle fate
A promise never to expire
When tides are hard to chase
Cause when all the sirens come
You’re still the one
And under the coldest suns
I’ll keep you warm
When all the hope is gone
You’re still the one
You’re still the one
You’re still the one.”

-

Max Collins (lyrics from the song “Still the one”)

Read between the lines people.

October 23, 2017 10:41 AM

"She is indeed a labyrinth of beauty where one can get lost and never wish to come back."

“She is indeed a labyrinth of beauty where one can get lost and never wish to come back.”

- Kshithij Iyer

October 23, 2017 09:15 AM

October 22, 2017

Vivek Anand

Tornado with systemd

Unlike Django or Flask, tornado is not WSGI based. It also ships with it’s own HTTP server and running the tornado server in production is not very much different from what you do while running it while developing. You may want to run the server in background though.

The systemd config file for tornado server that i am currently using is:

[Unit]
Description=Tornado server service file
After=rabbitmq-server.target

[Service]
ExecStart=/usr/bin/python /path/to/tornado/server/main/method.py
Restart=on-abort

[Install]
WantedBy=multi-user.target

For my use case, it should start after rabbitmq-server has started. After putting this script in /etc/systemd/system/ , you can start the server by:

sudo systemctl start servicename.service

It’s status can be checked using:

sudo systemctl status servicename.service

For people with trust issues, you can use curl or visit the site itself to reconfirm. In my case, the tornado server was a websocket server and not http. So, i had to put some additional parameters with curl which i got from here.

➜ curl –include \
–no-buffer \
–header “Connection: Upgrade” \
–header “Upgrade: websocket” \
–header “Host: http://127.0.0.1:8080” \
–header “Origin: http://127.0.0.1:8080” \
–header “Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==” \
–header “Sec-WebSocket-Version: 13” \
http://127.0.0.1:8080/ws

That’s it.


by Vivek Anand at October 22, 2017 06:07 PM

Kshithij Iyer

"Hmm! I am not justifying my actions but there were some reasons for everything I did."

“Hmm! I am not justifying my actions but there were some reasons for everything I did.”

- Kshithij Iyer

October 22, 2017 10:13 AM

"A time will always come when you’ll have to stop thinking about everything else and finish the..."

“A time will always come when you’ll have to stop thinking about everything else and finish the work which is on your desk.”

- Kshithij Iyer

October 22, 2017 08:37 AM

October 21, 2017

Kshithij Iyer

"So I had to go back to conclude the war, I had to go back fixed, patched and bruised. The final..."

“So I had to go back to conclude the war, I had to go back fixed, patched and bruised. The final round had just begun and I was ready to go down swinging or win it through a knockout.”

- Kshithij Iyer

October 21, 2017 04:30 AM

October 20, 2017

Kshithij Iyer

Crashed

Life goes real smooth till you crash. It could be a bike, a car, a plane or a life itself. Crashes show you that the unthinkable can happen. They are the bad experiences which happen, but anyway they are experiences which teach you a lot. A good life can teach you a few things or not teach you anything at all but a bad one teaches you a lot. For instance who is on your side in the rough times and who is not. But the hardest part is getting up after a crash, learning to forget what happened and go back to your normal life. Overcoming your fears which are left after the crash, the memories of the bad that happened to you. And eventually becoming the man/ woman you are supposed to be. 

Crashing doesn’t mean that you are a bad driver it means that you are a driver who has to learn by falling.

October 20, 2017 04:30 AM

October 19, 2017

Vipul Gupta

My First Official Project: #completed

Projects are fun, they provide a steep learning curve, you learn how to work in a team and how to contribute, solve problems. That’s what I used to think. Until I landed my first big project and here’s my account of how our project really happens.

What was the project about?

The project was about creating a Geographic Information System (GIS) based website for monitoring pollution scenario of a river and to assess its impact on the health of people using water from the river. GIS is a system which is designed to capture, store, manipulate, analyze, manage, and present spatial or geographic data.

We needed to choose a river on which we would build our system on. We chose Yamuna. Flowing through Uttarakhand, Himachal Pradesh, Haryana and Uttar Pradesh, passing by Uttarakhand and later Delhi, and meets its tributaries on the way. One of the most polluted rivers in our country and with all the efforts being made by the Government of India to cleanse the river and money being spent.

In short, the project was to create a website to monitor the condition of a river (in this case, Yamuna) in real-time having salient features like :

  • It should display the complete stretch of river (with important tributaries/streams) by digitization from satellite image (google maps or data published by ISRO).
  • Displaying all the sampling points and area of health survey
  • The system should facilitate user to add/edit/delete parameters for water quality assessment and health assessment.
  • The system should facilitate user to add/edit/delete values for the above-entered parameters.
  • The project should be able to show reports/graphs for the entered data (including correlation graph).

Who all were there?

Every successful project got an effective and productive team behind it which burns the midnight hours to make it what it is. The people without which this project could be made were:

  1. Ayush Agarwal
  2. Tanya Jain
  3. Parth Sharma
  4. Anuja Agarwal
  5. Ajay Tripathi
  6. Omkar

Where and other fine details?

The project was part of a competition, organized by the Department of Amity School of Engineering and Technology (ASET), Amity University, Noida. We worked under the guidance and advice of Ms. Madhuri Kumari, Dy. Director, Placement & Industry Relations, ASET. Without her help, it wouldn’t have been possible to accomplish this huge task. Our project was awarded the first prize in the competition.

My Contribution

There was a lot of work and issues were needed to be taken care of when the project was being started. Everyone took what issue they are interested to contribute and started working as we were behind our deadline. My interest was in the integration of Google Maps API in reports sections of the website that is designed to store, manipulate, analyze, manage, and present spatial or geographic data. The Google Maps API was needed to be customised accordingly for the project. Many markers, visible objects, landmarks were removed from the map for better visibility. Controls were rearranged and new were added to give have a better User Experience (UX). The code needed some additions to view our shapefile on top of the Google Maps API as a separate layer which itself proved to be a challenge.

As the deadline grew closer, we all kept our cool, believed in each other and worked together as a team to fix the remaining issue and bugs. Customisation and keeping the mixture of things that were just right for our project was imperative for the end product. Google’s Documentation of the API was a life-saver as I searched and scoured almost every page there was, to give the API all the features that we needed. With the right advice, help from our seniors and Alumni, innovative thinking and a lot of Teamviewer sessions, we finally did it and completed our project well ahead of the deadline.

Now what?

Well, now the problem has to be scaled and made bigger which can help actual people and organizations. Which will become the stage 2 of our project, as to releasing the product we created.

My Take from this Project

Projects like these make you experience a lot of emotions that you can’t while working alone. Personally, I learned a lot. A lot. Probably more than I ever could alone. They say practical knowledge is important. You develop practical knowledge when you apply your knowledge to work out a solution on your own or with the help of some like-minded individuals. That’s how. I see it now. I am not stating that studying or learning is not important. But what ask yourself? What benefit is it to you? Personally. When you can’t apply what you have learned in real life. Team management and communication skills also develop which helps in the long run. I hope I get to be a part of many more projects.

Till then live in the mix.


by Vipul Gupta at October 19, 2017 11:05 AM

Kshithij Iyer

October 18, 2017

Kshithij Iyer

Is it that part of the life when everything screwed and after a few bad chapter it’s all...

Is it that part of the life when everything screwed and after a few bad chapter it’s all fixed?

Kshithij Iyer

October 18, 2017 05:58 PM

October 16, 2017

Niranjana Deshpande

I pretend to be a poet

I pretend to be a poet,

To write in rhymes,

More often than not,

I write crimes. 
I wonder if what I write is new,

Or if I regurgitate things known to be true. 

Perhaps I mix words of others who came before me,

And pen them, lovely word chemistry! 
The impostor syndrome strikes all of us sometime soon,

What if in my case, it’s actually true? 


by niranjana at October 16, 2017 03:35 AM

October 15, 2017

Kshithij Iyer

October 14, 2017

Vivek Anand

Token based Websocket Authentication

At my day job, i had to implement websockets and thus authentication of the websocket connection came up. There were two different types of clients but, the authentication for browser client was the biggest headache.

For a normal HTTP request, we use cookies for authentication of a user. Websocket protocol in itself doesn’t define how a websocket connection should be authenticated. According to RFC 6455, under section 10.5:

   This protocol doesn't prescribe any particular way that servers can
   authenticate clients during the WebSocket handshake. The WebSocket
   server can use any client authentication mechanism available to a
   generic HTTP server, such as cookies, HTTP authentication, or TLS
   authentication.

So, the first thing that comes to mind is: Why not use the same cookies that we use for an HTTP request? I thought the same too but, eventually, decided to use token based authentication.

Why not use the cookie?
We are using Django for our main web application. Django and WSGI based python frameworks in general, are not built for long lived connections. So, for websockets we are using Tornado.

In Django, by default, cookies are not readable by javascript. They are marked as HTTP only and thus the browser uses the cookie only for making http/https requests to the origin server. It can be turned off by using:

SESSION_COOKIE_HTTPONLY = False

Screenshot from 2017-10-15 00-16-41

The above image is when you have SESSION_COOKIE_HTTPONLY = True .

Screenshot from 2017-10-15 00-42-28

This is when you set SESSION_COOKIE_HTTPONLY  to False. The “`sessionid“` is the one which will be used by the server to identify the user.

The main benefit of not exposing sessionid to js in the browser is that it if someone successfully performs a XSS attack they won’t be able to hijack the session. Setting the cookie to be not http only would have been the easiest option for me but, as it was not recommended, i went for token based authentication.

Token based authentication

For token based authentication to work, the Django server will have to generate a token on every request (for the endpoints which requires the websocket connection). Once the browser gets the token, it can initiate a websocket connection to the tornado server. While opening the websocket connection, the browser will send the token as well. On the server side, there should be a common store where Django can store the token and Tornado can retrieve the token to verify the request.

Generating the token on server side for multiple views can be done by making a python decorator. But, if you are making a decorator and want to pass on a variable to the original function itself, you will have to add an extra parameter on the function to receive the variable’s value. This was a big task and would have meant a lot of changes across the project. Instead, i went on to make project wide template tags.

Making a project wide template tag in django for creating tokens

  1. Create a folder under the project’s main directory and create two files: __init__.py and create_ws_tokens.py
  2.  In create_ws_tokens.py, you can put something like this.:
    import uuid
    import json
    import datetime
    
    from django import template
    from project_name import redis_conn
    
    register = template.Library()
    
    @register.simple_tag(takes_context=True)
    def create_ws_token(context):
        request = context['request']
        if not request.user.is_authenticated():
            return 'Not authed'
        user = request.user.username
        current_time = datetime.datetime.strftime(
                datetime.datetime.utcnow(),
                "%d:%m:%Y:%H:%M:%S"
        )
        token = 'wstoken' + uuid.uuid4().hex
        output = {
           'user': user,
           'time': current_time
        }
        redis_conn.set(token, json.dumps(output))
        return token
    
    
  3. Put the following snippet inside the Templates -> Options in settings of the project.
    'libraries': {
    'create_ws_token': 'project_name.templatetags.create_ws_token',
    },
    
  4. Now to use this template tag in any template, you will need to load it.
    {% load create_ws_token %}
    and

    <script>
        var token = '{% create_ws_token %}';
        if (token.startsWith('wstoken')) {
            socket(token);
        }
    </script>
    

socket is a function which is defined in other js file which creates a websocket connection.

ws = create_ws("ws://localhost:8080/wsb?ws_token="+ws_token);

From tornado side, we need to get the ws_token and query redis for a verification.

def open(self):
    ''' Called by tornado when a new connection opens up '''
    self.user = None
    if 'ws_token' in self.request.arguments:
        token = self.request.arguments['ws_token'][0]
        self.user = self.authenticate(token)
        if self.user:
             tsockets.add_socket(self.user, self)
             print 'New connection from browser!'
        else:
             self.close()
    else:
        self.close()

The authenticate method would be like:

def authenticate(self, token):
    ''' Check for authentic token in redis '''
    inredis = self.application.redis_conn.get(token)
    if inredis:
        inredis = json.loads(inredis)
        self.application.redis_conn.delete(token)
        current_time = datetime.datetime.utcnow()
        valid_time = current_time - datetime.timedelta(seconds=20)
        inredis_time = datetime.datetime.strptime(
           inredis['time'], "%d:%m:%Y:%H:%M:%S"
         )
        if valid_time <= inredis_time:
            return inredis['user']
    return False

I chose redis because, Tornado is a single threaded server and connecting to db, if it’s not async will result in a blocking connection which means the real time features will get affected.

That’s it.


by Vivek Anand at October 14, 2017 08:26 PM

Vipul Gupta

My First talk as a Speaker

Heart pounding against my chest, my throat dry as a barren road and hands shaking in nervousness and anxiety. As someone said a name that sounded similar. All eyes turned on me, prying. As they announced “the next speaker we are going to have is Vipul Gupta .. for his talk on Software Development using Version Control System (git)”

Now for all those who don’t know what that means, or not interested that much in code or technology. Can ignore the terminology and focus more on the experience and my thoughts. I will try to be brief.

How/Where/When/Why

The talk I gave was part of a meetup organized by Indian Linux Users Group Delhi (ILUG-D) on 8th October 2017 in which students, professionals, enthusiasts, and contributors to the open-source domain with similar interests meet, discuss and learn together. There are talks and workshops organized and scheduled by the group. It’s was an informal talk but nowhere lacking in sincerity or strictness. About 80-100 people came who listen, learn and ask questions about the topic. Which makes it even better.

highres_463542748.jpeg

The meetup was held at Bhagwan Parshuram Institute of Technology, Delhi with the theme set as ” Back to Basics ” All the talks were aimed at beginners and students who were just starting to explore the open-source domain. Talks are proposed by the members of the group on Github as issues. Mine is here and the schedule for that day is here.

What was it about?

My talk was about Version Control System, git, Github and git workflow. It was partly a hands-on workshop aimed at making the people learn about harnessing the powers of git. Understand how git works. How projects are built and how git makes them better and easier to contribute and manage. VCS is used all over the world by programmers and enthusiasts to systematically work on different projects at different times. To be more efficient. Here are the slides that I prepared on the topic.

How did it go?

Well, it went fine.
And you probably want to hear more than that I suppose. I reached the venue and someone’s else talk was going on. I was 2-3 hours early. I was a little stressed about the talk but who isn’t, right?  I honestly never had a problem with public speaking. I just have a constant numb feeling in my feet when I am on stage. Which I drowse by walking around and interacting with the audience. Then too, minutes before one go on stage. The nerves kick in, mouth goes dry, the mind blanks out and ears start humming. At least mine did. You take that walk from your seat to the mike. That long walk. With every eye in the room trained on you. You got people’s attention and now they want to listen to you. Speak. Speak. Speak. Your mind replies. And then in that make or break moment, your heart knows what do to do.

And mine did… I guess. It went well. Due to time constraints, I wasn’t able to say everything I wanted to. I am satisfied with whatever I said. I took feedback from many individuals and broadly got a positive response. But I need to improve more on my speaking skills. Which I will with time. Need to interact more with the audience. And keep checking if they understand me. Cross-check with them if they understood me in the form of questions. If they didn’t understand then what’s the point of the talk.

 

WhatsApp Image 2017-10-14 at 11.00.47 AM.png

Picture of the meetup

My talk was over in about an hour. As the hands-on workshop was going on. I was asked many technical questions. Which I answered gladly. In my talk, I was assisted by Sanyam Khurana who helped me when things slightly began to go downhill. Thanks to him it was a success.

Well, there’s my first talk. In the many more, that are going to come. This is an experience everyone should have at least once in their life. The sharing of knowledge sure goes a long way. Giving a talk has many personal benefits too, I would write about them in my next post.

Till then live in the mix !!


by Vipul Gupta at October 14, 2017 06:43 AM

October 13, 2017

Kshithij Iyer

"Just figure out what people don’t say and then you are set for life."

“Just figure out what people don’t say and then you are set for life.”

- Kshithij Iyer

October 13, 2017 04:56 PM

"I was a larrikin. This was my choice, I always believed in speaking my mind even when it hurt a few..."

“I was a larrikin. This was my choice, I always believed in speaking my mind even when it hurt a few people. But one day someone stepped into my life, someone who was able to see through all that evil which I choose to put up front to cover up. She saw that I was Anakin Skywalker and not the Darth Vader. She brought out the best in me, She made me the man I was supposed to be, She showed me that I could be better. And eventually She became my kryptonite and I became the superman who fell in love with kryptonite.”

- Kshithij Iyer

October 13, 2017 09:45 AM

October 12, 2017

Kshithij Iyer

#boldomatic (at Vadodara, Gujarat, India)



#boldomatic (at Vadodara, Gujarat, India)

October 12, 2017 05:37 PM

October 11, 2017

Kshithij Iyer

Mac and cheese. #foodie #bakedpasta (at Alkapuri)



Mac and cheese.
#foodie #bakedpasta (at Alkapuri)

October 11, 2017 06:02 PM

An unwanted conversation

(Fake Friend at your doorstep)
Fake Friend: You never cook anything for me, you always cook alone and eat it all alone.
Me(in my head): Hay! bastard have some custard.
(FYI: I don't know how to make a custard.)

October 11, 2017 04:47 PM

After publishing the first set of results which I got from the...



After publishing the first set of results which I got from the simulator. I purchased stocks of a specific company and left it for a few months. Now the findings from this experiment was that the stocks which I bought at 74 is now at 84. This proved that the so called “Invest and forget” model can work in scenarios where you buy the stocks and hold on to them for long. The whole point of this experiment was to find out if normal working class people could invest in share market and forget about their investment for longtime. And still be able to make money out of it.

October 11, 2017 08:15 AM

October 10, 2017

Shivam Singhal

Moz WebD SIG 30 Sep

Dussehra, Saturday, Sept 30th, while many students were enjoying the festival week at their places, Moz-NIEC conducted the class, it commenced at 11 am, sharp, as the team came before the scheduled time and hence, were ready to teach the basics of JS.

I, frankly, thought that, conducting class on Dussehra wasn’t a good idea, as many students have already made plans with their family and would not prefer the class over their famliy. But to my surprise, around 55 students came, despite saying ‘no’ in the WhatsApp group.

Each team member told about their personal experience, working with JavaScript, and how it is useful in the modern day browser. Some students haven’t even studied C/C++, so we started with basics of every programming language, If, else. First, team wrote the code and showed it to the class, by using the projector, then, explained each and every word of the code, and, for some reason, someone is not able to understand the code, the team members, spread out in the class, go to their desks and, if the doubt is something important that the member, who was teaching, hadn’t emphasized a lot on. The doubt is then, cleared on the projector for everyone to see. This repo has been updated as promised.

Students, who were attending the class for the first time, were given links to read through, and each team member were assigned the new students to help them understand whatever was taught in the previous classes and were added in the group so that, they may discuss their doubts.

We gave them some tasks as homework. At the very end, We told them that Mozilla-NIEC is conducting a hackathon Moz-Hack on Oct 14 2017, and invites all developers and hackathon enthusiasts to participate in the hackathon. The next class is scheduled to be on next weekend. We intend to continue javascript in that session.

This time we also have some swags from Mozilla Community for all 🙂

swag

Thanks for reading. Cheers. Be Mozillian 🙂


by championshuttler (Shivam Singhal ) at October 10, 2017 08:50 PM

Moz WebD SIG 24 Sep

Sunday, Sept 24th, a day after our first term exams got over, we thought that the turnout of the students would be less, but, to our surprise, almost 50 students came.
We had set the projectors, laptops,extensions cords, etc quicker than the last time, and also before time as moz niec team came early.
Moz-NIEC team taught different styling and, customising the look and feel of the website, and sending all the code into an external file i.e. CSS file. And gave a hint about the next class on JS.
Many new students came, so, the team members went to their desk and personally made them understand all that was being taught in the class. Presently, many students ask their doubts in the WhatsApp group, and from the team, whoever is free, solves their doubts. This repo has been updated as promised.

 


by championshuttler (Shivam Singhal ) at October 10, 2017 08:30 PM

Moz WebD SIG 9 Sep

This is when the journey begins. It wasn’t the easiest of task to make announcements in every single class at the top of our voices, but it turned out unexpectedly overwhelming.

The response was just fantastic.  More than 40 students showed up even before we did (we were punctual).  And then adding up to near about 65 by the commencement of the class.

The plan was crystal clear, this was the first time coding experience for many of the first year students,  and we wanted it to be as basic as we wanted it to be interesting.

We started off with who we are,  how we are what we are and most importantly WHY we (and the students) are here. Being straightforward open source enthusiasts, it wasn’t as difficult for us ‘Mozillians’ to make our students fall in love with open source as it once might have seemed.

The response was not only overwhelming when it came to attendance but also equally amazing when it came to respone of the students towards what is being taught.

By the end of the 4 hour long workshop,  where everyone seemed interested throughout, we as ‘teachers’ were delighted to conduct a successful workshop on  HTML and more importantly why is it important to be a programmer, a creator.

The students, we feel, felt amazing. And we expect an even more audience the next time.

Some photos of the class 🙂 . You can find me. I am the guy with Hike T-shirt 😛

WhatsApp Image 2017-09-10 at 4.53.52 PM(3)

 

1111

Thanks for reading. Cheers . Be Mozillian 🙂


by championshuttler (Shivam Singhal ) at October 10, 2017 08:20 PM

Kshithij Iyer

"I am 21 years, 11 months and 10 days old. Jobless for now, no love either, no idea of what I want,..."

“I am 21 years, 11 months and 10 days old. Jobless for now, no love either, no idea of what I want, no money and no to a few other things as well.  Okay! All I can do for now is either waste time or study.”

- Kshithij Iyer

October 10, 2017 06:01 PM

"It’s 11 in the night and I am still not able to find the strength to sit and study. God knows..."

“It’s 11 in the night and I am still not able to find the strength to sit and study. God knows what is wrong with me now!”

- Kshithij Iyer

October 10, 2017 05:40 PM

You know the solution to every problem in your life is Food. And the best solution is good...

You know the solution to every problem in your life is Food. And the best solution is good food.

Kshithij Iyer

October 10, 2017 12:05 PM

October 09, 2017

Kshithij Iyer

That day her words were more painful than the open wounds which I had from the bike crash.Kshithij...

That day her words were more painful than the open wounds which I had from the bike crash.

Kshithij Iyer

October 09, 2017 05:35 PM

Shivam Singhal

Software Freedom Day Chandigarh 2017

So about this event Pushpita told me at the home of Ajay Sir that Mozilla team is going there for 2 sessions, one is of VR and another one on Mozilla Extensions. So after the last event on Mozilla Extension on 19 August , i started learning about how to make Mozilla Extensions and got idea about how to make simple Mozilla Extensions. So Pushpita asked me to join her and Tushar on the trip and i said yes in few seconds 😛 . So in this way this trip was planned. So after came back to home i booked the tickets of round trip in hurry :D. We boarded the train to Chandigarh on 15th September at 7 PM and reached Hotel around 11 PM.

<h1> Day 1 </h1>

So next day we went to Panjab University. Tanish was here who invited Mozilla to Chandigarh. There is such a nice arrangement , and more than 250 students were in Auditorium. So the session on VR is from 11 AM. Tushar started session with introducing Mozilla and then a hour talk about how can we develop VR project and showed audience some cool projects on VR.1

After that Pushpita introduced all to Woman in Mozilla  in 15 20 minutes lightning talk.

 

And the crowd at the Auditorium 😀

2

 

So after that we have a good time to see the beauty of Chandigarh as we got free around 1 PM from there. So we booked Cab and roam in Chandigarh. We visited Elante Mall and Sukhna Lake. We also did boating, it was my first experience of boating. The beauty of Sukhna Lake is unbelievable .5.jpg

After that we moved to Iskcon Temple. So in this way our Day 1 ended.

<h1> Day 2  </h1>

On second there was only a hands on session of Mozilla on Mozilla Extensions at 2 PM. So we planned to move to Rock Garden before Session. 12.jpg

After that we move to College and the session started and audience was quite interested in Mozilla Extensions and more than 80% of attendees developed there first Mozilla Extension in less than a hour called as “Borderify”

121.jpg

So after this talk We discussed with Team of Event about Mozilla Campus club at Panjab University. So now it was the time to get back to home :'(. We moved to Railway Station of Chandigarh and reached here Delhi at 11 PM

It was a nice experience and a awesome trip. I wish for a next trip to Chandigarh. Its a beautiful city , No traffic , awesome weather and the best part is the helping nature of the people of Chandigarh.

Writing this blog after bunking the class in college 😛

Thanks for Reading. Be Mozillian 🙂


by championshuttler (Shivam Singhal ) at October 09, 2017 07:23 AM

October 08, 2017

Kshithij Iyer

This is why I hate to Starbucks cause they charge me more and...



This is why I hate to Starbucks cause they charge me more and can’t really deliver something near to my expectations. This is how a perfect capachino looks like.
#coffee #capachino (at Alkapuri)

October 08, 2017 11:39 AM

Now normally after a crash I usually pretend to be wolverine but...



Now normally after a crash I usually pretend to be wolverine but I guess I am not that serious these days so Deadpool. And yeah I am well and now healing like Deadpool.

October 08, 2017 08:19 AM

October 07, 2017

Kshithij Iyer

Thank you love or should I say ex love! 😂😂 #love #life #MoveOn ...



Thank you love or should I say ex love! 😂😂
#love #life #MoveOn (at Alkapuri)

October 07, 2017 12:28 PM

October 06, 2017

Kshithij Iyer

"Cooking at home is really confusing cause it takes 10 minutes to decide which pan to use."

“Cooking at home is really confusing cause it takes 10 minutes to decide which pan to use.”

- Kshithij Iyer

October 06, 2017 01:21 PM

"It’s a strange feeling when someone else saves you from writing a backlog when you are known..."

“It’s a strange feeling when someone else saves you from writing a backlog when you are known to be a person who saves everyone's  lives.”

- Kshithij Iyer 

October 06, 2017 12:55 PM

"You know you were in love when you come home after months and you miss her every day."

“You know you were in love when you come home after months and you miss her every day.”

- Kshithij Iyer 

October 06, 2017 12:49 PM

October 04, 2017

Ashwani Kumar Gupta

Static Site Generators: Introduction, examples and comparison of existing ones written in Python

Since the last few days I am learning about how static site generators work and experimenting with a few written in Python. In this article I want to introduce what a static site generator is with some examples. Later I will also make a comparison between different open source static site generators available like Malt, Pelican and MKDocs

What is a static site generator?

Static site generators are used to generate a full-fledged website using only content written in plaintext. It is useful when you want to deploy a website with only static pages (such as a blog, documentation or even deploying  to GitHub pages). You might be wondering how is it useful? We can create static pages using plain HTML and CSS pretty easily. Yes we can, but apart from the content we also have to design the site layout and how it looks and that is tiresome. Even more, you can track your whole content using a VCS like git.

Static site generators take our content in plaintext(sometimes HTML) format and create HTML and CSS files out of that. You can also choose any theme you like and also create one of your own if you want (Isn’t that amazing?). If you are using it for your blog, you can write your blog posts in plaintext and create HTML versions with ease to update your site.

A quick example

Let’s see a quick example to see how things work. We will be using Malt to generate our own static site.

First let’s install Malt using the following command. It is available via pip

pip install maltapp

Now create a empty directory mywebsite. It will be our base directory where all our files will be stored. Change directory into it.

mkdir mywebsite
cd mywebsite

To initialize Malt type ​malt init . This will create a directory structure as below.

site/
    site.py      # site configuration file
    ext/         # extensions directory for plugins
    inc/         # includes directory for menus, etc.
    lib/         # library directory for themes
    out/         # output directory for html files
    res/         # resources directory for static assets
    src/         # source directory for text files

Now run the following command to generate the HTML and run your site locally

malt build
malt serve

And that’s it, your browser will open and you will be able to run your site locally. You can edit the files present in src directory to change the content of your pages. And it uses Markdown too.

A few static site generators and their comparison

We will be looking into few static site generators (Malt, Pelican and MKDocs) and see what features they offer, their good and bad points. Let’s see them one by one what they provide.

Malt
  • Easy and simple to use
  • Written in Python. Requires Python 3.5 or higher
  • Supports Markdown (.md) and Syntex (.stx) format
  • Comes with a default theme(pheonix), vanilla and a debugging utility(debug); limited themes
  • File metadata can be provided with a YAML header within each file; not mandatory though
  • Malt has built-in support for templates written in Jinja (.jinja extension) and Ibis  (.ibis extension)
  • No support for comments, importing from external website
  • Project is not maintained currently
  • Uses The Unlicense lincese
Pelican
  • Written in Python. support for python 2 and python 3
  • Supports formats reStructuredText (.rst), Markdown (.md), HTML (.html). Plugins can be used to support other extensions
  • Metadata information have to be provided in each individual file (Title is mandatory for each file)
  • Support for comments using disqus
  • Support for syntax highlighting
  • Support for importing from external website using command line tool called pelican-import
  • Single page rebuild allowed
  • New themes can be created; intuitive interface for installing/removing themes
  • Highly configurable
  • Project is community driven with 300+ contributors
  • RSS/Atom feed can be generated
  • Requires a bit of learning curve; not easy to get started quickly
  • Can be used to build a fully functional static website
  • Uses GNU Affero General Public License v3.0 lincese
MkDocs
  • Written in Python. support for versions 2.6, 2.7, 3.3, 3.4, 3.5 
  • Supports content format Markdown (.md)
  • More focused towards documentation generation
  • Comes with two themes; but third party themes can be used or own themes can be used; easy to make new themes or customise other themes
  • Comes with an inbuilt server which allows us to view the site as we change it; auto-reloads
  • Uses BSD 2-clause “Simplified” License lincese

 

Here is a table based comparison among the three:

Malt Pelican MKDocs
Ease of use Easy to use Requires little learning curve to get used to Easy to use
Content format Supports Markdown, Syntex. Other formats can be supported using plugins Supports reStructuredText, Markdown and even HTML Supports only markdown
Import external websites No Yes No
Templates Yes Yes Yes
Themes Yes Yes, also comes with theme manager Yes
Comments No Yes No
Feed generation No Yes No
Comments No Yes, but through Disqus No
Speed Builds the whole site on every change Fast rebuild times due to selective output writing Builds the whole site on every change. But comes with a real time dev server which automatically detects changes and builds it immediately
License The Unlicense AGPL-v3.0 BSD-2 Clause

So as we have seen that among the three Pelican provide most features and flexibility but it not very easy to get started if you are a beginner. Malt and MKDocs both provide very intuitive command line interface. Each of them are suitable according to your needs. If you are using it for documentation then you must go with MKDocs otherwise for a full website Pelican is a better choice.

Even though static site generators are great, they are not for everything. If your website requires interactivity/dynamic content/user input then definitely you should not go for static sites, dynamic ones are better choice.


by Ashwani Gupta at October 04, 2017 04:10 PM

October 03, 2017

Devesh Verma

October 02, 2017

Vipin kumar

Finding largest number from five number using for loop

In our this blog we are going to find largest number from five number .

large-for-loop.c


#include
void main()
{
	int i,number,max;

	printf("\nenter a number : ");
        scanf("%d",&number);
                                     // because we need something in max 
                                     // else there will be a gurbaje value
                                     // in max.
	max=number;

	for( i = 1 ; i <= 5 ; i++ )   
{       
        printf("\nenter a number : ");         
        scanf("%d",&number); 	     
            
               if( number > max) 
                                   // it compair each value and store large
                                   // one in max .
	       max = number;
  }
	printf("  \n largest number is :  %d",max);

}


by kumar vipin yadav at October 02, 2017 07:15 AM

A program to find power using for loop

In our this blog we will  code a C program to find lcm of four number

here is the link  lcm-for-loop.c


#include
void main()
{
	int number_1,number_2,number_3,number_4,i,max,lcm;

	printf("\n enter number 1 :");
	scanf("%d",&number_1);

        printf("\n enter number 2 :");
	scanf("%d",&number_2);

        printf("\n enter number 3 :");
	scanf("%d",&number_3);

        printf("\n enter number 4 :");
	scanf("%d",&number_4);

	max=number_1*number_2*number_3*number_4;

	for( i=1 ; i <= max ; i++ )
		{
if( i%number_1 == 0 && i%number_2 == 0 && i%number_3 == 0 && i%number_4 == 0 )
				{	
                                        lcm=i;
					break;
				}

		}
         printf("   \n  lcm is   :  %d ",lcm);
}

 


by kumar vipin yadav at October 02, 2017 06:56 AM

October 01, 2017

Kshithij Iyer

I don’t know if you are reading this or not but yes you...



I don’t know if you are reading this or not but yes you did make a difference in my life.

October 01, 2017 05:52 PM

September 30, 2017

Kshithij Iyer

Life at 80Kmph

So this is yet another post on bikes and my life. Recently I had pulled down a bike trip which was planned because my so-called relative had some problem with me riding to his/her place but no stress I don’t expect everyone to have an open mindset. And as usual, I am expecting a bit of a drama after my family reads this post. But what I have observed over these past few months after linking all my accounts to each other is that people conveniently read only the posts which have unparliamentary words in it and then create a scene out it at home. For all I know I have half the mind to use unparliamentary words and have a discussion with these people but anyway, some people will never understand what’s above them(there was a reason why these words were added to the English vocabulary right?). So 2 minutes of silence for these people and their brain as what is not used is as good as dead.

Okay! let’s jump back to the main topic, I guess we had enough of side talk.

IT as a career is a really tough job. Developing software for a living is a really frustrating job as sometimes the code works and sometimes you don’t know what is going on. Now you would say that “How is he commenting when he doesn’t really have an IT job till now?” For that, my comment would be that my college says “Work as if you are a Professional !” Now I understand that the college has given me a lot of stress lately and I had literally worked up my ass so hard that I even forgot my birthday for a second (This was while filling the EXAM FORM.) to achieve all that I did in this Sem. I ain’t complaining about it but I am just saying it to set the context right. If all your day you sit in front of a computer and work from morning to night and sometimes even the entire night. It has an adverse effect on you. You get tired.  Your mind stops to work at a point. You crave for a break, a stress buster, a recharge or whatever you would like to call it. Most people in IT either get addicted to cigarettes, alcohol or in some fucked up cases even drugs. But this is what the weak do. Then there are the strong ones who aren’t addicted to any of these, these are the ones who crave for the Sunday morning or long weekend rides. These are the people who like to go on road trips on bikes. I being one of the strong ones became hooked up to riding. It all started with that Vadodara-Ahmedabad and back challenge this was the first time I had rode for more than 200km at a stretch but that day I had figured out that if I would have to maintain my sanity I had to do this once every six months or so. Now, 214Km is a small thing and 495Km is a big thing but doing 495Km in 24 hours is accomplishable. If you fear to take risks you won’t be able to do anything at all in life. Everyone takes risks it’s just that the way is different. Now let’s come to the potential risks and other stuff. Consuming cigarettes slowly kills you, eating sweets while you have diabetes will also do something similar, prolonged BP also So now if you look from this perspective risking your life for a day is a really small thing. And the benefits of going on these trips outways the risks. Now I just don’t understand why they have all these problems with me having fun. You know every time you get into a fight you are risking your life cause your flight can crash, could be hijacked or could be shot down by Russian missiles. Riding long distance is my choice, my way of enjoying my life, my temple where I run to find peace, clarity, and purpose.

I guess if I try to keep everyone happy I won’t be able to live my life, so sorry to all those who’ll be pissed off after reading this on a Sunday morning. But just for the official records, I am not going to respond all the hate comments and messages which will follow this post as I am writing the post on a Thursday and it will be published on a Sunday and I’ll be busy working on my project. So don’t  bother commenting or calling. 

And yeah if you want to complain to my parents about me posting stuff, please sit and read all my post which is 400+ in number and then comment on what I a doing.

Love now and always,

Kshithij.

September 30, 2017 06:30 PM

September 29, 2017

Himanshu Awasthi

Python Power(Youtube Downloader)

Hey Guys! I’m Himanshu Awasthi & today I’m going to share how to download video’s from YouTube using small Python Script. As we all know that Python is most powerful language and we can do any thing using Python so lets start :

import All from todays_Blog

We need to download two Python Module for start write code for youtube downloader :

  1.  youtube-dl (Download Here)
  2.  pafy (Download Here)
  3.  pytube (Download Here)

We can use any one of these module for our code but I’m going to use pytube .

Why we need these modules ?

youtubedl is a command-line program to download videos from YouTube.com and a few more sites. learn more about it from Here

Pafy is very comprehensive python module, allowing download in both video and audio format. There are other features of Pafy which is not used in this module.

Pytube is a python package written for the main purpose of downloading videos from the famous video website Youtube.

lets move towards code :
import pytube
print("Enter the video link")
link = input()
yt = pytube.YouTube(link)
videos = yt.get_videos()
s = 1
for v in videos:
print(str(s)+". "+str(v))
s += 1
print("Enter the number of the video: ")
n = int(input())
vid = videos[n-1]
print("Enter the destination: ")
destination = input()
vid.download(destination)
print(yt.filename+"\nHas been successfully downloaded")

Output:

/usr/bin/python3.5 /home/him/PycharmProjects/online_Downloader/youtube_download.py
Enter the video link
https://www.youtube.com/watch?v=uSosZCcLr_U
1. <Video: MPEG-4 Visual (.3gp) – 144p – Simple>
2. <Video: MPEG-4 Visual (.3gp) – 240p – Simple>
3. <Video: H.264 (.mp4) – 360p – Baseline>
4. <Video: H.264 (.mp4) – 720p – High>
5. <Video: VP8 (.webm) – 360p – N/A>
Enter the number of the video:
3
Enter the destination:
/home/him/PycharmProjects/online_Downloader
Make Youtube Video Downloader with Python in 5 minutes
Has been successfully downloaded

Process finished with exit code 0

So enjoy your downloading using this script & Don’t forget to be the part of these upcoming great Python events in India .

Upcoming Python Events :

PyConf Hyderabad 2017

Pycon India 2017

Happy Coding!


by Himanshu Awasthi at September 29, 2017 06:34 PM

September 28, 2017

Kshithij Iyer

"I don’t know but today I felt bad for this guy who always tried to pull me down for no reason..."

“I don’t know but today I felt bad for this guy who always tried to pull me down for no reason for the last one year. This guy couldn’t figure out that he needed help. He just couldn’t understand that coming first is not an aim in life. He just couldn’t understand that people around him were not wrong but his mindset was… I tried to talk some sense into him but this stubborn ass(donkey) never heard. And now I see him and I only feel sympathy for him. Be careful of your actions people what goes around comes around. It’s just that the way you think will someday cause problems to you.”

- Kshithij Iyer

September 28, 2017 06:47 PM

"I guess I can’t win every bet I placed, life is like a poker game where you make money and..."

“I guess I can’t win every bet I placed, life is like a poker game where you make money and sometimes you lose it.”

- Kshithij Iyer 

September 28, 2017 06:31 PM

Ashwani Kumar Gupta

Different timestamps in UNIX systems

In UNIX filesystems, there are three timestamps associated with every file or directory. Whenever we access/modify any file/directory in the filesystem these timstamps change and this helps track the statistics of a file or directory. You can use these timestamps to check when a file was last accessed, last changed or even when it’s permissions were changed.

The timestamps

There are three timestamps associated with every directory or file or whatsoever in UNIX filesystem. They are:

  • mtime (This is the default timestamp, it stands for modify time)
  • atime (This stands for access time)
  • ctime (This stands for change time)

mtime

As its name suggests mtime is the last time the file/directory was modified. One simple way to see mtime of a file is via the ls command. Let’s first create a file and modify it.

$ date
Thu Sep 28 22:05:31 IST 2017
$ touch newfile.txt
$ ls -l newfile.txt
-rw-rw-r-- 1 ashwani ashwani 0 Sep 28 22:05 newfile.txt
$ echo "This is some random line" >> newfile.txt
$ ls -l newfile.txt
-rw-rw-r-- 1 ashwani ashwani 25 Sep 28 22:12 newfile.txt

As you saw, we changed the mtime of the file by modifying the content of the file.

atime

atime is access time. So whenever any program accesses(reads) your file, it’s atime changed. Let’s see how atime changes when we access our newly created file newfile.txt. Again we can use ls command with -ul flag for atime.

$ ls -ul newfile.txt
-rw-rw-r-- 1 ashwani ashwani 25 Sep 28 22:05 newfile.txt
$ vim newfile.txt
$ ls -ul newfile.txt
-rw-rw-r-- 1 ashwani ashwani 25 Sep 28 22:29 newfile.txt

ctime

This is often confused with create time. ctime stands for change time. It shows the last time the file metadata was changed (like file permissions, file name etc). We can use -cl flag with ls command to see the change time. Let’s see how we can change it. We rename the file from newfile.txt to newfile1.txt

$ ls -cl newfile.txt
-rw-rw-r-- 1 ashwani ashwani 25 Sep 28 22:12 newfile.txt
$ mv newfile.txt newfile1.txt
$ ls -cl newfile1.txt
-rw-rw-r-- 1 ashwani ashwani 25 Sep 28 22:33 newfile1.txt

So as you saw, we changed the ctime of the file.

Get all the timestamps of a file

We can use the stat command to see all three timestamps of the file/directory.

$ stat newfile1.txt
File: 'newfile1.txt'
Size: 25 Blocks: 8 IO Block: 4096 regular file
Device: 805h/2053d Inode: 8001736 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ ashwani) Gid: ( 1000/ ashwani)
Access: 2017-09-28 22:29:59.336886750 +0530
Modify: 2017-09-28 22:12:15.759258444 +0530
Change: 2017-09-28 22:33:45.564073345 +0530
Birth: -

As you can see stat command gives us the timestamps in a much better format and it also has other information about the file. You can learn more about stat command through the manual provided in Linux systems via man stat command.


by Ashwani Gupta at September 28, 2017 05:42 PM

Deepika Upadhyay

FEEDBACK

#learnings from sessions missed

Somedays I wasn’t able to cope with college-hours and extra-curriculars , and wanted to start to cover-up everything that i missed these days, looking back from where I started , 3 months prior to dgplug summer training , I feel this was the most helpful in growing my understanding for free and open-source world .

FEEDBACK SESSION- BY SANKARSHAN

I think it’s very important to have a feedback loop, where you’re constantly thinking about what you’ve done and how you could be doing it better. I think that’s the single best piece of advice: constantly think about how you could be doing things better and questioning yourself.

Elon Musk

Earlier,  I had a understanding that feedback is quiet essential in life , I write dairy to maintain this feedback loop to improve self  but what I learned from this discussion was that , we need to give and take critical feedback in a balanced form what this means that if you be too much in critical details maybe the receiver might not take it well , while being too abstract like the “the product looks awesome ” would not contribute to any improvement of any sort .

while giving or receiving feedback we must not be too much emotionally invested , as this might make us somewhat bias  , which again fails the purpose of feedback which , in my perspective is

The step that is mostly ignored  in the development of anything be it bussiness , code , skill !

Which can accelarate the development several-folds  if  received from a person having experience in the art or by self -evaluation like time travel and going in past to see where you did it wrong ,or reading and gaining knowledge in an unbiased manner ,  just like how a case is  evaulated in court ,to come up to a right judgement ,we need an unbiased evaluation and even be willing to take one .

 

When i miss batul  😀


image quailty ain’t that good , but expression is more important I guess 🙂

http://a%20href=//acceptable.a-ads.com/690964//acceptable.a-ads.com/690964/a

 


by deepika at September 28, 2017 10:56 AM

Kshithij Iyer

When something this small fucks up your entire life. #diode...



When something this small fucks up your entire life.
#diode #laptop

September 28, 2017 06:04 AM

Mohit

Nested loops are faster!

While solving a problem on hackerrank, I had to use for nested loops in problem related to 2D array.  Then, I realised I should use single loop rather than nested and then, I tried myself both the approaches to check which approach is better and faster.

Every time for similar iterations, nested loops were faster than the single loops.  Below is the python code to verify yourself.
The following code takes the inputs 10, 20, 50, 100 and outputs the time required by both the approaches.

Python Code:


import time

def loopinloop(n):
    StartTime = time.time()
    for i in range(0, n):
        for j in range(0, n):
            # Do nothing
            continue;
    return (time.time() - StartTime);

def loopalone(n):
    StartTime = time.time()
    for i in range(0, n**2):
        continue;
    return (time.time() - StartTime);

if __name__ == "__main__":
    number = [10, 20, 50, 100];
    withinloops = [loopinloop(num) for num in number];
    oneloop = [loopalone(num) for num in number];
    print("withinloops = {0}".format(withinloops))
    print("one loop = {0}".format(oneloop))

Output:

withinloops = [1.0013580322265625e-05, 1.9073486328125e-05, 7.987022399902344e-05, 0.0002682209014892578]
one loop = [4.0531158447265625e-06, 1.1920928955078125e-05, 9.298324584960938e-05, 0.0003771781921386719]
As the above code and its output suggests, nested loops are faster which is quite a contradiction in itself i.e. O(n^2) is faster than O(n).  But after searching a little I found this Stackoverflow answer.

Thus, nested loops is not always faster than single loop.  It depends on the statements it is executing.  Hope this helps :)

by Abstract Learner (noreply@blogger.com) at September 28, 2017 05:01 AM

September 23, 2017

Kshithij Iyer

"You know your life is messed up when you see through the window and you find your landlord water his..."

“You know your life is messed up when you see through the window and you find your landlord water his plants while you set your alarm and go to sleep.”

-

Kshithij Iyer

September 23, 2017 10:41 PM

Soumam Banerjee


                                            SHEBANG

Till date I have been writing normal python programs and storing it in .py files and executed it by migrating to the desired path where it is stored and executing python xyz.py in the terminal(say the name of the program is 'xyz'), but one day i found my friend compro(nick) has made a command lgm which is used to clone the git files from github/gitlab and arrange them sequentially and storing the files accordingly. I was quite surprised that he has made a command which gets executed in the terminal. So i thought of making it even ,i made a simple program where it will take the address in the command line and it will open the google map and find that address for you.

Now my command should be accepted from anywhere in the terminal be am i in the home dir or projects dir or any other directory.So what will make that possible???
SHEBANG!!!

Starting a Script With #!

  1. It is called a shebang or a "bang" line.
  2. It is nothing but the absolute path to the required interpreter.
  3. It consists of a number sign and an exclamation point character (#!), followed by the full path to the interpreter such as /bin/bash.
  4. All scripts under Linux execute using the interpreter specified on a first line[2].
  5. Almost all bash scripts often begin with #!/bin/bash (assuming that Bash has been installed in /bin)
  6. This ensures that Bash will be used to interpret the script, even if it is executed under another shell[3].
  7. The shebang was introduced by Dennis Ritchie between Version 7 Unix and 8 at Bell Laboratories. It was then also added to the BSD line at Berkeley [4]


So my basic program mapit.py is :---

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#! /usr/bin/python3



#mapIt.py - launches a map in jhatackkk...
# command line or clipboard

import webbrowser,sys
if len(sys.argv)>1:
#get the address from the terminal itself
address=' '.join(sys.argv[1:])

#Todo : get the address from clipboard


webbrowser.open('https://www.google.com/maps/place/'+address)

Now what shall we do ?? we have 3 steps to perform to make that command run in our terminal
so lets go:-
STEP NO 1. 
chmod +x /path/to/mapit.py
for example in my case:-
chmod +x /home/soumam007/projects/scrape/mapit.py


STEP NO 2. 
sudo cp /home/soumam007/projects/scrape/mapit.py /usr/local/bin/

This will copy your executable file in directory /usr/local/bin/ . Now at first my doubt was if its placed in usr/local/bin then why the heck are we writing #! usr/bin/python3 in the desired shebng line, but my mentor clarified that the shebang line is used to say "hey my script is a python script and it has to run using `python3` command which is available at `/usr/bin/python3`."

Now my doubt was then why the hell am i putting it in usr/local/bin it was well and good in my /home/soumam007/projects/, but remember??? we wanted the mapit.py to execute from anywhere in the terminal so we keep it in usr/local/bin.
you need to put it in a place that is looked up for all available commands.
PATH variable is a list of directories which is looked up for commands.
when you type `mapit.py` on your terminal, it will find your script at /usr/local/bin/mapit.py.
Then it will read the first line and see that it is a python file. Then it will go find the python command at /usr/bin/python Then it will run your file using the python command.


STEP NO 3. 
mapit.py delhi


One more thing I will like to add to these information as said by my mentor. He said me about the symbolic links, so I tried it out even but this time with a simple example hello.py
It contains only print("Hello World!!!").
First of all make it executable by chmod +x /home/soumam007/projects/scrape/hello.py

then to create a symbolic link:-
ln -s /home/soumam007/projects/scrape/hello.py /usr/local/bin/

this will not copy the hello.py file but it will create a symbolic link(like in case of shorcut)
So i will show you my usr/local/bin dir
ls -l
total 952 lrwxrwxrwx. 1 root root 40 Sep 23 19:23 hello.py -> /home/soumam007/projects/scrape/hello.py -rwxr-xr-x. 1 root root 4003 Aug 4 23:01 lgm -rwxr-xr-x. 1 root root 335 Sep 23 14:02 mapit.py -rwxr-xr-x. 1 root root 963520 Aug 15 21:18 minerd




Note hello.py points to the original directory,now if you delete it or make any changes to the original file it will affect the symbolic file accordingly.

All credits goes to :--
1. Maxking(dgplug)
2. askubuntu
3. https://automatetheboringstuff.com/chapter11/


Thanks,
Soumam Banerjee
:)

by SOUMAM BANERJEE (noreply@blogger.com) at September 23, 2017 02:20 PM

September 20, 2017

Kshithij Iyer

"The funny part is that people don’t work as hard as I do and sit in an ongoing presentation..."

“The funny part is that people don’t work as hard as I do and sit in an ongoing presentation and criticise me. I feel like abusing the shit out of such people but I guess I am better than this.”

- Kshithij Iyer

September 20, 2017 12:20 PM

Mohit

Everybody, Somebody, Anybody, Nobody!

During studying Communication Skills for my college exams, I found an amazing story which I would like to share.

Everybody, Somebody, Anybody, Nobody!

- A Communication Gap

This is a story about four people Everybody, Somebody, Anybody, and Nobody.  There was an important job to be done and Everybody was sure that Somebody would do it.  Anybody could have done it, but Nobody did it.  Somebody got angry about that, because it was Everybody's job.  Everybody thought Anybody could do it, but Nobody realized that Everybody wouldn't do it.  It ended up that Everybody blamed Somebody, when Nobody did what Anybody could have done!


Conclusion:  This story is far deeper than it might look and is best describe in team collaborative projects.  If any of you find difficulty understanding, please Comment. (It is rather difficult for me to explain it all over here)

by Abstract Learner (noreply@blogger.com) at September 20, 2017 10:59 AM

September 19, 2017

Kshithij Iyer

"Okay! 48 hours and I’ll be through with most confusing JAVA EE Project ever."

“Okay! 48 hours and I’ll be through with most confusing JAVA EE Project ever.”

- Kshithij Iyer

September 19, 2017 07:31 PM

Pune is rather green city. #pune #rains (at Symbiosis Institute...



Pune is rather green city.
#pune #rains (at Symbiosis Institute of Computer Studies and Research, Pune)

September 19, 2017 04:05 PM

"You won’t understand the pain of having a bike still you have to walk to the retail shop to..."

“You won’t understand the pain of having a bike still you have to walk to the retail shop to buy coke.”

- Kshithij Iyer

September 19, 2017 03:13 PM

September 18, 2017

Kshithij Iyer

"Okay! This is both exciting and horrifying, I just don’t recollect when I slept last night."

“Okay! This is both exciting and horrifying, I just don’t recollect when I slept last night.”

- Kshithij Iyer

September 18, 2017 09:20 AM

September 17, 2017

Vivek Anand

Using C function from Python

ctypes is a python library which allows using C data types, functions from a python script. It’s in the standard python library. To use C functions using ctypes, you will need to compile the C code and create a shared library.

add.c

#include <stdio.h>

int add_two_numbers(int num1, int num2) {
    return num1 + num2;
}

I will be using a very simple C function in this case which adds two given numbers

Now compile this file using:
gcc -fPIC -shared -o libadd2nums.so add.c

This will create a shared library named libadd2nums.so which, for now, contains only one function.

add.py

# coding=utf-8

import ctypes

_add = ctypes.CDLL('/home/vivek/ctypestuts/libadd2nums.so')
_add.add_two_numbers.argtypes = (ctypes.c_int, ctypes.c_int)

def add_two_numbers(num1, num2):
   ''' Adds two numbers '''

   return _add.add_two_numbers(ctypes.c_int(num1), ctypes.c_int(num2))

I am using fedora 26. If you are using Windows, you will need to use ctypes.WinDLL.

_add here, is the shared library and we can access the C function using dot(.) .

main.py

# coding=utf-8

import add

num1 = int(raw_input("Enter num1: "))
num2 = int(raw_input("Enter num2: "))
print add.add_two_numbers(num1, num2)

That’s it.


by Vivek Anand at September 17, 2017 03:50 PM

September 14, 2017

Mohit

Boot Loader vs BIOS!

If you guys have read my previous blog on LibreBoot, you guys might know that I have started to work on LibreBoot and here is something I like to share what I learn along the way on BIOS and boot-loader.

BIOS

BIOS is short for Basic Input Output System and is a very critical part of any computer system and it is very first part which powers up your system.

 When the system is powered on, a firmware loaded in a ROM(Read Only Memory) chip is executed and is known as BIOS.  This firmware takes care of your initials drivers required by your system for the keyboards and mouse to interact. Once the BIOS firmware is loaded, the process of booting goes to boot-loader.

Boot Loader

Booting takes place in two steps.  BIOS checks all the storage devices connected to the system and if the boot loader is present or not.

Boot Loader then in first step, checks for the master boot partition, aka MBR and verifies whether it is working or not i.e. not corrupted.

Then, in second step, boot loader points to the storage partition which stores the operating system for our system and is referenced by the MBR, whether it be windows or any linux based distribution.

In multiboot systems, MBR has the entry for all the storage partitions for all the operating system, and thus boot loader provides user the option to choose the operating system, s/he wants to use.


Note: Since I am learning these concepts on bootloader, bios and kernel.  So use this material on your risk.  I wont be responsible if your system crashes. :p








by Abstract Learner (noreply@blogger.com) at September 14, 2017 06:55 PM

LibreBoot: An openSource Firmware

LibreBoot!

As an open source enthusiast, I find new open-source softwares almost every week.  This week I get to know about a great one, which I never thought of.  A Open-Source BIOS firmware alternative, LibreBoot.  The thought never struck me that there might also be Open source BIOS firmware out there

How I found it?

For some weeks, I was looking for some opensource projects which I can contribute to but I was too confused about which one to pick.  The main reason being, every new thing fascinates me and thus I got distracted too easily.  Discussing these issues with my dgplug mentor Shakti kannan aka mbuf, I found my core competence (low level computer stuff, 0s and 1s) and most of all, I learnt to say No! to other fascinating stuff which distracted me a lot.

mbuf advised me to check on LibreBoot and see if it helps.  When I first encounter libreboot documentation, i couldn't understand much, but searching a little about it, I started to liked it.

What is it?

Libreboot (formerly known as GNU Libreboot) is a free software project aimed at replacing the proprietary BIOS firmware found in most computers with a libre, lightweight system designed to perform only the minimum number of tasks necessary to load and run a modern 32-bit or 64-bit operating system.


How can you get started?


I wont go into much detail, but there is one advice i would like to give: Hold on, take your time, it might not get to you at first.

  • Read about it and its history here.
  • Download the source code for libre boot from its git repository hosted here by:          git clone https://notabug.org/libreboot/libreboot.git

  • Try and install it on your system (Recommended on Test System).
  • See if you like it.
  • Have fun with its code.

As you can see in its documentation, its tested for limited devices/hardwares and here's your chance, go try and  test it on your on.












by Abstract Learner (noreply@blogger.com) at September 14, 2017 07:28 AM

September 13, 2017

Kshithij Iyer

"No! I ain’t losing tomorrow, Java EE 2 and PHP tests I guess it’s going to be a long..."

“No! I ain’t losing tomorrow, Java EE 2 and PHP tests I guess it’s going to be a long night.”

- Kshithij Iyer

September 13, 2017 03:28 PM

September 12, 2017

Vipin kumar

Program-to-find-Power-using-for-loop

In this blog we are going to make a program find power of same numer

for example :  number is 5 power 5.


power-for-loop.c

#include
void main()
{
int  i , n , pow = 1 ;
printf("enter a number \n");
scanf( "%d",&n);
for(i=1;i<=n;i++)
{
pow=pow*n;
}
printf("%d",pow);
}

 


by kumar vipin yadav at September 12, 2017 01:41 PM

Printing-N-to-1-using-for-loop

IN this blog we do a simple program on for loop .

printing-N-to-1-using-for-loop.c

 

#include<stdio.h>
void main()
{
int i,N ;

printf(“Enter a number : “);
scanf(“%d”,&N);

for ( i = N ; i >= 1 ; i– ) // or for( ; N >= 1 ; N–)
printf( ” %d \n “,i );
}

// I hope now you will able to understend for loop in C.


by kumar vipin yadav at September 12, 2017 01:31 PM

September 11, 2017

Kshithij Iyer

September 10, 2017

Vipul Gupta

!0 most brain me1ting m0vies.

As promised from my previous post Lights, Camera, My Love for watching movies.

Here’s my list of my mind melting movies that you probably won’t give a fuck about. But don’t worry the list is still gonna be here. Regardless of what you think. So let’s begin. But first. What is a mind melting movie?

It is a brainfuck of thoughts and scenes carefully stitched together with elegance and beauty by the director for you to unravel and discover and as you pull away each layer like scene of that onion like film until you reach its core, the climax where it all boils down into something you never could have expected. Your mind is thinking at about 10-15 WTF’s per minute. As you start to think about one particular scene. And that scene shifts to something else more mind boggling than the previous one. The movie craves for your attention and wouldn’t let you go out of its grip. You have to watch what happens in the end or the world would end. That’s a mind melting movie.

And honestly, I love those kinds of movies. I want movies to be a fast-paced sarcastic thriller that stands apart from the normal shit we are used to watching. That gets you a high, a blissful release from this world. A good movie is so many but a movie that makes you think is one in thousands. It could be anything for you. Share your list too in the comments section. Here is mine and it’s a bit cliche. In no particular order.

  1. Memento
  2. The Usual Suspects
  3. Inception
  4. Ocean’s series
  5. Don’t Breathe
  6. Cloverfield Series (So excited for God Particle)
  7. Gone Girl
  8. The Prestige
  9. The Departed
  10. Vanilla Sky and Valkryie and Minority Report ( Love Tom Cruise)

And seriously tons more… Thing is these movies lands quite close to thriller. Maybe I am just renaming the genre here. For what I like for it to sound. Share any movies you would like to be added. Till then, peace out, rabbit.


by Vipul Gupta at September 10, 2017 09:01 PM

Kshithij Iyer

"Okay! I though themes would be a bit more easy. :p"

“Okay! I though themes would be a bit more easy. :p”

- Kshithij Iyer

September 10, 2017 06:19 AM

September 09, 2017

Vipin kumar

Understanding-for-loop

#include<stdio.h>
void main()
{
int i ;

for ( i = 1 ; i <= 10 ; i++ )
printf( ” Now the value of i is %d .\n “,i );

/* OR
i = 1 ;
for( ; i <= 10 ; )
{
printf(“Now the value of i is %d.\n “,i);
i++;
}
*/
}
/* Here i = 1 is initialization
and i <= 10 is condinitiona; part and
i++ is expression part.
they run accroding to there flow as we explaine in last blog.
*/


by kumar vipin yadav at September 09, 2017 03:15 PM

Samridhi Agarwal

Euler Problem no.30 with Python

This problem statement was quite interesting because that not only judged my coding skills but also my mathematical skills. So i tried to solve it in two different ways –

Problem Statement
Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
1634 = 14 + 64 + 34 + 44
8208 = 84 + 24 + 04 + 84
9474 = 94 + 44 + 74 + 44

As 1 = 14 is not a sum it is not included.

The sum of these numbers is 1634 + 8208 + 9474 = 19316.

Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.

Solution –

I first thought of getting the set of numbers (which meet the problem’s criteria) that are to be added, and then add them together to verify that the set is correct and complete.

Secondly, make a list of constraints which put restriction on the solution set. This problem excludes the value 1 from consideration. In fact, by intuitive extension, it is excluding all single digit values (numbers < 10) as they cannot form a sum of digits. This is a clue that our search range starts from at least 10.Now we have to think on the end range that’s the maximum limit till which our code should search. After just a moment of thought it becomes clear that the number of digits for the sum must have the same number of digits as a value.
Look at the table below to get the maximum limit.

Digits Maximum n Limit = 95 x n Comments
9 999,999,999 531,441 they need to have the same no. of digits
8 99,999,999 472,392 nope, still too many digits of n .
7 9,999,999 413,343 not quite there
6 999,999 354,294 a valid search limit

So we got the maximum limit as 354,294 . Now let’s write the code.

Python Code –

TotalSum = 0    
Value = []                             #values to be added

#Range we got and then comparing the values according to criteria
for i in range(10, 354294): 
    Sum = 0                       #This sum is for getting one single value 
    for x in str(i):
        Sum += int(x) ** 5        #checking for main condition with power 5 
    if Sum == i:                  #If the sum matches with the value 
        Value.append(i)           #The value we are in search for 

# We add those values stored in the list to get total Sum
for i in Value:
    TotalSum += i

print ("Values :" , Value)
print ("TotalSum :" , TotalSum)

Output ->

Values : [4150, 4151, 54748, 92727, 93084, 194979]
TotalSum : 443839

I also tried with other way by defining a function.

Python Code ->

def power_of_digits(n, exp = 5):
    Sum = 0
    while n > 0:
       Sum += (n % 10)**exp
       n //= 10
    return Sum

total = 0
for i in range(10, 10**6):
    if power_of_digits(i) == i:
        total += i
print(total)

Output ->

443839

Happy Coding! 🙂


by samridhiagarwalblog at September 09, 2017 02:55 PM

Vivek Anand

Realtime Events using Tornado and Rabbitmq

At my day job, i needed a way to send real time events to clients that would in turn trigger some action on their side. The clients could ask for some computation from server which may take time.

To tackle this situation, i ended up making Tornado as a websocket server which will be different from our web app server (and both behind nginx). There are a couple of other services which the client may ask for indirectly. Since, those computations won’t have normal request – response cycle, the results from the computations will have to pushed to the clients. Since, the communication between the client and server is two-way so, websocket seemed fitting. For routing of messages internally, i decided to use Rabbitmq
and Celery for actual execution of tasks.

The problem with this is: Rabbitmq consumer and Tornado both run their own I/O loop. That confused me a little because i had heard this combo worked for zulip when i was randomly reading about their architecture. So, i duckduckgoed(:D) and found this article: https://reminiscential.wordpress.com/2012/04/07/realtime-notification-delivery-using-rabbitmq-tornado-and-websocket/   . It turns out he also had a similar doubt and he got a solution.

Pika library comes with a tornado adapter named TornadoConnection. This makes running the rabbitmq consumer loop inside the tornado IOloop itself. The code for tornado connection is fairly simple. As the code given in the blog wasn’t fully functional, i had to contact the source code of pika a couple of times.

Each websocket connection in tornado gets a unique WebSocketHandler object and these are not directly accessible from the tornado application object. But, the reverse is true. Each websocket handler has access to the application object. So, using TorandoConnection, we tie up one pika consumer to the tornado application object.

server.py

def main():
    ''' The main method to run the tornado application '''

    io_loop = tornado.ioloop.IOLoop.instance()

    pc = PikaConsumer(io_loop)

    application.pc = pc
    application.pc.connect()
    application.listen(8080)
    io_loop.start()

consumer.py

class PikaConsumer(object):
    ''' The pika client the tornado will be part of '''

    def __init__(self, io_loop):
        print 'PikaClient: __init__'
        self.io_loop = io_loop
        self.connected = False
        self.connecting = False
        self.connection = None
        self.channel = None
        self.event_listeners = {}

    def connect(self):
        ''' Connect to the broker '''
        if self.connecting:
           print 'PikaClient: Already connecting to RabbitMQ'
           return

        print 'PikaClient: Connecting to RabbitMQ'
        self.connecting = True

        cred = pika.PlainCredentials('someuser', 'somepass')
        param = pika.ConnectionParameters(
            host='localhost',
            port=5672,
            virtual_host='somevhost',
            credentials=cred)
        self.connection = TornadoConnection(
                    param,
                    on_open_callback=self.on_connected)
        self.connection.add_on_close_callback(self.on_closed)

    def on_connected(self, connection):
        print 'PikaClient: connected to RabbitMQ'
        self.connected = True
        self.connection = connection
        self.connection.channel(self.on_channel_open)

    def on_channel_open(self, channel):
        print 'PikaClient: Channel open, Declaring exchange'
        self.channel = channel
        # declare exchanges, which in turn, declare
        # queues, and bind exchange to queues
        self.channel.exchange_declare(
              exchange='someexchange',
              type='topic')
        self.channel.queue_declare(self.on_queue_declare, exclusive=True)

    def on_queue_declare(self, result):
        queue_name = result.method.queue
        self.channel.queue_bind(
        self.on_queue_bind,
        exchange='someexchange',
        queue=queue_name,
        routing_key='commands.*')
        self.channel.basic_consume(self.on_message)

    def on_queue_bind(self, is_ok):
        print 'PikaClient: Exchanges and queue created/joined'

    def on_closed(self, connection):
        print 'PikaClient: rabbit connection closed'
        self.io_loop.stop()

    def on_message(self, channel, method, header, body):
        print 'PikaClient: message received: %s' % body
        self.notify_listeners(body)
        # important, since rmq needs to know that this msg is received by the
        # consumer. Otherwise, it will be overwhelmed
        channel.basic_ack(delivery_tag=method.delivery_tag)

    def notify_listeners(self, event_obj):
        # do whatever you wish
        pass

    def add_event_listener(self, listener):
        # listener.id is the box id now
        self.event_listeners[listener.id] = {
                'id': listener.id, 'obj': listener}
        print 'PikaClient: listener %s added' % repr(listener)

    def remove_event_listener(self, listener):
        try:
            del self.event_listeners[listener.id]
            print 'PikaClient: listener %s removed' % repr(listener)
        except KeyError:
            pass

    def event_listener(self, some_id):
        ''' Gives the socket object with the given some_id '''

        tmp_obj = self.event_listeners.get(some_id)
        if tmp_obj is not None:
            return tmp_obj['obj']
        return None

That’s it. In your WebSocketHandler objects, you can access the consumer via: self.application.pc

Although, this is working fine for me right now but, i am not fully satisfied with this. At present each connection is listening to a single queue because in rabbitmq one consumer cannot listen to multiple queues.


by Vivek Anand at September 09, 2017 10:33 AM

September 08, 2017

Kshithij Iyer

Some out of the box decor in a shop. #ufo (at Ufo)



Some out of the box decor in a shop.
#ufo (at Ufo)

September 08, 2017 12:28 PM

Ashwani Kumar Gupta

Creating desktop entries in GNU/Linux

Have you ever installed a new program on your linux machine and could not figure out why it doesn’t come up in the launcher search menu? You can still access the program from the terminal it works fine. For example, if you ever installed sublime text you might faced this problem.

Desktop environments and desktop entries

Every GNU/Linux distribution provides a desktop environment which is basically a GUI (Graphical User Interface) for the operating system. A distribution comes with a default desktop environment when you install it for the first time but one can choose and change from various desktop environments out there. Check this link to know how it can be done. The desktop entries are just a specification for a program to integrate it with the desktop environment.

How to put our application on the launcher?

For creating a desktop entry you have to create a .desktop file and edit the file with the specification of the application. We will be creating a desktop entry for sublime text. You can choose any other program for which you want to make a desktop entry. Open your favourite text editor and create a file ​ sublime_text.desktop. Inside this file copy and paste the following text.

[Desktop Entry]
Version=1.0
Type=Application
Name=Sublime Text
Comment=Sophisticated text editor for code, markup and prose
Exec=/opt/sublime_text/sublime_text %F
Terminal=false
MimeType=text/plain;
Icon=sublime-text
Categories=TextEditor;Development;
Actions=Window;Document;

The .desktop file consists of a bunch of fields and their values. Let’s look at what these mean one by one.

Version

This refers to the .desktop file version (Not the application version). Hence it is 1.0

Type

It specifies the type of the program.

Name

This refers to the name of the application. This name will be shown in the launcher. We set it to Sublime Text as we are creating one for sublime text.

Comment

A comment about the application.

Exec

This is a very important field. This specifies the path of the program that will be executed. The full path has to be specified in here. In case the path of the program is specified in the $PATH environment variable, then only the filename will do the task.

Terminal

It specifies if the program can be run on a terminal window or not. It has to be either true or false.

MimeType

It specifies the type of file(s) the program can open. MimeType refers to the type of the data. Here is a complete list of MIME types.

Icon

This is the path to the icon file that the program/file will be using. In our case we entered the directory name as there is only one icon inside it.

Categories

It is the categories of the application. Multiple categories are split with ;. This categorisation is useful as it helps categorising applications on the computer.

To know more about the desktop entry specifications refer to freedesktop desktop entry specification.

After you have put the specifications in the file save it with sublime-text.desktop filename. To get it when you search in the launcher, you have to put the file inside /usr/share/applications or ~/.local/share/applications depending upon creating it for all users or a single user. To do this you have to get root access.

sudo mv sublime-text.desktop /usr/share/applications/sublime-text.desktop

The above command will ask you for your password and put your file in the /usr/share/applications folder. After this, search for ‘sublime text’ on your launcher and you will be able to find it like below.

picccc

That’s it. You have created your new desktop entry. 🙂

 


by Ashwani Gupta at September 08, 2017 06:24 AM

September 07, 2017

Himanshu Awasthi

Python Express(in Kanpur)

Hey Guys ! This is Himanshu & I have good news for Kanpur Python users . Python Express going to conduct Python Beginner workshop at two colleges of Kanpur .

Before describe more about these college I will inform you about Python Express .

What is Python Express ?

Python Express is the ongoing effort of PSSI  with aim of increasing the awareness and awesomeness of Python Programming Language within the student community in India.

Python Express started as an initiative in the month of August 2013, just before the annual PyCon India conference, a bunch of volunteers came together and decided to spread the love of Python far and wide. A lot of colleges and instructors came together conducting numerous workshops, and we celebrated that month as the PythonMonth. Python Month shows how people passionate about python language , the response and enthusiasm was tremendous. PSSI decides if people wanted to learn, and there were people ready to teach, why restrict ourselves to just one month from that day PythonExpress brings tutors, organizations and students together to spread the love of Python far and wide.

PythonExpress conducts free python workshop all over the India To create more awareness on Python programming language and help to build larger Python community.

Only Two colleges from Kanpur apply for workshop  but really Happy to see the name of colleges from my city.

First college is Allenhouse Institute of Technology & I’m taking the beginner session  & another is Kanpur Institute of Technology & I will be volunteering this workshop. you can check out below links :

Thank You ! Python Express

Happy Coding!

 

 


by Himanshu Awasthi at September 07, 2017 06:01 PM

Samridhi Agarwal

Euler Problem no. 4 with Python

I Solved the 4th problem from the Euler’s problem set using python and found that it can be done in multiple ways. The problem is related to palindrome concept.

Problem Statement – 
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.

I first approached the problem statement by thinking that how many maximum digits will a number have so 2 three digits will have max 6 digits number when multiplied and that can be easily achieved by first multiplying the biggest numbers so I took a reverse loop. And then checked the condition of being a palindrome number and displayed the greatest one after comparison .

Python Code ->

palindrome = 0 
# 2 variables to find the biggest palindrome
for a in range(999, 100, -1):       #First factor

#second factor starts from a so that one multiplication does not repeat.  
    for b in range(a, 100, -1): 
        number = a * b  
        if number > palindrome: 

#To check if number is a palindrome. 
            x = str(a * b)   
            if x == x[::-1]:  
                palindrome = a * b  
print(palindrome) 

Output ->

906609 

Trying More Euler’s Problem and the same code with C++. 🙂


by samridhiagarwalblog at September 07, 2017 02:50 PM

Back to Coding Life!

After all this long time I returned back to my hostel (after a lot more traveling and sad days). Everything seems stable now and I wish this remains for a longer time. So today as I returned back there were many things and many tasks to be completed – the internship work (mainly), I missed the dgplug sessions 😦 (reading the logs), Assignments and College.

So Completed with few things now and enjoyed the whole day with my laptop (after 7 days long holiday). First I did the tasks of the internship work (still left with much more). Read the previous 4 logs which i missed (dgplug). There was a session in dgplug where warthog9 was there for the guest session. He was the one who gave us the battle bunnies in the PyCon Pune 2017 and i also wanted to ask him few things about the bunnies but hard luck missed the chance! But the session was great i read the logs and got to learn many things about hardware. 

I think I will take one more day to return to the normal schedule where i can write atleast two codes a day and learn things. Still I tried to complete most of the things (satisfied by myself 😛 ).


by samridhiagarwalblog at September 07, 2017 02:26 PM

Vipin kumar

FOR-LOOP-IN-C

This loop is called controlled loop in C. it genraly divided in three parts initializaton ,condition and
expression[increment/decrement,etc.] all three parts are optional.
If you do’nt give condition to for looop it become true and run infinit times.

SYNTEX :

1. for( initializaton ; condition ; expression )
statement ;

2. for( initializaton ; condition ; expression )
{
statement_1 ;
statement_2 ;
statement_3 ;
statement_……;
}

NOTE : remember the ( ; ) semicolon after each part.

initializaton : In this part we can store values in variable those will used by loop statement.
or we can say we can do our initializaton here in this part.
This part of for loop execute first and once only.

condition : you use a lots of condition in while or do-while loop this is same in this part we can write our condition.
This place in for loop is check each time during execution. if condition become false then loop stop executing.

expression : In this part of loop we can write any expression which execute after running body of loop. amd execute each time
loop will execute.

FLOW-OF-CONTROLE-IN-FOR-LOOP :
In this loop first of all the initializaton part will execute it will execute once then
or conditional part will execute after initializaton it check every time and if it,s true then loop
will execute after checking the condition the flow of loop will move forwarde
now the body of loop will execute after running hole body of loop
The expression will execute after executing body of loop and
after it again the condition will check and loop will flow continusly untill condition become
false.

 

Now ready for a lots of question on for loop.


by kumar vipin yadav at September 07, 2017 08:17 AM

Print-lucas-serese-using-do-while-loop

/*
Let me tell you what a lucas serese it’s a serese in which numbers are to be arange in a secquence the secquence is given below

1 3 4 7 11 18 29 ……………

and we have to print this serese till N.
where user will give value of N
*/

#include<stdio.h>
void main()
{
int sum,first,second,Number;

printf(“Enter a number : “);
scanf(” %d”,&Number);

sum = 0 , second = 3 , first = 1;

do
{
printf( ” %d “,first );
sum = first + second ;
first = second ;
second = sum ;
Number–;
}
while ( Number >= 1 );
}


by kumar vipin yadav at September 07, 2017 08:15 AM

Print-fibonacci-serese-using-do-while-loop

/*
Let me tell you what a fibonacci serese it’s a serese in which numbers are to be arange in a secquence the secquence is given below

0 1 1 2 3 5 8 ……………

and we have to print this serese till N.
where user will give value of N
*/

#include<stdio.h>
void main()
{
int sum,first,second,Number;

printf(“Enter a number : “);
scanf(” %d”,&Number);

sum = 0 , second = 1 , first = 0;

do
{
printf( ” %d “,first );
sum = first + second ;
first = second ;
second = sum ;
Number–;
}
while ( Number >= 1 );
}


by kumar vipin yadav at September 07, 2017 08:15 AM

Read-a-number-and-check-it-is-palindrome-or-not-using-do-while

/*
If you know what is a palindrome then you can directly move to code else read a few line given beloww
a number is said to be palindrome if it’s reverse is same as number.
e.g. – >
1234 is a number and reverse of number is 4321 hence it is not a palindrome.
6776 is a number and it’s reverse is 6776 both the nuber and reverse are equale hence we can say this number is a palindrome.
*/
#include<stdio.h>
void main()
{
int Number,reverse,i;

printf(“Enter a Number :”);
scanf(“%d”,&Number);

i = Number;
reverse = 0;

do
{

reverse = reverse * 10 + i % 10;
i = i / 10 ;

}while ( i != 0 );

if ( Number == reverse )
printf(“Enterd number is an palindrome”);
else
printf(“Enterd number is not an palindrome”);

}


by kumar vipin yadav at September 07, 2017 08:14 AM

Read-a-number-and-check-it-is-prime-or-not-using-do-while

#include<stdio.h>
void main()
{
int Number,i,flag;

printf(“Enter a Number :”);
scanf(“%d”,&Number);

i = 2; // because every number is divesible by 1 ;
flag = 1; // we can give any value to flag.

do
{

if ( Number % i == 0 )
flag = 0; // if number divide by any number from 1 to number-1 then flag become 0.
i++;

}while( i < Number ); // because each number is divesible by itself so we move from 2 to Number-1.

 

if( flag == 0 || Number == 1 )
printf(“Enterd number is not an prime number”);
else
printf(“yes enterd number is an prime number”);

}


by kumar vipin yadav at September 07, 2017 08:13 AM

September 06, 2017

Mohit

The Rabbit or Turlte

"The Rabbit and The Turtle"

We all have heard of this Aesop "The Rabbit and The Turtle". It is a story where a turtle despite being slow challenges rabbit for a race and rabbit out of overconfidence, stop to take a nap and lost it.

The moral behind this story was "Slow and Steady wins the race".

Most of you must have heard this story only up to here, let me tell you my friends, it was just a trailer.

"The Story Beyond"

At the end of the race, rabbit realized his mistake and out of shame (cause one of the fast animal was lost to one of the slowest animal) went to challenge the turtle again.
As expected, this time rabbit won the race.

The moral behind this part is "Fast and Persistent wins the race".

But Wait a minute, there's still something left,

"The Final Blow"


This time, turtle again challenges the rabbit with a condition of choosing the arena himself and Rabbit said yes! (No doubt)

Out of Rabbits surprise, the arena for the race was the pond.  And there is no doubt that this time turtle won the race.

The moral of the Final Blow is: "Never Underestimate your core competence"


Now, What I concluded of all this...

Conclusion

Part 1(Slow and Steady):

As a tech-geek, we should approach to learn any new technology Slow and Steady, never quit in between or you will loose to those, who were once lacking from you.  So Always, delve deeper into new technologies slow and steady to get a good grasp.

Part 2 (Fast and Persistent):

If Someone like me, wants to learn something in a very short time, this approach will be the best.  You have to approach the technologies with a faster pace and keep it persistent.
But also like me, most of you, might not be persistent and may take a pause which is their biggest mistake.

Part 3 (Core Competence):

Never Underestimate your Core Competence, everyone got something, everyone has something special. Everyone is pretty good at some things and not at all in other things.


Now, you might wonder how come we are discussing these stuff today.  Because..., I didn't know about these other two parts and When I did, I felt I should spread the word.

by Abstract Learner (noreply@blogger.com) at September 06, 2017 03:39 PM

September 05, 2017

Bhavin Gandhi

Finding the data usage culprit [ packagekitd ]

Yesterday morning, I noticed that my laptop was using high bandwidth. It was nearly 1MBps. It was little bit suspicious for me. At first, I thought it must be Chrome, but later I realized Chrome does not auto update itself.…

The post Finding the data usage culprit [ packagekitd ] appeared first on GeekSocket.

by Bhavin at September 05, 2017 02:44 PM

Vivek Anand

Running Firefox as kiosk application on RPi3

At my day job, i had to run firefox as a kiosk application on RPi3. In this blog post, i will note down the steps that i did so that i or my team members can refer to it when needed.

I have not used any display manager or Desktop Environment but had to use matchbox-window-manager to make firefox run on full screen.

  1. sudo apt-get install vim (this is just for me, i can’t help it)
  2. sudo apt-get install xorg xutils matchbox-window-manager 
  3. sudo apt-get install iceweasel (this is firefox :p)
  4. sudo raspi-config
    1. Go to boot options and setup auto login for user pi
    2. Change the keyboard layout if you wish to
  5. As a sudo user, do the following steps:
    1. cp -r /home/pi  /opt/
    2. cd /opt/pi
    3. chmod -R a+r .
    4. touch .xsessionrc
    5. chmod a+x .xsessionrc
  6. Open .xsessionrc as a sudo user and put the following lines there:
    1. xset s off # no screen saver
      xset -dpms  # disable some power consumption thingy
      xset s noblank # don’t blank the rpi screen
      matchbox-window-manager &
      while true; do
        firefox –url http://127.0.0.1
      done
  7. Copy .xsessionrc file to /home/pi/ 
    1. cp .xsessionrc /home/pi
  8. Configure .bash_profile to start X server when user logs in:
    1. if [ -z “$DISPLAY” ] && [ -n “$XDG_VTNR” ] && [ “$XDG_VTNR” -eq 1 ]; then
      exec startx
      fi
  9. Install an extension in firefox to apply kiosk mode. The first extension that comes up when you search kiosk in addons works fine

The blog post that helped most in coming up this setup was: http://www.alandmoore.com/blog/2011/11/05/creating-a-kiosk-with-linux-and-x11-2011-edition/


by Vivek Anand at September 05, 2017 09:32 AM

September 04, 2017

Himanshu Awasthi

Experience of PyData Delhi’17

Hello Guys ! I’m Himanshu Awasthi . I’m very excited to share my experience about First PyData Conference in India. PyData Conf was brilliantly organized by PyData Delhi Community  at IIIT Delhi. PyData Delhi was two days event which means lots of fun & learning . I learned about Neural Network  , ArcGis Api , How to Create Sense2vec model  , also very first interaction with JuliaLang  and lots of Stuffs related to Data Science & visualization.

First Day of conference started by awesome keynote by YouTube Star Siraj Raval . He talks about Math behind Deep Learning .

DIsK8V6V4AAgM9j.jpg:large

You can watch video here .

Workshop track was awesome and taken by amazing peoples . I attended these workshops :

  1. Machine learning as a Service by Anand Chitipothu.
  2. Deep Reinforcement Learning by Shubham Dokania
  3. Create a Sense2vec model using Gensim & spacy by Tanu Mittal & Abhishek Kapoor
  4. Introduction to Julia Lang by Dr. Sandeep Nagar

Each talk & workshop was awesome and brilliantly organized by the volunteers and speakers .

Keynotes was awesome but keynote taken by Dr. Pannurangam Kumaraguru about Data Science for Social Good was most impact full talk I have ever seen .

DIybEgiUQAEH1BS.jpg:large

I discussed people about firefly & NetworkX  Library & finally found them amazingly useful . I also met some of my friends & mentor of other python communities .

I really thank full to NumFOCUS because they help people to form a community & learn Data Science together.

I suggest students who willing to learn Deep learning , Data science should join the community of PyData. I miss the open space due to some reason . So I’m really happy to inform you that PyData Kanpur is the local chapter of PyData so the students , Developer who willing to be a part of PyData Community can join us  :

PyData Kanpur

Kanpur, IN
33 Members

PyData is an educational program of NumFOCUS, a 501(c)3 non-profit organization in the United States. PyData provides a forum for the international community of users and deve…

Next Meetup

Welcome to PyData Kanpur

Friday, Sep 15, 2017, 5:00 PM
6 Attending

Check out this Meetup Group →

Thank you !

Happy Coding !


by Himanshu Awasthi at September 04, 2017 08:27 PM

Vivek Anand

Star a project on pagure

This feature was marked as “wishful” and it was supposed to be a low priority but i implemented it out of frustration. This should be there in the next feature release.

Star feature is already there on github and gitlab. I use this feature on github a lot. If I like an open source project, i star it. You also have a list of all the projects which you have starred which can be helpful if you have come across a project sometime ago and had starred it and you want to know more about it (given that you don’t exactly remember the name, otherwise you can just search). Also, if the project author/maintainer is anything like me, he would love to see the star count rising.

For sometime now, i had been asking people who use pagure often (and hopefully like pagure) to star it on github. The star count of pagure was 96 at the time i started my work on star project feature. Last year, at this time, it was in late 60s.

If you star a project on github, your followers come to know that you have liked a project. They can see that on their github homepage. If they see the project, like it, you already have helped pagure reach more people with almost zero effort. I can’t see one good reason if you like a project that you won’t star it.

Pagure doesn’t have the follow feature and i am not sure it will have in near future. This means the star project won’t have it’s full effect. But, one can star a project, there is a star count, there is a list of people who have starred, there is a list of starred projects of a user.

Here is how you can use this feature:

  1. Log in to pagure and go to a project’s home page.
  2. There is a star button, just beside the fork button. It has a star count just beside it.
  3. Star it if you like the project.

Screenshot from 2017-09-05 00-28-45

Here is where you will find your starred projects:

  1. Log in to pagure.
  2. The drop down on the top right corner will be “My Stars”

Screenshot from 2017-09-05 00-43-16

Here is where you can see who all have starred a particular projects:

  1. Right beside the star button on repo page, we have a star count which actually links to a page which lists all the users who have starred the project.

Screenshot from 2017-09-05 00-42-01

 


by Vivek Anand at September 04, 2017 07:20 PM

September 02, 2017

Soumam Banerjee

The Socket Programming



                                  The Socket Programming

Few months ago, i was browsing on my laptop i came across the resume of one of my ideals Aman Goel, I noticed something like "Made a Client Server Messenger using  socket programming libraries of C++ to design a simple server that could chat with upto 30 clients simultaneously." I was like what is this !! socket programming ???? is it saying socket like the electrical engineers study :P ? 
                 I tried to understand what it is but in vain . After few days i lost interest in it so i moved on. As you may be knowing , if you regularly follow me that i am an active student of #dgplug :) there python sessions started. We were taught how powerful and easy python is because of its friendliness and huge bundle of libraries. So again the thought of socket programming came in my mind ,i failed to understand the codes of socket programming in java and c++ then lets give a try with python and atlast i got it :) . Yeah not every thing may be 1% of socket programming but with that knowledge i also made a client server messenger.
How the python files work :---
There are two python files namely server.py and client.py

server.py     code is given below:---
 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import socket
import time


def Main():
host="127.0.0.1"
port=5001

mySocket =socket.socket()
mySocket.bind((host,port))

mySocket.listen(1)
conn, addr= mySocket.accept()
print ("Connection from: "+ str(addr))
while True:
data=conn.recv(1024).decode()
if not data:
break
print("from connected user: "+ str(data))
#data= str(data).upper()
#print("Received from user: "+ str(data))

data=input(">>> ")
conn.send(data.encode())


conn.close()


if __name__ == '__main__':
Main()


client.py     code is given below:---
 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import socket



def Main():
host='127.0.0.1'
port=5001

mySocket= socket.socket()
mySocket.connect((host,port))


message= input(">>> ")


while message !='exit':
mySocket.send(message.encode())

data=mySocket.recv(1024).decode()
print('Recieved from natasha bot: '+data)

message = input(">>> ")

mySocket.close()



if __name__=='__main__':
Main()




How to run the messenger :---
Open 2 terminals .From terminal no. 1 run the server.py file so that it starts listening on its port and then from the terminal no.2 as soon as we run client.py
   
           
short commings to be updated:---
>>>Multiple client messenger to be done
>>>possibly make a GUI of it(i dont know how to though :P)
>>>Now the messenger works within my system only , i want it to be live in the internet :P
Note :---
---------------
>>>Snapshots will be updated soon
>>>The blog is incomplete. I will complete it and there i will explain the code line-wise.
>>>Feel free to contact me if you wanna contribute to my project by any means be it even a readme.txt file :) https://github.com/soumam007/chat_App

email : soumambanerjee007@gmail.com


by SOUMAM BANERJEE (noreply@blogger.com) at September 02, 2017 03:42 PM