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 | |
import base64 | |
import codecs | |
import json | |
import logging | |
import os | |
import sys | |
import uuid | |
from datetime import datetime |
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 sqlalchemy import create_engine | |
engine = create_engine('postgresql://user:[email protected]:5432/dbname') | |
engine.dialect.identifier_preparer.quote('table') | |
engine.dialect.identifier_preparer.quote_identifier('table') |
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 bash | |
# Use this script to test if a given TCP host/port are available | |
# This is script is download from | |
# https://github.com/vishnubob/wait-for-it/blob/9995b721327eac7a88f0dce314ea074d5169634f/wait-for-it.sh | |
# Modify by on 2019-1-7, with support for MACOS | |
# solution is found from: | |
# - https://github.com/vishnubob/wait-for-it/issues/13 | |
# - https://stackoverflow.com/questions/3504945/timeout-command-on-mac-os-x |
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
CREATE OR REPLACE FUNCTION create_city_partition(schema_name text, parent_table_name text, city_id int) | |
RETURNS text AS | |
$func$ | |
DECLARE | |
partition_table_name text; | |
BEGIN | |
partition_table_name := parent_table_name || '_' || city_id::text; | |
EXECUTE format(' | |
CREATE TABLE %I.%I PARTITION OF %I FOR VALUES IN (%L) | |
', schema_name, partition_table_name, parent_table_name, city_id); |
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
CREATE OR REPLACE FUNCTION jsonb_remove_keys( | |
jdata JSONB, | |
keys TEXT[] | |
) | |
RETURNS JSONB AS $$ | |
DECLARE | |
result JSONB; | |
len INT; | |
target TEXT; |
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
CREATE OR REPLACE FUNCTION jsonb_rename_keys( | |
jdata JSONB, | |
keys TEXT[] | |
) | |
RETURNS JSONB AS $$ | |
DECLARE | |
result JSONB; | |
len INT; | |
newkey TEXT; | |
oldkey TEXT; |
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
TARGET=/root/geoip | |
wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz -O $TARGET/tmp.tar.gz | |
tar -xvzf GeoLite2-City.tar.gz -C $TARGET --strip-components 1 | |
rm $TARGET/tmp.tar.gz |
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 ( | |
"fmt" | |
"math" | |
"strconv" | |
"strings" | |
) | |
func ParseFloat(str string) (float64, error) { |
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
env: | |
es6: true | |
node: true | |
parserOptions: | |
ecmaFeatures: | |
experimentalObjectRestSpread: true | |
generators: false | |
objectLiteralDuplicateProperties: false | |
ecmaVersion: 6 | |
sourceType: module |
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
Show hidden characters
{ | |
"rules": { | |
"strict": [ | |
"error", | |
"never" | |
], | |
"import/no-unresolved": [ | |
"error", | |
{ | |
"commonjs": true, |
NewerOlder