Skip to content

Instantly share code, notes, and snippets.

View KolevDarko's full-sized avatar
🎯
Focusing

Darko Kolev KolevDarko

🎯
Focusing
View GitHub Profile
@KolevDarko
KolevDarko / Architecture.md
Created November 19, 2017 18:33 — forked from evancz/Architecture.md
Ideas and guidelines for architecting larger applications in Elm to be modular and extensible

Architecture in Elm

This document is a collection of concepts and strategies to make large Elm projects modular and extensible.

We will start by thinking about the structure of signals in our program. Broadly speaking, your application state should live in one big foldp. You will probably merge a bunch of input signals into a single stream of updates. This sounds a bit crazy at first, but it is in the same ballpark as Om or Facebook's Flux. There are a couple major benefits to having a centralized home for your application state:

  1. There is a single source of truth. Traditional approaches force you to write a decent amount of custom and error prone code to synchronize state between many different stateful components. (The state of this widget needs to be synced with the application state, which needs to be synced with some other widget, etc.) By placing all of your state in one location, you eliminate an entire class of bugs in which two components get into inconsistent states. We also think yo
if __name__ == '__main__':
my_exchange = input("Your exchange:")
starting_price = input("Bitcoin starting price:")
amount = input("Bitcoin amount:")
currency = input("Your currency (default USD):")
check_every = input("Check every (seconds):")
threshold = input("Choose to be notified when a certain limit is reached\n1) Percent limit: \n2) Amount limit: \n ")
limit_type = None
limit = 0
if threshold == '1':
def calc_percent_diff(now, base):
difference = now - base
return difference * 100 / base
def calculate_profits(cc, latest_bid, starting_price, amount, limit_type, limit):
difference = abs((latest_bid - starting_price) * amount)
single_diff = latest_bid - starting_price
if limit_type == 'percent':
percent_difference = calc_percent_diff(latest_bid, starting_price)
if percent_difference >= limit:
{
"name": "bitstamp",
"display_name": "Bitstamp",
"url": "https://bitstamp.net/",
"timestamp": 1493816831,
"data_source": "api",
"symbols": {
"XRPEUR": {
"last": 0.0513,
"volume": 5706005.4795,
def main(exchange, starting_price, amount, currency, limit_type, limit):
"""
:param exchange: The exchange where bitcoin was bought
:param starting_price: The price at which bitcoin was bought
:param amount: The amount of bitcoin
:param currency: The currency bitcoin was bought in
:param limit_type: The type of threshold, percent or amount
:param limit: The value of the threshold
:return: Current profit made
"""
def create_signature():
ts = str(int(time.time()))
sig = str(ts + "." + public_key).encode()
sign = hmac.new(secret_key.encode(), sig, digestmod=sha256).hexdigest()
signature = "{0}.{1}.{2}".format(ts, public_key, sign)
return signature
@KolevDarko
KolevDarko / ba-profits-guide-1.py
Last active June 16, 2017 07:59
Snippet 1 from BitcoinAverage Bitcoin profits article
import hmac
import time
from hashlib import sha256
import subprocess
import requests
secret_key = '<your secret key here>' or input('Enter your secret key: ')
public_key = '<your public key here>' or input('Enter your public key: ')
# Full code
import hmac
import time
from hashlib import sha256
import subprocess
import requests
secret_key = '' or input('Enter your secret key: ')
public_key = '' or input('Enter your public key: ')
@KolevDarko
KolevDarko / cache.py
Created September 12, 2016 08:41 — forked from cloverstd/cache.py
tornado cache
# coding: utf-8
try:
import cPickle as pickle
except ImportError:
import pickle
try:
import hashlib
sha1 = hashlib.sha1
@KolevDarko
KolevDarko / Angular mistakes
Last active August 29, 2015 14:22
List of common AngularJS mistakes
1. Always use objects when using binding in angular directives.
2. Everything is camel case, dashes don't exist in link function.
3. Add headers: headers: {'Content-Type': 'application/x-www-form-urlencoded'} when trying to submit form data with $http
4. $scope is not a model!!!