~/bin/mysql_table_to_big_query.sh bucket_name schema_name table_name ~/bin/mysql_schema_to_big_query.sh bucket_name [schema_name].
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 ruby | |
require 'rubygems' | |
require 'bundler/setup' | |
# TWO WAYS TO RUN THIS SCRIPT: | |
# ---------------------------- | |
# --->>> THE FIRST WAY> Run this script as executable: `./clone_gitlab_projects.rb` | |
# You need to make the script executable: `chmod +x gitlab_clone_all_repos.rb` | |
# ---- ANYTHING ABOVE THIS LINE IS ONLY REQUIRED IF YOU WANT TO RUN THE SCRIPT WITH SINGLE COMMAND `./clone_gitlab_projects.rb` ---- # |
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 EXTENSION IF NOT EXISTS "dblink"; | |
CREATE OR REPLACE FUNCTION batch_update(TEXT) RETURNS INTEGER LANGUAGE plpgsql AS $$ | |
DECLARE | |
batch_query TEXT := ''; | |
row_limit INTEGER := (REGEXP_MATCHES($1, 'LIMIT (\d+)', 'i'))[1]; | |
row_count INTEGER := 1; | |
row_offset INTEGER := 0; | |
total_rows INTEGER := 0; | |
connection_str TEXT := 'dbname=' || CURRENT_DATABASE(); |
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
source 'https://rubygems.org' | |
gemfiles = [ 'Gemfile1', 'Gemfile2' ] | |
gemfiles.each do |gemfile| | |
instance_eval File.read(gemfile) | |
end |
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
-- source: http://www.jamiebegin.com/base36-conversion-in-postgresql/ | |
CREATE OR REPLACE FUNCTION base36_encode(IN digits bigint, IN min_width int = 0) | |
RETURNS varchar AS $$ | |
DECLARE | |
chars char[]; | |
ret varchar; | |
val bigint; | |
BEGIN | |
chars := ARRAY['0','1','2','3','4','5','6','7','8','9' | |
,'A','B','C','D','E','F','G','H','I','J','K','L','M' |