This file contains 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
class SettingsReader: | |
def __init__(self, opts, config, settings): | |
self.opts = opts | |
self.config = config | |
self.settings = settings | |
def __contains__(self, key): | |
if (key in self.opts or | |
key in self.config or | |
key in self.settings): |
This file contains 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
function p_curl() { | |
{ | |
curl "$@" | |
}|python -mjson.tool | |
} |
This file contains 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
config.vm.box_url = "http://files.vagrantup.com/lucid64.box" | |
config.vm.box = "ubuntu/lucid64" | |
config.vm.network "forwarded_port", guest: 5984, host: 5984 | |
config.vm.provision "shell", inline: <<-SHELL | |
sudo apt-get update | |
sudo apt-get install -y python-software-properties curl |
This file contains 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 inspect import getouterframes, currentframe | |
from functools import wraps | |
logger = logging.getLogger(__name__) | |
def _get_caller_details(curframe): | |
""" | |
Helper retrieving caller details from current frame |
This file contains 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
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.db import migrations | |
from django.contrib.auth.admin import User | |
def create_superuser(apps, schema_editor): | |
superuser = User() | |
superuser.is_active = True |
This file contains 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
[{"model": "auth.user", | |
"pk": 1, | |
"fields": | |
{"username": "admin", | |
"first_name": "", | |
"last_name": "", | |
"is_active": true, | |
"is_superuser": true, | |
"is_staff": true, | |
"password": "pbkdf2_sha256$15000$TrGrqtzwNJUa$omLG886xVSLNxYOvjrceDbWQS5ISmzyPM9ka0rAhu3Y=", |
This file contains 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
def get_version(): | |
local_vars = {} | |
try: | |
execfile('src/imagination/objectid_manager/__init__.py', | |
{}, | |
local_vars) | |
except NameError: | |
# python3.x does not provide execfile | |
with open('src/imagination/objectid_manager/__init__.py') as f: | |
exec(f.read(), {}, local_vars) |
This file contains 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
def retry(retries=3, callback_on_failure=None): | |
"""Retry requests method and run callback on failure | |
Decorator will retry the decorated function for specified number of times, | |
default is 3. If there is a callback passed, it will be called before | |
calling the decorated function again. Callback allows to perform cleanups, | |
clear the credentials, etc. | |
Decorator will only work with functions that return requests.Request | |
object, if decorated method returns other object result is returned with | |
out retrying. |
This file contains 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
def kwargs_default(params): | |
"""Decorator for setting default keyword parameters | |
@kwargs_default((('number_of_chickens', 3),)) | |
will add param 'number_of_chickens' with value of 3 into kwargs. | |
:param params: tuple of tuples consiting of name of parameter and value | |
:type params: tuple of tuples with str and any ((str, any), (str, any), ...) | |
""" |
This file contains 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
OlderNewer