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
<div class="modal hide fade" id="confirm-dialog"> | |
<div class="modal-header"> | |
<a class="close" data-dismiss="modal">×</a> | |
<h3>Confirm</h3> | |
</div> | |
<div class="modal-body"> | |
| |
</div> | |
<div class="modal-footer"> | |
<a href="#" class="btn btn-danger">Ok</a> |
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 django.core.exceptions import PermissionDenied | |
from django.contrib import admin | |
from django.contrib.admin.actions import delete_selected as delete_selected_ | |
def delete_selected(modeladmin, request, queryset): | |
if not modeladmin.has_delete_permission(request): | |
raise PermissionDenied | |
if request.POST.get('post'): | |
for obj in queryset: |
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
# virtualenvwrapper | |
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 | |
source /usr/local/bin/virtualenvwrapper.sh |
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
# Emperor uWSGI script /etc/init/uwsgi-emperor.conf | |
description "uWSGI Emperor" | |
start on runlevel [2345] | |
stop on runlevel [06] | |
env UWSGI_VASSAL_SOCKET=/tmp/uwsgi/%n.sock | |
exec uwsgi --master --die-on-term --emperor "/home/*/uwsgi/*.ini" --emperor-tyrant |
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
# MyApp UpStart script template | |
description "MyApp python server" | |
start on startup | |
stop on shutdown | |
respawn | |
# It's a good idea to setup LANG | |
env LANG=en_US.UTF-8 | |
env USER=myuser | |
env COMMAND=/home/myuser/.virtualenvs/myapp/bin/python |
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
/* Based on http://stackoverflow.com/questions/1714786/querystring-encoding-of-a-javascript-object | |
*/ | |
var serializeToURL = function(obj, prefix) { | |
var url = []; | |
for(var p in obj) { | |
var k = prefix ? prefix : p, v = obj[p]; | |
url.push(typeof v == "object" ? | |
serializeToURL(v, k) : | |
encodeURIComponent(k) + "=" + encodeURIComponent(v)); | |
} |
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 | |
def make_random_password(length=12, symbols='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@$^_+&'): | |
password = [] | |
for i in map(lambda x: int(len(symbols)*x/255.0), os.urandom(length)): | |
password.append(symbols[i]) | |
return ''.join(password) |
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 math | |
def georange(origin, distance): | |
""" | |
Returns approximate longitude & latitude rectangle range for | |
specified origin and distance in km. Works good when: | |
distance is far smaller 6400 km (approximate Earth radius) | |
origin isn't too close to North and South poles |
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
#!/bin/sh | |
# Helper script for generating push notification certificates based on tutorial: | |
# http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1 | |
function show_help_and_exit | |
{ | |
echo "usage:" $0 \<certificate output\> \<private key output\> \<combined output\> | |
echo | |
echo "Input files are not specified, they are supposed to have" |
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
upstream app_server { | |
# Gunicorn or runfcgi-powered Django server | |
server 127.0.0.1:8000 fail_timeout=0; | |
} | |
server { | |
server_name server.name; | |
listen 443 ssl; | |
client_max_body_size 4G; | |
keepalive_timeout 5; |
OlderNewer