Skip to content

Instantly share code, notes, and snippets.

#
# models.py
#
class Claim(models.Model):
week_commencing = models.DateField()
tech = models.ForeignKey(
settings.AUTH_USER_MODEL,
#!/bin/sh
# iptables script generated -
# http://www.mista.nu/iptables
IPT="/sbin/iptables"
# Flush old rules, old custom tables
$IPT --flush
$IPT --delete-chain
# move this file to sites-available/
server {
listen 443 ssl;
client_max_body_size 32M;
# set the correct host(s) for your site
server_name example.com;
keepalive_timeout 5;
@vulcan25
vulcan25 / app.py
Last active December 30, 2018 01:23
Mongodb counter increment.
from flask import Flask,Response
app = Flask(__name__)
@app.route('/')
def hello():
return "Hello World!"
@app.route('/<int:recipe_id>',methods=['GET'])
def home(recipe_id):
@vulcan25
vulcan25 / Dockerfile
Last active December 28, 2020 21:51
Flask upload with dropzone.
from python:alpine
RUN pip install -U pip && pip install flask
WORKDIR /code
COPY ./app.py /code
COPY ./index.html /code
CMD flask run -h 0.0.0.0
@vulcan25
vulcan25 / run.py
Last active January 11, 2023 13:52
psycopg2 flask implementation with connection pooling support
from flask import Flask, g, jsonify
import werkzeug, os
from werkzeug.utils import secure_filename
import psycopg2
from psycopg2 import pool
def get_db():
print ('GETTING CONN')
if 'db' not in g:
@vulcan25
vulcan25 / app.py
Last active December 27, 2019 15:17
Flask: Example of periodically refreshing a page, pending rq job completion.
from flask import Flask, redirect, url_for, render_template_string
from time import sleep
from rq import Queue
from rq.job import Job
from redis import Redis
r = Redis(host='redisserver')
q = Queue(connection=r)
@vulcan25
vulcan25 / README.md
Last active November 29, 2022 14:11
Flask + sqlalchemy declarative base example

TODO: write readme

@vulcan25
vulcan25 / app.py
Last active May 4, 2020 09:39 — forked from MortallaSane/app.py
Flask tiny project
from flask import Flask, render_template
# Because gists don't support subfolders, we pass the `template_folder` argument
# to `Flask` to set it as the current directory. If you wish you can create a
# subfolder called `templates/` in the project, moving the HTML files there, then
# remove that argument from the next line.
app = Flask(__name__, template_folder='.')
@app.route("/")
def index():
@vulcan25
vulcan25 / tcpdump.md
Created January 22, 2020 20:21
tcpdump cheatsheet

TCPDUMP

OPTIONS

-i any : Listen on all interfaces just to see if you’re seeing any traffic. -i eth0 : Listen on the eth0 interface. -D : Show the list of available interfaces -n : Don’t resolve hostnames. -nn : Don’t resolve hostnames or port names. -q : Be less verbose (more quiet) with your output.