Skip to content

Instantly share code, notes, and snippets.

View Miserlou's full-sized avatar

Rich Jones Miserlou

View GitHub Profile
@Miserlou
Miserlou / s3sqlite_settings.py
Created October 17, 2017 21:57
s3sqlite_settings.py
DATABASES = {
'default': {
'ENGINE': 'zappa_django_utils.db.backends.s3sqlite',
'NAME': 'sqlite.db',
'BUCKET': 'your-db-bucket'
}
}
@Miserlou
Miserlou / shell_invoke.sh
Created August 31, 2017 20:00
Execute Lambda Shell Commands With Zappa
zappa invoke --raw 'import subprocess; print subprocess.check_output("ls");'
class User(object):
name = None
age = None
def print_name(self):
print "Hi, I'm " + self.name + "!"
new_user = User()
new_user.name = "Jeff"
new_user.age = 19
@Miserlou
Miserlou / nodb_example.py
Created April 10, 2017 14:05
nodb_example.py
from nodb import NoDB
nodb = NoDB()
nodb.bucket = "my-s3-bucket"
nodb.index = "name"
# Save an object!
user = {"name": "Jeff", "age": 19}
nodb.save(user) # True
@Miserlou
Miserlou / run.py
Created March 29, 2017 17:35
run.py
from zappa.async import run
run(your_function, args, kwargs) # Using Lambda
run(your_function, args, kwargs, service='sns') # Using SNS
@Miserlou
Miserlou / async_zappa_settings.js
Last active March 29, 2017 17:34
async_zappa_settings.js
{
"dev": {
..
"async_source": "sns", // Source of async tasks. Defaults to "lambda"
"async_resources": true, // Create the SNS topic to use. Defaults to true.
..
}
}
@Miserlou
Miserlou / task_sns.py
Created March 29, 2017 17:33
task_sns.py
from zappa.async import task_sns
@task_sns
@Miserlou
Miserlou / zappa_task_example.py
Created March 29, 2017 17:09
zappa_task_example.py
import flask
from zappa.async import task
@task
def make_pie():
""" This takes a long time! """
ingredients = get_ingredients()
pie = bake(ingredients)
deliver(pie)
@Miserlou
Miserlou / drift.js
Created March 27, 2017 19:28
Drift JS
<!-- Start of Async Drift Code -->
<script>
var YOUR_CODE = 'BLAH_BLAH_BLAH';
!function() {
var t;
if (t = window.driftt = window.drift = window.driftt || [], !t.init) return t.invoked ? void (window.console && console.error && console.error("Drift snippet included twice.")) : (t.invoked = !0,
t.methods = [ "identify", "config", "track", "reset", "debug", "show", "ping", "page", "hide", "off", "on" ],
t.factory = function(e) {
return function() {
var n;
@Miserlou
Miserlou / semantic-2.2.9.html
Created March 4, 2017 00:46
Semantic UI 2.2.9 CDN Starter
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>Semantic UI CDN</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.9/semantic.min.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.9/semantic.min.js"></script>
</head>
<body>