Friday, 11 April 2014

VTC/USD, VTC/EUR and VTC/GBP Python Script

You may  want download the file here: https://drive.google.com/file/d/0B06EJahqJCOCVzY1eTVMYTZDS00/edit?usp=sharing 

import urllib2
import json
import time
import pandas as pd
from pandas import Series, DataFrame
from urllib2 import URLError
import ystockquote

# Accessing VTC/BTC price from Cryptsy

def vtcbtc():
    try:
        raw = urllib2.urlopen("http://pubapi.cryptsy.com/api.php?method=singleorderdata&marketid=151").read()
        dictionary = json.loads(raw)
        #BID
        bidraw = dictionary['return']['VTC']['buyorders']
        newformatb = pd.DataFrame(bidraw)
        newnameb = newformatb.rename(columns={'price': 'BID'})
        global finalbid1
        finalbid1 = newnameb[0:1]
    except URLError, error:
        print error

#BTC/USD price from BTC-e

def btcusd():
    btcePrices = urllib2.urlopen("https://btc-e.com/api/2/btc_usd/ticker").read()
    btcejson = json.loads(btcePrices)
    global btcelastP 
    btcelastP = btcejson['ticker']['last']
    
    global btcelastB #bid
    btcelastB = btcejson['ticker']['sell']
    
    global btcelastA #ask
    btcelastA = btcejson['ticker']['buy']

def eurusd():
    global eur
    eur=ystockquote.get_price('eurusd=X')

def gpbusd():
    global gbp
    gbp=ystockquote.get_price('GBPUSD=X')

# Calculates Vert/USD price

while True:
    vtcbtc()
    btcusd()
    eurusd()
    gpbusd()
    pricevtcbtc = float(finalbid1["BID"])
    VertUSD = btcelastP * pricevtcbtc
    VertEUR = VertUSD / float(eur)
    VertGBP = VertUSD / float(gbp)
    print time.strftime('%I:%M%p %Z on %b %d, %Y')
    print "VERT/$", VertUSD
    print "VERT/EUR", VertEUR
    print "VERT/GBP", VertGBP
    print
    time.sleep(20) #20 seconds.  
 
 
Sample Output
 

Tuesday, 1 April 2014

How To Find A Website's IP via command line

The command we will be using is nslookup. For example:

nslookup www.cryptsy.com

This will return

Non-authoritative answer:
www.cryptsy.com    canonical name = qrq4x.x.incapdns.net.
Name:    qrq4x.x.incapdns.net
Address: 192.230.66.5

How To Find A Website's IP via command line

How to download a portion of Youtube Video with youtube-dl

First make you have both youtube-dl and ffmpeg installed: sudo apt install youtube-dl ffmpeg Then download a portion of your desired...