Skip to content

Instantly share code, notes, and snippets.

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

Blurjp

🏠
Working from home
View GitHub Profile
@mzupan
mzupan / lambda.py
Last active June 8, 2021 05:19
AWS Lambda job to backup RDS instances
import boto3
import datetime
def lambda_handler(event, context):
print("Connecting to RDS")
client = boto3.client('rds')
print("RDS snapshot backups stated at %s...\n" % datetime.datetime.now())
client.create_db_snapshot(
DBInstanceIdentifier='web-platform-slave',
@drgarcia1986
drgarcia1986 / __main__.py
Last active August 9, 2023 21:20
Example of OAuth2 autentication server with Client Credentials grant (using python-oauth2 and tornado)
# !/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Diego Garcia'
import tornado.web
import tornado.ioloop
import oauth2.tokengenerator
import oauth2.grant
import oauth2.store.redisdb
import oauth2.store.mongodb
anonymous
anonymous / gist:3518102
Created August 29, 2012 20:02
import functools
import json
import tornado.web
from tornado import httpclient
from datetime import datetime
class TestHandler(tornado.web.RequestHandler):
@jparise
jparise / gist:3428652
Created August 22, 2012 19:39
Tornado Graceful Shutdown
def shutdown(graceful=True):
"""Shut down the application.
If a graceful stop is requested, waits for all of the IO loop's
handlers to finish before shutting down the rest of the process.
We impose a 10 second timeout.
"""
ioloop = tornado.ioloop.IOLoop.instance()
def final_stop():
@boucher
boucher / gist:1750368
Created February 6, 2012 07:07 — forked from saikat/gist:1084146
Stripe sample checkout form
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Stripe Sample Form</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.min.js"></script>
<script type="text/javascript" src="https://js.stripe.com/v1/"></script>
<script type="text/javascript">
#Async Version with AsyncHTTPClient as url fetcher
from tornado import httpserver, ioloop
from tornado.httpclient import AsyncHTTPClient, HTTPClient
class httpProxy():
def __init__(self, iolp):
self.myserv = httpserver.HTTPServer(self.handle_request)
self.myserv.listen(8080)
self.httpclient = AsyncHTTPClient()
@joshmarshall
joshmarshall / tornado_temp_json_post.py
Created March 15, 2011 02:43
JSON to Arguments POST in Tornado
import tornado.ioloop
import tornado.web
import tornado.httpserver
import tornado.httputil
import json
class MainHandler(tornado.web.RequestHandler):
def post(self):
# do something useful
name = self.get_argument('foo')