Make a package.json
file if you don't have one yet:
npm init
# just keep pressing enter.
# this will create the file `package.json`
package com.thinkminimo.step | |
class StepExample extends Step { | |
get("/") { "Hello World!" } | |
} |
@split | |
@login_required | |
def hello(): | |
return render_template('hello.html') | |
@hello.for_mimetype("application/json") | |
@login_required | |
def hello(): | |
return jsonify({"hello":"flask"}) |
/* Python(ish) string formatting: | |
* >>> format('{0}', ['zzz']) | |
* "zzz" | |
* >>> format('{x}', {x: 1}) | |
* "1" | |
*/ | |
var format = (function() { | |
var re = /\{([^}]+)\}/g; | |
return function(s, args) { | |
return s.replace(re, function(_, match){ return args[match]; }); |
(incomplete) | |
This question comes up often here. As a Windows systems engineer that transitioned into a "DevOps" systems engineer (this is a very contentious title, but "systems engineer that IS DevOps" doesn't have the same ring to it) over about a year, I'd like to start a living FAQ/guide on how to get into this game. | |
I'm also posting it on Gist [here](https://gist.github.com/carlosonunez/83312c12f884444620a495ef60882945). I presume that I'll update that one more frequently. | |
# Materials Required | |
* A healthy love for learning (DevOps is very young and is evolving almost daily) | |
* Patience with being the "dumb guy in the room" |
def bulk_upsert(model, fields, values, by): | |
""" | |
Return the tuple of (inserted, updated) ids | |
""" | |
result = (None, None) | |
if values: | |
stmt = """ | |
WITH data_set AS ( | |
INSERT INTO %s (%s) |
-- Capped collection of JSON blobs: (Use json for postgres 9.4 and below and jsonb for 9.5 and above) | |
CREATE SEQUENCE circle_index START WITH 1 INCREMENT BY 1 MINVALUE 1 MAXVALUE 5 CACHE 1 CYCLE ; | |
CREATE TABLE circle ( i integer PRIMARY KEY default nextval('circle_index') NOT NULL, tim timestamp DEFAULT current_timestamp NOT NULL, dat jsonb ); | |
INSERT INTO circle(i, dat) SELECT nextval('circle_index') as idx, '{"a":12345,"b":1}' AS val ON CONFLICT (i) DO UPDATE SET i=EXCLUDED.i, tim=DEFAULT, dat=EXCLUDED.dat; | |
INSERT INTO circle(i, dat) SELECT nextval('circle_index') as idx, '{"a":12345,"b":2}' AS val ON CONFLICT (i) DO UPDATE SET i=EXCLUDED.i, tim=DEFAULT, dat=EXCLUDED.dat; | |
INSERT INTO circle(i, dat) SELECT nextval('circle_index') as idx, '{"a":12345,"b":3}' AS val ON CONFLICT (i) DO UPDATE SET i=EXCLUDED.i, tim=DEFAULT, dat=EXCLUDED.dat; | |
INSERT INTO circle(i, dat) SELECT nextval('circle_index') as idx, '{"a":12345,"b":4}' AS val ON CONFLICT (i) DO UPDATE SET i=EXCLUDED.i, tim=DEFAULT, dat=EXCLUDED.dat; | |
INSER |
# -*- coding: utf-8 -*- | |
import os | |
from flask import Flask | |
from flask_heroku import Heroku | |
from flask_sslify import SSLify | |
from raven.contrib.flask import Sentry | |
from flask.ext.celery import Celery |
This article is now published on my website: Prefer Subshells for Context.
This Gist contains instructions to setup Ubuntu server with Nginx, uWSGI & Node.js with that can serve for any Python apps (Django for instance) and will allow it's automatized deployment.
The content is as follows:
01-ubuntu.md
– A basic Ubuntu server setup.02-nginx-uwsgi-nodejs.md
– Nginx, uWSGI and Node.js installation and setup.03-deployment.md
– A server setup for automatized deployment.04-mariadb.md
– Mariadb installation and setup.