Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
class Script { | |
process_incoming_request({ request }) { | |
// console is a global helper to improve debug | |
console.log("Sentry error"); | |
console.log(JSON.stringify(request.content)); | |
var fields = []; | |
fields.push({ | |
title: "Message", |
import base64 | |
from rest_framework import HTTP_HEADER_ENCODING, status | |
from rest_framework.test import APITestCase | |
from user.models import User | |
class EndpointViewTest(APITestCase): | |
def test_basic_auth(self): | |
username = "test_username" |
#!/bin/sh | |
## --- tunnel_to_master_redis | |
REDIS_MASTER=XYZ | |
REDIS_SLAVE_PORT=6280 | |
AUTOSSH_POLL=300 | |
AUTOSSH_PORT=20000 | |
AUTOSSH_GATETIME=10 | |
AUTOSSH_LOGFILE=/var/log/autossh/autossh.log |
#!/usr/bin/env python | |
# Haversine formula example in Python | |
# Author: Wayne Dyck | |
import math | |
def distance(origin, destination): | |
lat1, lon1 = origin | |
lat2, lon2 = destination |
from fabric.api import * | |
from fabric.contrib.console import confirm | |
from local_settings import remote_user | |
from time import time | |
import subprocess, shlex, atexit, time | |
from settings import DATABASES | |
from os import remove | |
env.use_ssh_config = True | |
env.context = 'local' |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
# -*- coding: utf-8 -*- | |
from django.contrib.auth.decorators import login_required | |
from django.utils.cache import patch_response_headers | |
from django.utils.decorators import method_decorator | |
from django.views.decorators.cache import cache_page, never_cache | |
from django.views.decorators.csrf import csrf_exempt | |
class NeverCacheMixin(object): | |
@method_decorator(never_cache) |
import datetime | |
# requires python-dateutil (http://labix.org/python-dateutil) | |
from dateutil.relativedelta import relativedelta | |
def get_month_day_range(date): | |
""" | |
For a date 'date' returns the start and end date for the month of 'date'. | |
Month with 31 days: |
import logging | |
logger = logging.getLogger(__name__) | |
# Note: we need dnspython for this to work | |
# Install with `pip install dnspython` | |
import dns.resolver, dns.exception | |
from django import forms | |
from django.utils.translation import ugettext as _ |