Thursday, 12 March 2015

How to download from torrent

Step 1: Open https://torrentz.eu/ . This is a torrent search engine. Like Google for torrents.

Step 2: Search. Search for what you are looking to download.


Step 3: click on 1 that matches your search best. Look at rating and size. Some torrents could be very large like 10-20 Gb. Some could still be large like 2-3Gb for a BlueRay Movie or something. While we can manage with a 720 Blure Ray Rip.

Step 4: Open this torrent you chose in a new tab. This may take 2 clicks. On your first click you might end up opening an Ad and on the 2nd click the actual torrent may open. 


Step 5: I trust very few websites. Like https://kickass.to/ or http://1337x.to/ or http://thepiratebay.to/. These are the reliable once. Open that link in a new Tab.

Step 6: Now the crucial parts. Check for the comments and likes on the torrent. That will tell you what other users who have downloaded the torrent say about it. if they found it useful or not.



Step 7: Now open the downloaded .torrent file in a torrent client like Bit torrent, U Torrent, Deludge for linux. It should download a some time.

Step 8: And if you have limited bandwidth then once the download is complete stop that particular torrent otherwise it will keep uploading/seeding which will consume your bandwidth. 


Other ways to verify a torrent is genuine or not is to check other uploads from the same up-loader.

open the up-loader account in new tab.


check the users other uploads and comments on them.



Enjoy your downloads :)

Friday, 6 March 2015

How to achieve port forwarding

you will need a few things:

A computer through which you want to achieve port forwarding:

details required:

ip
port # any port would do
ssh key # if needed to access the computer or password
username on that computer


run this command in the terminal to port forward from port 8080 on your computer to the remote computer over ssh.

     ssh -D 8080 -C -N -i ~/.ssh/key.pem ubuntu@<ip>

Now configure your browser to talk to this computer as a proxy server on the port you specified.

This is browser level configuration for Firefox. You can configure the same proxy settings at Ubuntu/OS level to use it across the system from any browser or computer.

cheers.

How to extract email ids from your gmail account using a python script

Recently a friend of mine asked me to give him all the email ids that i have. Post the usual discussion of 'i will not spam them, it's research purpose, ... is what i am working on' i agreed to give him the list. He sent me a link to some 3rd part service which i was suppose to authenticate to so he can get the list of mail id's. While he is not a techie, i am. So agreeing to an o-auth with some random 3rd party website does not sound like a good idea to me. Thus i mailed him that i will not authenticate a 3rd party app with o-auth but i will give him the list of mail ids and i will extract it myself. He didn't mind it so i set to work:

I found a simple program online :


import imaplib, email

def split_mail_id(email_id):
    #split an address list into list of tuples of (name, address)
    if not(email_id): return []
    out_queue = True
    cut = -1
    result = []
    for i in range(len(email_id)):
        if email_id[i]=='"': out_queue = not(out_queue)
        if out_queue and email_id[i]==',':
            result.append(email.utils.parseaddr(email_id[cut+1:i]))
            cut = i
    result.append(email.utils.parseaddr(email_id[cut+1:i+1]))
    return result

user_id = "<email>"
password = "<app_password>" #at the bottom of the page we explain how to get this password

mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login(user_id, password)
mail.select("INBOX")
result, data = mail.search(None,"ALL")
ids = data[0].split()
msgs = mail.fetch(','.join(ids),'(BODY.PEEK[HEADER])')[1][0::2]
addresses = []
for x, msg in msgs:
    msgobj = email.message_from_string(msg)
    addresses.extend(split_mail_id(msgobj['to']))
    addresses.extend(split_mail_id(msgobj['from']))
    addresses.extend(split_mail_id(msgobj['cc']))

output_file = open('mail_ids.txt','w')
for address in addresses:
    output_file.write(address[1] + "\n")
output_file.close()


Now, How to get app specific gmail password:

goto : https://myaccount.google.com/

and select App passwords or direct click this link: 

https://security.google.com/settings/security/apppasswords

There select "other". Enter a name like mail_ids and generate a password.


this is a google app password. You can use this password to access your gmail account from any app.


Finally my friend got all the mail ids in a .txt file. He is happy and i am happy that i didn't had to authenticate a 3rd party app with my gmail.

Peace Out.

Clear all queue in rabitmq

To clear a queue in rabbitmq or get no of jobs/consumers in/on the queue:

open python shell
enable a connection to the rabbitmq server
open a channel to the connection

import amqplib.client_0_8 as amqp 

host = <IP>
port = <PORT>
connection= amqp.Connection(host ='%s:%s' % (host, port),
                                                  userid = '<user>',
                                                  password = '<password>',
                                                  ssl = False,
                                                  virtual_host = 'rabbitvhost')  
channel = connection.channel()

name, jobs, consumers = channel.queue_declare(queue='queue_name', passive=True)
         

jobs # no of jobs in the queue
consumers # no of workers working on that queue


#Delete the queue
channel.queue_delete(queue='queue_name')

# Close the channel
channel.close() 
# Close our connection
connection.close()
happy programming :)