Skip to content

Instantly share code, notes, and snippets.

View lockwooddev's full-sized avatar
🐍
*productive hissing*

Carlo Smouter lockwooddev

🐍
*productive hissing*
View GitHub Profile
@lockwooddev
lockwooddev / vault_django_wrappers.py
Created February 17, 2021 06:53
Vault Django wrappers
def upsert_secret(path, value):
settings.VAULT_CLIENT.secrets.kv.v2.create_or_update_secret(
path=path,
secret=value,
mount_point=settings.VAULT_MOUNTPOINT
)
def read_secret(path):
return settings.VAULT_CLIENT.secrets.kv.v2.read_secret_version(
@lockwooddev
lockwooddev / vault_settings.py
Created February 17, 2021 06:49
Vault Django settings
import hvac
VAULT_HOSTNAME = 'http://0.0.0.0'
VAULT_PORT = 8200
VAULT_TOKEN = 'xxx'
VAULT_CLIENT = hvac.Client(
url=f'{VAULT_HOSTNAME}:{VAULT_PORT}',
token=VAULT_TOKEN,
package job
import (
"io/ioutil"
"net/http"
)
func Job() (error) {
resp, err := http.Get("http://example.com/api/v1/examples")
if err != nil {
package job
type Job struct {
client ApiClient
}
func NewJob(client ApiClient) FetchJob {
return Job{client: client}
}
package yourpackage
import (
"fmt"
"log"
"net/http"
"net/http/httptest"
"net/url"
"testing"
"time"
package yourpackage
import (
"fmt"
"io/ioutil"
"net/http"
)
type ApiClient struct {
protocol string
package yourpackage
import (
"io/ioutil"
"net/http"
)
func GetData() ([]byte, error) {
resp, err := http.Get("http://example.com/api/v1/examples")
if err != nil {
package yourpackage
import "testing"
func setup(t *testing.T) {
t.Log("setup")
}
func teardown(t *testing.T) {
t.Log("teardown")
@lockwooddev
lockwooddev / drone_lib_1.yaml
Last active February 23, 2019 08:24
Drone 1.x library multi machine pipeline
kind: pipeline
name: python27
steps:
- name: test
image: python:2.7-alpine3.9
commands:
- pip install -e .
- pip install -e .[tests]
- pytest
// a & b & c are exactly the same
// a is shorthand written
// b is the long version
// c is the type infered version
var a: [Int] = [1, 2, 3, 4, 5]
var b: Array<Int> = [1, 2, 3, 4, 5]
var c: = [1, 2, 3, 4, 5]
var a: [String: Int] = ["a": 1, "b": 2]