Skip to content

Instantly share code, notes, and snippets.

@btoueg
btoueg / synthetics_test.yml
Last active Mar 22, 2019
Terraform draft
View synthetics_test.yml
resource "datadog_synthetics" "foo" {
# Every attributes required to create a new Datadog synthetics test
name = "Name for synthetics foo"
type = "api"
message = "Synthetics test failed. Notify: @slack-channel"
options {
tick_every = 60
}
config {
request {
View phpinfo.php
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
@btoueg
btoueg / main.py
Last active Jan 21, 2019
An example of asymmetric encryption in python 2.7 - utilizes cryptography library
View main.py
# -*- encoding: utf-8 -*-
import base64
import logging
from cryptography.exceptions import UnsupportedAlgorithm
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import padding
@btoueg
btoueg / main.py
Last active Jan 8, 2021
An example of symmetric encryption in python 2.7 using a single known secret key - utilizes cryptography library
View main.py
# -*- encoding: utf-8 -*-
import os
import base64
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
backend = default_backend()
secret_key = base64.b64decode(
# generated randomly once, kept secret
@btoueg
btoueg / Readme.md
Last active Apr 20, 2018
Demonstration of throttling aiohttp with semaphore
View Readme.md

I'm trying to achieve fine-grained throttling with aiohttp.

By fine-grained, I mean that controlling how many requests are simultaneously executed is not enough, I want to rate-limit the number of requests to match 100 requests per 10 seconds interval.

The interesting part resides in throttled_coroutine which acquires/releases a lock at a speed which is exactly the rate-limit I want to enforce by either:

  • waiting a delay once requests performing very quickly are completed
  • releasing lock before completion of requests performing poorly

At the end of a batch of requests, last coroutines tend to wait for no reason. This behaviour amplifies when timeout increases.

@btoueg
btoueg / sellsy.py
Created Mar 2, 2015
Sellsy API python with OAuth
View sellsy.py
# -*- coding: utf-8 -*-
import json
import requests
from requests_oauthlib import OAuth1
from oauthlib.oauth1 import SIGNATURE_PLAINTEXT, SIGNATURE_TYPE_BODY
consumer_token = '***'
consumer_secret = '***'
user_token = '***'