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
name: execute bash script | |
command: bash {{ APP_DIR }}/some_script.sh |
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
#A very good resource on configuring some webservers with ssl: | |
https://wiki.mozilla.org/Security/Server_Side_TLS | |
# create a file: /etc/nginx/sites-enabled/app_name.conf and also link to /etc/nginx/sites-available/app_name.conf | |
# and edit as: | |
log_format timed_combined '$remote_addr - $remote_user [$time_local] ' | |
'"$request" $status $body_bytes_sent ' | |
'"$http_referer" "$http_user_agent" $request_time'; |
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 os | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") | |
# This application object is used by the development server | |
# as well as any WSGI server configured to use this file. | |
import django.core.handlers.wsgi | |
application = django.core.handlers.wsgi.WSGIHandler() |
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
#Taken from: | |
http://nategood.com/client-side-certificate-authentication-in-ngi | |
#reposted here to preserve history | |
#see: https://gist.github.com/komuW/076231fd9b10bb73e40f for a bash script to auto-generate all this | |
Client Side Certificate Auth in Nginx | |
Why Client-Side Certificate Authentication? Why nginx? | |
I sometimes peruse the ReST questions of stackoverflow.com. Many times I see questions about authentication. There are many options (Basic HTTP Auth, Digest HTTP Auth, OAuth, OAuth Wrap, etc.) however when security is of importance, I like to recommend client side certificates. This is the route our team at ShowClix chose when implementing our API. |
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
#! /usr/bin/env bash | |
# Create the CA Key and Certificate for signing Client Certs | |
openssl genrsa -des3 -out ca.key 4096 | |
openssl req -new -x509 -days 365 -key ca.key -out ca.crt | |
# Create the Server Key, CSR, and Certificate | |
openssl genrsa -des3 -out server.key 1024 | |
openssl req -new -key server.key -out server.csr |
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
#/etc/haproxy/haproxy.cfg | |
frontend http-in | |
bind *:{{APP_PORT}} | |
mode http | |
default_backend servers | |
frontend https-in | |
bind *:{{APP_PORT_HTTPS}} ssl no-sslv3 crt /etc/haproxy/server_cert.pem | |
reqadd X-Forwarded-Proto:\ https |
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 DateTimefaker(datetime): | |
""" | |
fake datetime to use your own custom datetimes | |
""" | |
def __new__(cls, *args, **kwargs): | |
return datetime.__new__(datetime, *args, **kwargs) | |
class TestSomething(TestCase): | |
fixtures = ['test_data'] |
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
# We compare/measure reading a file from memory(1) vs reading from filesytem(2) | |
################################## | |
### 1. reading file from memory ## | |
################################## | |
import time | |
import mmap | |
filename = "myfile.txt" |
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
from rest_framework.test import APIClient | |
class SomeTests(LiveServerTestCase): | |
def setUp(self): | |
self.real_URL = settings.SOME_URL | |
settings.SOME_URL = '{0}/some-url/'.format(self.live_server_url) | |
self.client = APIClient() | |
self.payload = """<some>xml-string</xml>""" |
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
package main | |
import ( | |
"fmt" | |
"net/http" | |
) | |
type Mystring string | |
type Mystruct struct { |