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 value
Typing 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/
""" | |
Detect groups having common values | |
Example: unpack.csv | |
PATID, HASH_1, HASH_2 | |
pat_1, a, b | |
pat_2, x | |
pat_3, , y | |
pat_4, a, c |
import pandas as pd | |
bad_px = ["12", "34"] | |
df = pd.DataFrame({ | |
"px_id": [1, 2, 3], | |
"px": ["12", "34", "56"], | |
"px_type": ["10", "10", "09"] | |
}) |
#!/usr/bin/env python | |
""" | |
Goal: search multiple LOINC codes in a reference file | |
""" | |
import argparse | |
import sys | |
import pandas as pd | |
# from contextlib import redirect_stdout | |
# import io | |
pd.set_option('display.width', 2500) |
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 |