This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from svglib.svglib import svg2rlg | |
from reportlab.graphics import renderPDF | |
def svg_to_pdf(in_path, out_path): | |
# svg to pdf | |
drawing = svg2rlg(in_path) | |
renderPDF.drawToFile(drawing, out_path) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import newsapi_v2 | |
import findurls | |
import praw | |
import pandas as pd | |
import utils_func | |
import os | |
import time | |
import subreddit | |
import requests | |
from newspaper import fulltext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# uses the date_to_milliseconds and interval_to_milliseconds functions | |
# https://gist.github.com/sammchardy/3547cfab1faf78e385b3fcb83ad86395 | |
# https://gist.github.com/sammchardy/fcbb2b836d1f694f39bddd569d1c16fe | |
from binance.client import Client | |
import time | |
def get_historical_klines(symbol, interval, start_str, end_str=None): | |
"""Get Historical Klines from Binance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import justext, time | |
import pandas as pd | |
import requests, urllib | |
import utils_func | |
def get_sources(key): | |
""" | |
retrieve all sources from newsapi, filter the german and english speaking | |
and return them as dataframe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
""" | |
url matching regex | |
http://daringfireball.net/2010/07/improved_regex_for_matching_urls | |
""" | |
""" | |
The regex patterns in this gist are intended to match any URLs, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import newsapi_v2 | |
import findurls | |
import praw | |
import pandas as pd | |
import utils_func | |
import os | |
import subreddit | |
import requests | |
from newspaper import fulltext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tweepy import Stream | |
from tweepy import OAuthHandler | |
from tweepy.streaming import StreamListener | |
import json | |
import sqlite3 | |
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer | |
from unidecode import unidecode | |
import time | |
analyzer = SentimentIntensityAnalyzer() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/azam-a/32b89944b98a3fd79d44ebfdac16b63d | |
import pandas as pd | |
import selenium | |
print('selenium.__version__: ', selenium.__version__) | |
from selenium import webdriver | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.support.ui import WebDriverWait | |
from selenium.webdriver.support import expected_conditions as EC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AttentionLSTM(LSTM): | |
"""LSTM with attention mechanism | |
This is an LSTM incorporating an attention mechanism into its hidden states. | |
Currently, the context vector calculated from the attended vector is fed | |
into the model's internal states, closely following the model by Xu et al. | |
(2016, Sec. 3.1.2), using a soft attention model following | |
Bahdanau et al. (2014). | |
The layer expects two inputs instead of the usual one: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy.stats import entropy | |
def js(p, q): | |
p = np.asarray(p) | |
q = np.asarray(q) | |
# normalize | |
p /= p.sum() | |
q /= q.sum() | |
m = (p + q) / 2 |
OlderNewer