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
sed -i "s/{{hostname}}/`hostname`/g" /etc/supervisor/conf.d/celeryd.conf |
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 requests | |
from urllib import urlencode | |
token = '**************************************************' | |
url_base = 'https://api-ssl.bitly.com/v3/' | |
url = 'http://www.repubblica.it' | |
parameters = [('access_token', token), ('longUrl', url)] | |
request = requests.get(url_base + 'shorten/', params = urlencode(parameters)) |
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
server { | |
listen 80; | |
server_name mywebsite.com; | |
access_log /var/log/www/mywebsite.com/log/nginx.access.log; | |
error_log /var/log/www/mywebsite.com/log/nginx_error.log debug; | |
#set your default location | |
location / { | |
proxy_pass http://127.0.0.1:8000/; | |
proxy_redirect off; |
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 requests | |
from urllib import urlencode | |
api_base_url = 'http://localhost:8001/api/1/' | |
api_token = '******************************************' | |
auth_header = {'Authorization': 'Token ' + api_token} | |
parameters = [('type', 'adcountry'), ('limit', 1000)] | |
request = requests.get(api_base_url + 'facebook/search/', params = urlencode(parameters), headers = auth_header) |
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
from __future__ import unicode_literals | |
from django.utils.functional import Promise | |
from rest_framework.compat import timezone, force_text | |
from django.utils.encoding import smart_unicode | |
from rest_framework import renderers | |
import datetime | |
import decimal | |
import types | |
import json | |
from bson import ObjectId |
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
from rest_framework import renderers | |
from rest_framework.utils.encoders import JSONEncoder | |
from bson import ObjectId | |
class FbxJSONEncoder(JSONEncoder): | |
""" | |
FbxJSONEncoder subclass that knows how to encode date/time/timedelta, | |
decimal types, generators and Mongo ObjectId. | |
""" | |
def default(self, o): |
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
from bzrlib import branch | |
import urllib | |
JENKINS_URL = 'http://.....' | |
def post_change_branch_tip_hook(push_result): | |
urllib.openurl(JENKINS_URL) | |
branch.Branch.hooks.install_named_hook('post_change_branch_tip', | |
post_change_branch_tip_hook, 'Jenkins build hook') |
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
# Copyright (c) 2013, Andrea Grandi and individual contributors. | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without modification, | |
# are permitted provided that the following conditions are met: | |
# | |
# 1) Redistributions of source code must retain the above copyright notice, | |
# this list of conditions and the following disclaimer. | |
# | |
# 2) Redistributions in binary form must reproduce the above copyright notice, |
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
# Credits: http://qugstart.com/blog/git-and-svn/add-colored-git-branch-name-to-your-shell-prompt/ | |
function parse_git_branch_and_add_brackets { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \[\1\]/' | |
} | |
PS1="\h:\W \u\[\033[0;32m\]\$(parse_git_branch_and_add_brackets) \[\033[0m\]\$ " |
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
from rest_framework.views import exception_handler | |
def custom_exception_handler(exc): | |
# Call REST framework's default exception handler first, | |
# to get the standard error response. | |
response = exception_handler(exc) | |
# Now add the HTTP status code to the response. | |
if response is not None: | |
response.data['Success'] = False |
OlderNewer