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
# No Rights Reserved | |
# http://creativecommons.org/publicdomain/zero/1.0/ | |
""" | |
Flask-Admin simple helpers | |
========================== | |
Just copy and paste to some of your helpers or base classes module, import and use. | |
You'll also need to install Flask-Login for using authentication. |
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
# -*- coding: utf-8 -*- | |
# | |
# No Rights Reserved | |
# http://creativecommons.org/publicdomain/zero/1.0/ | |
"""Agnostic minimal session based cart for Django. | |
Just copy-n-paste this snippet to your project. | |
See `Cart` class reference below for details. |
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
// | |
// HyperShortcuts.h | |
// Created by Alexey Kinyov on 27/04/2014. | |
// | |
// The MIT License (MIT) | |
// | |
// Copyright (c) 2013 Alexey Kinyov <[email protected]> | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal |
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; |
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
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
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
/* 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
# 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
# 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 |