I've been having trouble with serving a Flask app via uWSGI and nginx, so I thought I'd put together some of the basics to help out others.
- Flask is managed by
uWSGI. uWSGItalks tonginx.
| #!/usr/bin/env python | |
| import os | |
| import random | |
| import time | |
| import platform | |
| snowflakes = {} | |
| try: | |
| # Windows Support |
| #!/usr/bin/python2 | |
| # GIBE MONY PLOX. -mplewis | |
| import random | |
| import sys | |
| from time import sleep | |
| from math import log | |
| numHue = 100 # LOL THIS DOESN'T MATTER |
| #!/usr/bin/env python2 | |
| # this script grabs all youtube links in a 4chan thread and opens them in your browser. | |
| # the regex is probably pretty shitty but it seems to work | |
| # i dunno if it handles more than one youtube link in a post because i'm lazy | |
| # usage: | |
| # python chanTube.py [threadUrl] | |
| # example: | |
| # python chanTube.py http://boards.4chan.org/v/res/168482467 |
| // This program is an example of how to run a command such as | |
| // ps aux | grep root | grep sbin | |
| // using C and Unix. | |
| #include <stdlib.h> | |
| #include <unistd.h> | |
| int pid; | |
| int pipe1[2]; | |
| int pipe2[2]; |
| import Image | |
| from collections import Counter | |
| IMAGE_FILE = 'testris_fb.png' | |
| def get_tetris_vert_bounds_from_img(img): | |
| '''Returns the left and right crop boundaries of an image of the player's Tetris Battle board.''' | |
| img_width, img_height = img.size | |
| left_tri_black_coords = [] |
| import os, time, subprocess | |
| def run_command_silently(command): | |
| with open(os.devnull, 'wb') as devnull: | |
| subprocess.check_call(command.split(' '), stdout=devnull, stderr=subprocess.STDOUT) | |
| run_command_silently('ping -c 1 255.255.255.255') | |
| time.sleep(0.5) | |
| arp_entries = subprocess.check_output(('arp','-na')).splitlines() | |
| all_ip_and_macs = [] |
| #!/usr/bin/python | |
| import httplib2 | |
| import json | |
| from apiclient.discovery import build | |
| from oauth2client.file import Storage | |
| from oauth2client.client import AccessTokenRefreshError | |
| from oauth2client.client import OAuth2WebServerFlow | |
| from oauth2client.tools import run | |
| from datetime import datetime |
| #!/usr/bin/env python | |
| import os | |
| import sys | |
| # print_compact_dir recursively prints the contents of the directory with indentation and without stuttering. | |
| # If the only contents of a given directory are another single directory, that single directory is concatenated instead of indented on the next line. | |
| def print_compact_dir(root, route, level, spacing=4): | |
| dir_path = os.path.join(root, route) | |
| contents = os.listdir(dir_path) |
| var http = require('http'); | |
| var SOCKET_PATH = '/var/run/docker.sock'; | |
| var dockerConn = { | |
| get: function(path, callback) { | |
| var options = { | |
| socketPath: SOCKET_PATH, |