Skip to content

Instantly share code, notes, and snippets.

@indera
indera / dummy-web-server.py
Created April 15, 2024 14:27 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/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:
@indera
indera / README.md
Created April 15, 2024 14:22 — forked from nitaku/README.md
Minimal JSON HTTP server in python

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"}
@indera
indera / context_keys_as_struct_not_int_or_string.md
Created February 22, 2024 15:25 — forked from ww9/context_keys_as_struct_not_int_or_string.md
Why use empty struct{} and not int or string for context.Value() key types in #go

Use struct{} as keys for context.Value() in Go

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!

Creating a VM

  • 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.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
@indera
indera / gpg-import-and-export-instructions.md
Created May 10, 2018 20:23 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

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.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

"""
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