Skip to content

Instantly share code, notes, and snippets.

View purple4reina's full-sized avatar
💜

Rey Abolofia purple4reina

💜
View GitHub Profile
@purple4reina
purple4reina / agent.py
Created November 18, 2022 23:01
Datadog agent in customer code
# This is the agent interfacer code which can be used to start/stop/flush a Datadog agent
import pkg_resources
import requests
import subprocess
import time
from ddtrace import tracer as ddtracer
@purple4reina
purple4reina / datadog.tar.gz
Last active November 14, 2022 22:04
azure testing
This file has been truncated, but you can view the full file.
# https://realpython.com/generative-adversarial-networks/
# https://salu133445.github.io/lakh-pianoroll-dataset/
import torch
from torch import nn
import time
import json
import math
import matplotlib.pyplot as plt
@purple4reina
purple4reina / safe_template.py
Last active August 29, 2015 14:22
Django Safe Template
from django.template import Template
class SafeTemplate(Template):
"""
Subclass of the regular django Template but disallows rendering anything
that will call a method on a class thus making it safe for use as a user
editable object
Examples:
# this will return the template as expected
@purple4reina
purple4reina / run_unittests.py
Created June 9, 2015 21:43
Running Django Unit Tests
#!/usr/bin/env python
"""
Run all unit tests within the current working directory optionally skipping
some modules
This script should be used instead of running `./manage.py test`. This django
provided unittest runner does not reset the testing database between each
testing file. The only way to ensure the testing database is completely dropped
is by running each test file individually.
class throttle(object):
"""
Decorator that prevents a function from being called more than once every
time period. If called too soon, RuntimeError is raised.
To create a function that cannot be called more than once a minute:
@throttle(minutes=1)
def my_fun():
pass