This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Documentation | |
See also https://www.python-boilerplate.com/flask | |
""" | |
import os | |
import argparse | |
from flask import Flask, jsonify, send_file | |
from flask_cors import CORS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# src: https://powerfulpython.com/blog/making-unreliable-apis-reliable-with-python/ | |
# | |
# example usage: | |
# retry_on_auth_failure = RetryOnAuthFailure() | |
# retry_on_server_failure = RetryOnServerFailure(retries=5) | |
# | |
# @retry_on_server_failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import uuid | |
def guid_to_string(binary_guid: bytes) -> str: | |
return str(uuid.UUID(bytes_le=binary_guid)).lower() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"io" | |
"os" | |
) | |
func cp(dst, src string) error { | |
s, err := os.Open(src) | |
if err != nil { | |
return err | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# when you get the error "sasl.h is required" | |
xcrun --show-sdk-path | |
sudo ln -s <the_path_from_above_command>/usr/include /usr/include | |
# if you get "Operation not permitted," you probably need to disable SIP: | |
# reboot, hold down cmd-R, choose Utilities -> Terminal, type "csrutil disable," | |
# reboot, try the steps above again | |
pip install python-ldap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing import Process | |
def method_to_call(*args, **kwargs): | |
# do what you do | |
pass | |
def main(): | |
# | |
rows = ("job1", "job2") | |
procs = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
_ "expvar" | |
"fmt" | |
"net/http" | |
"os" | |
) | |
// use expvarmon to monitor: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"encoding/binary" | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"os" | |
) | |
func download() string { | |
client := &http.Client{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"fmt" | |
"log" | |
"os/exec" | |
"strings" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "sync" | |
var ( | |
r *repository | |
once sync.Once | |
) | |
func Repository() *repository { | |
if r == nil { | |
once.Do(func() { |