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"}
| #!/usr/bin/env python | |
| """ | |
| Very simple HTTP server in python (Updated for Python 3.7) | |
| Usage: | |
| ./dummy-web-server.py -h | |
| ./dummy-web-server.py -l localhost -p 8000 | |
| Send a GET request: |
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"}
In the other file of this gist I detail why we should use struct{} as context.Value() keys and not int or string. Open gist to see main.go but the TLDR is:
type key struct{}
ctx = context.WithValue(ctx, key{}, "my value") // Set value
myValue, ok := ctx.Value(key{}).(string) // Get valueTyping vagrant from the command line will display a list of all available commands.
Be sure that you are in the same directory as the Vagrantfile when running these commands!
vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.
cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/
| defmodule App.SignupChannel do | |
| use App.Web, :channel | |
| alias App.User | |
| import Ecto.Changeset | |
| require Logger | |
| def join("signup", _params, socket) do | |
| send self(), {:sign_up, _params} | |
| {:ok, socket} | |
| end |
These commands generate and use private keys in unencrypted binary (not Base64 “PEM”) PKCS#8 format. The PKCS#8 format is used here because it is the most interoperable format when dealing with software that isn't based on OpenSSL.
OpenSSL has a variety of commands that can be used to operate on private
key files, some of which are specific to RSA (e.g. openssl rsa and
openssl genrsa) or which have other limitations. Here we always use
Original link: http://www.concentric.net/~Ttwang/tech/inthash.htm
Taken from: http://web.archive.org/web/20071223173210/http://www.concentric.net/~Ttwang/tech/inthash.htm
Reformatted using pandoc
Thomas Wang, Jan 1997
last update Mar 2007
| package main | |
| import ( | |
| "errors" | |
| "fmt" | |
| "io" | |
| "time" | |
| ) | |
| type Point struct { |
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """ | |
| This code resolves the problem described in | |
| http://xahlee.info/perl-python/python_construct_tree_from_edge.html | |
| """ | |
| import collections |