Skip to content

Instantly share code, notes, and snippets.

View BastinRobin's full-sized avatar
🏠
Working from home

Bastin Robin BastinRobin

🏠
Working from home
View GitHub Profile
@BastinRobin
BastinRobin / example.com
Created October 29, 2015 15:34 — forked from mignev/example.com
Django deployment with Nginx and Tornado Web
upstream tornadoFrontends {
server 127.0.0.1:8000;
server 127.0.0.1:8001;
server 127.0.0.1:8002;
server 127.0.0.1:8003;
}
server {
listen 80;
@BastinRobin
BastinRobin / supervisord-example.conf
Created October 28, 2015 18:03
Example configuration file for supervisord.conf
[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file
[supervisord]
logfile=/var/log/supervisord/supervisord.log ; supervisord log file
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=error ; info, debug, warn, trace
pidfile=/var/run/supervisord.pid ; pidfile location
nodaemon=false ; run supervisord as a daemon
# To run this command:
# curl https://gist.githubusercontent.com/tianhuil/0aa9b265f55413dc7198/raw > setup_digitalocean.sh
# . setup_digitalocean.sh
# Update sudo apt-get
sudo apt-get update
# Installing scientific Python
sudo apt-get -y install --fix-missing build-essential python-dev python-numpy python-setuptools python-scipy libatlas-dev
sudo apt-get -y install --fix-missing build-essential python-sklearn
import torndb
mysql_settings = {
'host': 'localhost:3306',
'user': 'user',
'password': 'password',
'database': 'database',
'time_zone': '-8:00',
'charset': 'utf8'
import json
import tornado.web
class JsonHandler(BaseHandler):
"""Request handler where requests and responses speak JSON."""
def prepare(self):
# Incorporate request JSON into arguments dictionary.
if self.request.body:
try:
<?php
// This creates a date string in the format YYYY-WNN, which is
// a four digit year followed by a hyphen and letter W then the
// two digit week number
$strtotime = date("o-\WW");
// The $start timestamp contains the timestamp at 0:00 on the
// Monday at the beginning of the week
$start = strtotime($strtotime);
// Routes.php
Route::get('upload', function()
{
return View::make('upload-form');
});
Route::post('upload', function()
{
// Get and move uploaded file.
/*
Taken and cribbed from blog.datalicious.com/free-download-all-australian-postcodes-geocod
May contain errors where latitude and longitude are off. Use at own non-validated risk.
*/
SET NAMES utf8;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP TABLE IF EXISTS postcodes_geo;