Skip to content

Instantly share code, notes, and snippets.

@karlarao
karlarao / getBigQuerySchema.sh
Created January 26, 2021 03:17 — forked from vicenteg/getBigQuerySchema.sh
Shell script to extract the schema from an existing BigQuery table and output the schema in a format suitable for use with `bq mk`.
#!/bin/bash
if [ -z $1 ]; then
echo "Provide a BQ table spec, ideally fully qualified."
exit 1
fi
if $(echo "" | jq .); then
bq --format json show $1 | jq -j '[.schema.fields[] | .name + ":" + .type] | join(",")'
#!/bin/bash
if [ -z "${PROJECT}" -o -z "${DATASET}" ]; then
echo "Please set \$PROJECT and \$DATASET."
exit 1
fi
IFS='' read -d '' Q <<EOF
#standardSQL
/*
#!/bin/bash
if [ -z "${PROJECT}" -o -z "${DATASET}" ]; then
echo "Please set \$PROJECT and \$DATASET."
exit 1
fi
IFS='' read -d '' Q <<EOF
#standardSQL
/*
#!/bin/bash
if [ -z "${PROJECT}" -o -z "${DATASET}" ]; then
echo "Please set \$PROJECT and \$DATASET."
exit 1
fi
IFS='' read -d '' Q <<EOF
#standardSQL
/*
@karlarao
karlarao / redis_cheatsheet.bash
Created August 1, 2019 20:57 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@karlarao
karlarao / benchmark-commands.md
Created May 17, 2019 06:55 — forked from ueokande/benchmark-commands.md
Kafka Benchmark Commands

Benchmark commands

Producer

Setup

bin/kafka-topics.sh \
  --zookeeper zookeeper.example.com:2181 \
  --create \
@karlarao
karlarao / s3update.py
Created May 2, 2019 00:40 — forked from nateware/s3update.py
Check local files vs what's on S3, and upload any that have changed.
#!/usr/bin/env python
# Compare a file on S3 to see if we have the latest version
# If not, upload it and invalidate CloudFront
import fnmatch
import os
import boto
import pprint
import re
@karlarao
karlarao / flask-flaskrestful-nginx-setup.sh
Created April 27, 2019 21:02 — forked from lawrencefoley/flask-flaskrestful-nginx-setup.sh
Script to setup Python 3, Flask-Restful, and Nginx
#!/bin/bash
sudo apt-get update
sudo apt-get install -y python3 python3-pip nginx python3-setuptools git
sudo pip3 install uwsgi virtualenv Flask flask-restful gunicorn
sudo mkdir -p /var/www/
cd /var/www/
echo "<h1>Hello world!</h1>" | tee index.html
@karlarao
karlarao / export_db_structure.sh
Created January 31, 2019 08:27 — forked from dantheman213/export_db_structure.sh
Batch backup and export your Postgres or PostgreSQL table schemas and stored functions or procedures into individual *.sql files --the easy way!
#!/bin/sh
# AUTHOR
# DANIEL E. GILLESPIE (2016)
# https://github.com/dantheman213
# DESCRIPTION
# Export your app's table schemas and stored functions from a PostgreSQL
# database into individual *.sql files for easy management and source control.
@karlarao
karlarao / postgres cheatsheet.md
Created January 31, 2019 08:27 — forked from apolloclark/postgres cheatsheet.md
postgres cheatsheet

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL