Skip to content

Instantly share code, notes, and snippets.

S3_ACCESS_KEY_ID_GITLAB_BACKUP=<ACCESS_KEY>
S3_SECRET_ACCESS_KEY_GITLAB_BACKUP=<SECRET_KEY>
@RainJayTsai
RainJayTsai / convert_voc2createml.py
Created September 9, 2021 14:13 — forked from bezineb5/convert_voc2createml.py
Pascal VOC annotation to Apple createML annotations conversion tool
import argparse
import json
import logging
import pathlib
from xml.etree import ElementTree
log = logging.getLogger(__name__)
def _parse_arguments() -> argparse.Namespace:
@RainJayTsai
RainJayTsai / server.conf
Created June 7, 2021 03:04 — forked from laurenorsini/server.conf
OpenVPN configuration for /etc/openvpn/server.conf
local 192.168.2.0 # SWAP THIS NUMBER WITH YOUR RASPBERRY PI IP ADDRESS
dev tun
proto udp #Some people prefer to use tcp. Don't change it if you don't know.
port 1194
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/Server.crt # SWAP WITH YOUR CRT NAME
key /etc/openvpn/easy-rsa/keys/Server.key # SWAP WITH YOUR KEY NAME
dh /etc/openvpn/easy-rsa/keys/dh1024.pem # If you changed to 2048, change that here!
server 10.8.0.0 255.255.255.0
# server and remote endpoints
@RainJayTsai
RainJayTsai / Makefile
Created January 13, 2020 03:25 — forked from doubleyou/Makefile
grpc-gateway python example
GATEWAY_FLAGS := -I. -I/usr/local/include -I$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -I/usr/local/include
GRPC_FLAGS := --python_out=. --grpc_python_out=.
code:
python -m grpc_tools.protoc $(GRPC_FLAGS) $(GATEWAY_FLAGS) *.proto
gw:
protoc $(GATEWAY_FLAGS) \
--go_out=Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:. \
@RainJayTsai
RainJayTsai / gmmhmm.py
Created February 20, 2019 06:29 — forked from kastnerkyle/gmmhmm.py
GMM-HMM (Hidden markov model with Gaussian mixture emissions) implementation for speech recognition and other uses
# (C) Kyle Kastner, June 2014
# License: BSD 3 clause
import scipy.stats as st
import numpy as np
class gmmhmm:
#This class converted with modifications from https://code.google.com/p/hmm-speech-recognition/source/browse/Word.m
def __init__(self, n_states):
self.n_states = n_states
@RainJayTsai
RainJayTsai / server.py
Created January 4, 2019 08:10 — forked from scturtle/server.py
python socks5 proxy server with asyncio (async/await)
#!/usr/bin/env python3.5
import socket
import asyncio
from struct import pack, unpack
class Client(asyncio.Protocol):
def connection_made(self, transport):
self.transport = transport
self.server_transport = None
@RainJayTsai
RainJayTsai / http_echo_and_proxy_server.py
Created January 4, 2019 08:10 — forked from pomack/http_echo_and_proxy_server.py
A simple python HTTP server that either serves as a proxy or as an echo server. If working as an echo server, it outputs the headers and body into log output and to the client, which is useful when debugging a reverse proxy or caching server to see what is being sent. If working as a proxy server, it outputs what the request headers will be to t…
#!/usr/bin/env python
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import StringIO
import argparse
import logging
import os
import random
import sys
import urllib2
@RainJayTsai
RainJayTsai / async_worker_pool.py
Created August 22, 2018 06:40 — forked from thehesiod/async_worker_pool.py
Asynchronous Worker Pool, allows for limiting number of concurrent tasks
import asyncio
from datetime import datetime, timezone
import os
def utc_now():
# utcnow returns a naive datetime, so we have to set the timezone manually <sigh>
return datetime.utcnow().replace(tzinfo=timezone.utc)
class Terminator:
pass
@RainJayTsai
RainJayTsai / download-file.js
Created June 12, 2018 02:36 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@RainJayTsai
RainJayTsai / async-await.js
Created May 31, 2018 01:29 — forked from wesbos/async-await.js
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}