Skip to content

Instantly share code, notes, and snippets.

View mallow111's full-sized avatar

Min Wang mallow111

View GitHub Profile
@navid-taheri
navid-taheri / awscli-ubuntu-16.04
Last active February 24, 2020 21:46
How to install awscli on ubuntu 16.04
docker run -it ubuntu:16.04
apt-get -y update
apt-get -y upgrade
apt-get install -y python3-pip
pip3 install awscli
aws --version
aws-cli/1.14.48 Python/3.5.2 Linux/4.13.0-36-generic botocore/1.9.1
@superbrothers
superbrothers / main.go
Created September 8, 2016 02:42
http request with context in Go
package main
import (
"context"
"fmt"
"log"
"net/http"
"time"
)
@ammario
ammario / goth
Created September 2, 2016 16:27
golang test coverage html
#!/bin/bash
go test -coverprofile=coverage.out
go tool cover -html=coverage.out
@alyssaq
alyssaq / main.go
Last active February 13, 2024 08:01
GET and POST golang API
/*
* Sample API with GET and POST endpoint.
* POST data is converted to string and saved in internal memory.
* GET endpoint returns all strings in an array.
*/
package main
import (
"encoding/json"
"flag"
#!/bin/bash
echo "Please use stackme.sh from https://github.com/rm-you/devstack_deploy instead! Always the latest:"
echo "bash <(curl -sL bit.do/devstack)"
exit
BARBICAN_PATCH=""
NEUTRON_LBAAS_PATCH=""
OCTAVIA_PATCH="refs/changes/30/278830/6"
#Create LB
http://localhost:9876/v1/loadbalancers
{
"name": "loadbalancer1",
"description": "simple lb",
"vip": {"subnet_id": "ac7d27ae-7ace-459f-ae11-a4568abd227a"}
}
#Create LIstener
http://localhost:9876/v1/loadbalancers/0c59f9c3-13e2-47ad-bf7e-fd533c51e918/listeners
@odyniec
odyniec / test_temp_directory.py
Last active January 30, 2023 11:12
An example Python unittest test case that creates a temporary directory before a test is run and removes it when it's done.
import shutil, tempfile
from os import path
import unittest
class TestExample(unittest.TestCase):
def setUp(self):
# Create a temporary directory
self.test_dir = tempfile.mkdtemp()
def tearDown(self):
@prograhammer
prograhammer / git-cheat-sheet.md
Last active March 14, 2023 17:44
Git cheat sheet for some useful Git commands and command scenarios.
@mangecoeur
mangecoeur / concurrent.futures-intro.md
Last active January 9, 2024 16:04
Easy parallel python with concurrent.futures

Easy parallel python with concurrent.futures

As of version 3.3, python includes the very promising concurrent.futures module, with elegant context managers for running tasks concurrently. Thanks to the simple and consistent interface you can use both threads and processes with minimal effort.

For most CPU bound tasks - anything that is heavy number crunching - you want your program to use all the CPUs in your PC. The simplest way to get a CPU bound task to run in parallel is to use the ProcessPoolExecutor, which will create enough sub-processes to keep all your CPUs busy.

We use the context manager thusly:

with concurrent.futures.ProcessPoolExecutor() as executor:
@paulsmith
paulsmith / echo.go
Created January 12, 2011 06:09
A simple echo server testing a few interesting Go language features, goroutines and channels.
// $ 6g echo.go && 6l -o echo echo.6
// $ ./echo
//
// ~ in another terminal ~
//
// $ nc localhost 3540
package main
import (