Skip to content

Instantly share code, notes, and snippets.

Avatar
🏐
Focusing

ORES ORESoftware

🏐
Focusing
View GitHub Profile
@ORESoftware
ORESoftware / partitions.md
Created Jan 4, 2021
how to create table partitions programmatically (with a loop)
View partitions.md

Loop to create partitions does not work b/c a "CREATE TABLE" statement cannot be a prepared statement (laaaame).

do $$
declare
counter integer := 0;
begin
while counter <= 500 loop
    PREPARE create_table(int) AS
    CREATE TABLE mbk_auth_method_$1 PARTITION OF mbk_auth_method FOR VALUES WITH (modulus 500, remainder $1);
@ORESoftware
ORESoftware / partition.md
Created Jan 4, 2021
how to partition on user_id, but use modulus, in order to avoid too many partitions?
View partition.md

how do I create partition based on modulus of an id? something like this:

create table my_table(id bigint)
partition by value (modulus(id,1000));

create table my_table_0
partition of my_table
for values in (0);
@ORESoftware
ORESoftware / ovpn.conf
Created Dec 28, 2020
openvpn conf to route only certain traffic through VPN is not working :(
View ovpn.conf
client
nobind
dev tun
remote-cert-tls server
remote 35.209.20.300 1194 udp
<key>
-----BEGIN PRIVATE KEY-----
View promises-vs-obs.md

If I want to create an async queue with concurrency = 1, I use promises like so:

let p = Promise.resolve()

export const runTask(run, onerror){
    return p = p.then(run, onerror);
}
@ORESoftware
ORESoftware / ubuntu.md
Last active Jul 22, 2020
how to tell yourself when you need to merge with master / integration when you are working on a feature branch
View ubuntu.md

this will work on linux where notify-send is installed

throw this snippet into ~/.bashrc

((

    branch_name=dev
@ORESoftware
ORESoftware / query.json
Created Jul 6, 2020
es query for version 7
View query.json
{
"from": 0,
"query": {
"bool": {
"must": [
{
"simple_query_string": {
"query": "*"
}
},
@ORESoftware
ORESoftware / rjh.md
Last active May 27, 2020
rosanna joy hetrick
View rjh.md

love stanza 1

i express my love differently than some people i think pictures are nice but black and white text is cool too i think you make tasty snax you are a kickass persona

zan fux

@ORESoftware
ORESoftware / build-and-run.sh
Last active Apr 30, 2020
Build and run docker image/container
View build-and-run.sh
#!/usr/bin/env bash
# the nice thing about this script is it will remove
# existing containers in the background
# while the new image is being built
set -eo pipefail
cd "$(dirname "$BASH_SOURCE")"
(
@ORESoftware
ORESoftware / golang.Dockerfile
Last active May 11, 2020
How to create an optimized dockerfile for go services
View golang.Dockerfile
FROM golang:1.13 as base_img
ADD ./netrc /root/.netrc
ENV GO111MODULE='on'
ENV GOPROXY='direct'
ENV GOSUMDB='off'
RUN mkdir -p /tmp/go-api
View get-token-for-cloud-run.go
package common
import (
"cloud.google.com/go/compute/metadata"
"encoding/json"
"errors"
"fmt"
"github.com/acme/go-api/config/proj"
jwtgo "github.com/acme/jwt-go"
"golang.org/x/oauth2"