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 Throttler: | |
""" | |
A simple throttler that limits the number of requests per time window | |
""" | |
def __init__(self, | |
request_rate: RequestRate = SecMaxRequestRate): | |
self.request_rate = request_rate | |
self.request_timestamps = [] | |
if self.request_rate.time_window == 1: |
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 sys | |
import certifi | |
from cryptography import x509 | |
from cryptography.hazmat.backends import default_backend | |
from cryptography.hazmat.primitives import hashes | |
from cryptography.hazmat.primitives.serialization import Encoding | |
def load_certificates_from_file(file_path): | |
"""Load all certificates from a file, automatically handling PEM and DER formats.""" |
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 edgar import * | |
# Get the current filings | |
filings = get_current_filings() | |
# Page through the filings | |
filings = filings.next() | |
# Select the filing you want | |
filing = filings[0] |
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 edgar import * | |
# Tell SEC Edgar who you are | |
set_identity("First Last First.last@domain.com") | |
# Get filings - by default it gets the current quarter | |
filings = get_filings() | |
# Get filings for 2022 | |
filings = get_filings(year=2020) |
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
mkdir -p output | |
# Install Transformers | |
pip install transformers | |
# Download the wikitext raw data files | |
if [ ! -d "wikitext-2-raw" ]; | |
then | |
wget https://s3.amazonaws.com/research.metamind.io/wikitext/wikitext-2-raw-v1.zip | |
unzip wikitext-2-raw-v1.zip | |
fi |
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 pandas as pd | |
class DataFrameHolder: | |
def __init__(self, data: pd.DataFrame, title=''): | |
self.data = data | |
self.title = title | |
def __len__(self): | |
return len(self.data) |
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
/** | |
* Gets an HTTP resource | |
* @param url the url | |
* @return an InputStream from the resource | |
*/ | |
public static InputStream get(String url){ | |
HttpClient client = HttpClientBuilder.create().build(); | |
try { | |
return client.execute( new HttpGet(url)).getEntity().getContent(); | |
} catch (IOException e) { |
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
package com.dgunning.testtools.sql; | |
import java.util.Arrays; | |
import java.util.HashMap; | |
import java.util.LinkedHashMap; | |
import java.util.Map; | |
import java.util.stream.IntStream; | |
import static java.util.stream.Collectors.joining; | |
import static java.util.stream.Collectors.toMap; |