Skip to content

Instantly share code, notes, and snippets.

View axolx's full-sized avatar
🐝

Martin Rio axolx

🐝
View GitHub Profile
diff --git a/services/web/src/website/settings/base.py b/services/web/src/website/settings/base.py
index 25bb9c96..47edb55b 100644
--- a/services/web/src/website/settings/base.py
+++ b/services/web/src/website/settings/base.py
@@ -569,9 +569,21 @@ if os.getenv("SENTRY_DSN"):
return None
return event
+ # Set up Sentry distributed tracing
+ # see https://docs.sentry.io/platforms/python/performance/
@axolx
axolx / etrm-api-request.py
Created February 26, 2021 00:31
Sample Python code for making requests to the eTRM API
#!/usr/bin/env python3
"""
Sample Python code for making requests to the eTRM API
"""
import http.client
import json
TOKEN = "SETME"
@axolx
axolx / sts_assume_role.bash
Last active October 4, 2022 23:48
A Bash function to assume an AWS role with MFA and update the awscli environment to the assumed role
sts_assume_role () {
read -p "Enter a current MFA token code: " token_code
role_credentials=`aws sts assume-role \
--role-arn <role-arn> \
--role-session-name <session-name> \
--serial-number <mfa-arn> \
--token-code ${token_code}`
export AWS_ACCESS_KEY_ID=$(echo $role_credentials | jq -r .Credentials.AccessKeyId)
export AWS_SECRET_ACCESS_KEY=$(echo $role_credentials | jq -r .Credentials.SecretAccessKey)
export AWS_SESSION_TOKEN=$(echo $role_credentials | jq -r .Credentials.SessionToken)
@axolx
axolx / s3-cors-bucket.yaml
Created July 26, 2018 17:14
Sample CloudFormation stack for a bucket for AJAX uploads to S3
# Sample CloudFormation stack to create a bucket for AJAX uploads to S3
# Includes a lifecycle policy, CORS settings, and a IAM policy
# aws cloudformation create-stack --capabilities CAPABILITY_IAM --stack-name my-bucket --template-body file://s3-bucket.yaml --parameters ParameterKey=BucketName,ParameterValue=my-bucket ParameterKey=ExpirationDays,ParameterValue=2 ParameterKey=Role,ParameterValue=my-role
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
BucketName:
Type: String
Description: The name for the bucket
@axolx
axolx / gist:4eb54de4b8a4714fcda4071ce333da02
Created September 9, 2016 15:15
uptimerobot.com API monitor add
#! /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python
import os
import argparse
import requests
import json
from pprint import pprint
# Requires evironment variable UPTIMEROBOT_API_KEY
@axolx
axolx / 0_reuse_code.js
Last active August 29, 2015 14:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@axolx
axolx / nav-reveal.js
Created June 30, 2014 22:02
Implements nav reveal for Bootstrap 3 fixed navbar
/**
* Hide navbar on on scroll down, reveal on scroll up
* @see https://medium.com/@mariusc23/hide-header-on-scroll-down-show-on-scroll-up-67bbaae9a78c
*/
(function ($) {
'use strict';
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $('.navbar').outerHeight();
<?php
if (class_exists('Memcache')) {
$server = 'SETME'; # Memcached server hostname
$memcache = new Memcache;
$isMemcacheAvailable = @$memcache->connect($server);
if ($isMemcacheAvailable) {
$aData = $memcache->get('data');
echo '<pre>';
@axolx
axolx / ses_mail.py
Last active December 31, 2015 23:59
Sendmail `mail` with AWS SES
#! /usr/bin/env python
"""
A very basic script that emulates Sendmail's `mail` command, sending emails
with [aws-cli](https://github.com/aws/aws-cli). It replicates the minimum
amount of functionality for delivery [Munin notifications](
http://munin-monitoring.org/wiki/HowToContact) (e.g. `contact.email.command
ses_mail -s "Munin-notification for ${var:group} :: ${var:host}" your@email
.address.here`
).
@axolx
axolx / gist:7829436
Created December 6, 2013 18:06
A handy Memcached memoization decorator for Python
"""memorised module - container for the memorise python-memcache decorator"""
__author__ = 'Wes Mason <wes [at] 1stvamp [dot] org>'
__docformat__ = 'restructuredtext en'
__version__ = '1.0.1'
import memcache
import itertools
from hashlib import md5
from functools import wraps
import inspect