Skip to content

Instantly share code, notes, and snippets.

@cemk
Last active November 25, 2018 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cemk/23119bfae1516ad95a361bdc570ed5cf to your computer and use it in GitHub Desktop.
Save cemk/23119bfae1516ad95a361bdc570ed5cf to your computer and use it in GitHub Desktop.
BitBar için döviz kuru göstergesi. Doviz.com API erişimini engellediği için canlidoviz.com'dan çekiyor verileri.
#!/usr/bin/env ruby
# <bitbar.title>Çoklu Döviz Kontrolü</bitbar.title>
# <bitbar.version>5.285</bitbar.version>
require 'open-uri'
require 'json'
begin
puts "💵"
puts "---"
checkCurr = Array['USD', 'EUR', 'AUD', 'GBP', 'CAD']
currencies = JSON.parse(open('https://api.canlidoviz.com/web/items?marketId=1&type=0').read)
currencies.each do |currency|
if checkCurr.include?(currency['code'])
country_code = currency['code'].chomp.split ''
c1, c2 = *country_code.map { |c| (c.ord + 0x65).chr.force_encoding 'UTF-8' }
puts "\xF0\x9F\x87#{c1}\xF0\x9F\x87#{c2}" + currency['code'].to_s
puts "Satış: " + currency['sellPrice'].round(3).to_s
puts "Alış: " + currency['buyPrice'].round(3).to_s
puts "---"
end
end
rescue StandardError => err
puts "🚩"
puts "---"
puts err.to_s
end
#!/usr/bin/python
# -*- coding: utf-8 -*-
# <bitbar.title>BTC->USD&TRY</bitbar.title>
# <bitbar.version>3.352</bitbar.version>
# <bitbar.author>Cem K.</bitbar.author>
# <bitbar.author.github>cemk</bitbar.author.github>
# <bitbar.desc>BTC/USD/TRY</bitbar.desc>
import urllib2
import json
import locale
locale.setlocale(locale.LC_ALL, 'tr_TR')
request = urllib2.Request("https://api.coinbase.com/v2/exchange-rates?currency=btc")
result = urllib2.urlopen(request).read()
jsonRes = json.loads(result)
usd = float(jsonRes["data"]["rates"]["USD"])
tr = float(jsonRes["data"]["rates"]["TRY"])
print "₿: " + locale.currency(usd, symbol=False, grouping=True)
print "---"
print "₺ → " + locale.currency(tr, symbol=False, grouping=True) + " | color=#000"
print "---"
print "Coinbase.com'da gör | href=https://www.coinbase.com/charts?locale=en"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment