A minimal HTTP server in python. It sends a JSON Hello World for GET requests, and echoes back JSON for POST requests.
python server.py 8009
Starting httpd on port 8009...
curl http://localhost:8009
{"received": "ok", "hello": "world"}
// See comments below. | |
// This code sample and justification brought to you by | |
// Isaac Z. Schlueter, aka isaacs | |
// standard style | |
var a = "ape", | |
b = "bat", | |
c = "cat", | |
d = "dog", |
A minimal HTTP server in python. It sends a JSON Hello World for GET requests, and echoes back JSON for POST requests.
python server.py 8009
Starting httpd on port 8009...
curl http://localhost:8009
{"received": "ok", "hello": "world"}
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
#!/bin/bash | |
cd ${HOME} | |
if [[ $unamestr == "Darwin" ]]; then | |
echo "installing... homebrew..." | |
if ! which brew > /dev/null; then | |
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
fi | |
echo "installing... git... go..." | |
brew install git go | |
fi |
This is a detailed runbook for setting up a production server on an Ubuntu 16.04 cloud VPS for automated deployment of static web content to be served by an NGINX web server and Node.js web application behind an NGINX reverse-proxy, both with SSL/TLS (https) support.
The steps are as follows:
# Fetch latest configuration: | |
*/5 * * * * cd /home/ubuntu/dogsheep-config && python3 git_pull_and_run_scripts.py . && sudo python3 ensure_symlinks.py files-to-symlink | |
# Goodreads | |
46 * * * * cd /home/ubuntu && /home/ubuntu/datasette-venv/bin/goodreads-to-sqlite books goodreads.db -a auth.json | |
1,11,21,31,41,51 * * * * /home/ubuntu/datasette-venv/bin/twitter-to-sqlite user-timeline /home/ubuntu/twitter.db -a /home/ubuntu/auth.json --since | |
2,7,12,17,22,27,32,37,42,47,52,57 * * * * run-one /home/ubuntu/datasette-venv/bin/twitter-to-sqlite home-timeline /home/ubuntu/timeline.db -a /home/ubuntu/auth.json --since | |
4,14,24,34,44,54 * * * * run-one /home/ubuntu/datasette-venv/bin/twitter-to-sqlite mentions-timeline /home/ubuntu/twitter.db -a /home/ubuntu/auth.json --since |
<script> | |
var toUrlParam = function(date) { | |
return date.toISOString().split("T")[0].replaceAll("-", "%2F"); | |
} | |
// https://stackoverflow.com/questions/563406/add-days-to-javascript-date | |
Date.prototype.addDays = function(days) { | |
var date = new Date(this.valueOf()); | |
date.setDate(date.getDate() + days); | |
return date; |
This project is a tiny compiler for a very simple language consisting of boolean expression.
The language has two constants: 1
for true and 0
for false, and 4 logic gates:
!
(not), &
(and), |
(or), and ^
(xor).
It can also use parentheses to manage priorities.
Here is its grammar in BNF format:
expr ::= "0" | "1"
{ | |
"Old Testament": { | |
"Genesis": { | |
"1": { | |
"1": "¹ When God began to create the heavens and the earth, ", | |
"2": "² the earth was complete chaos, and darkness covered the face of the deep, while a wind from God swept over the face of the waters. ", | |
"3": "³ Then God said, “Let there be light,” and there was light. ", | |
"4": "⁴ And God saw that the light was good, and God separated the light from the darkness. ", | |
"5": "⁵ God called the light Day, and the darkness he called Night. And there was evening and there was morning, the first day. \n", | |
"6": "⁶ And God said, “Let there be a dome in the midst of the waters, and let it separate the waters from the waters.” ", |
// Name: OpenAI Replace | |
// Description: Replace using Open AI's API | |
// Shortcut: cmd ctrl s | |
import "@johnlindquist/kit" | |
let { Configuration, OpenAIApi } = await npm("openai") | |
let configuration = new Configuration({ | |
apiKey: await env("OPENAI_API_KEY"), |