This file contains hidden or 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
| var http = require('http'); | |
| function make_request(options, payload) { | |
| return new Promise(function(resolve,reject) { | |
| if(payload) options.method = 'POST'; else options.method = 'GET'; | |
| var request = http.request(options,function(response) { | |
| var str = ''; | |
| response.on('error', function() { reject('Error'); } ) | |
| response.on('data', function (chunk) { str += chunk; }) | |
| response.on('end', function () { resolve(JSON.parse(str));}) |
This file contains hidden or 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
| {% set ver_str = [grains.os|lower,grains.osrelease,grains.osarch]|join('/') %} | |
| {% set release = latest %} {# currently 2015.8 #} | |
| {% set release = 2015.5 %} | |
| salt_repo: | |
| pkgrepo.managed: | |
| - humanname: salt-repo | |
| - name: "deb http://repo.saltstack.com/apt/{{ ver_str }}/{{ release }} {{ grains.oscodename }} main" | |
| - file: /etc/apt/sources.list.d/salt.list | |
| - keyid: DE57BFBE |
This file contains hidden or 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 urlparse | |
| import argparse | |
| import psycopg2 | |
| class Bunch: | |
| def __init__(self, **kwds): | |
| self.__dict__.update(kwds) | |
This file contains hidden or 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
| # pip install retryz backoff | |
| from __future__ import print_function | |
| import random | |
| import retryz | |
| import backoff | |
| def naughty_func(): | |
| picky = random.randint(1, 3) |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html lang="en" xmlns="http://www.w3.org/1999/html"> | |
| <head> | |
| <meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <title>Title</title> | |
| <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> | |
| </head> | |
| <body class="" style="" xmlns:ng="http://angularjs.org" ng-app="fooApp" ng-strict-di> |
This file contains hidden or 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 os | |
| import sys | |
| import bottle | |
| bottle.debug(True) | |
| static_root = os.path.abspath(os.path.dirname(__file__)) | |
| @bottle.route('/') |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| ''' | |
| `@beartype` decorator, implementing a rudimentary subset of PEP 484-style type | |
| checking based on Python 3.x function annotations. | |
| See Also | |
| ---------- | |
| https://stackoverflow.com/a/37961120/2809027 | |
| Stackoverflow answer introducing the `@beartype` decorator. |
This file contains hidden or 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 logging | |
| from django.db import connection | |
| from django.conf import settings | |
| from celery.signals import task_prerun, task_postrun | |
| from time import time | |
| @task_prerun.connect() |
This file contains hidden or 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 json | |
| import logging | |
| import pip | |
| import site | |
| # installed by lambda env | |
| # import six | |
| # import boto3 | |
| # from dateutil.easter import * |
This file contains hidden or 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
| callers = {} | |
| def _ghetto_compile(pattern, flags=0): | |
| import inspect | |
| try: | |
| frame = '{}'.format(inspect.currentframe().f_back.f_code) | |
| val = callers.setdefault(frame,0) | |
| callers[frame] = val + 1 | |
| # print(frame) | |
| if 'rest_framework.py' in frame: |