Random query recipes of JMESPath for the AWS CLI tools that I might have written or stumbled upon.
This file contains hidden or 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
DROP TABLE if exists temp; | |
CREATE TABLE temp ( | |
`table` varchar(250) DEFAULT NULL, | |
`colum` varchar(250) DEFAULT NULL, | |
`type` varchar(250) DEFAULT NULL, | |
`number_of_PK` tinyint(2) DEFAULT NULL, | |
`alter` varchar(250) DEFAULT NULL | |
) ENGINE=InnoDB DEFAULT CHARSET=latin1; |
This file contains hidden or 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
#!/bin/bash | |
# Created by RainoBoy97 | |
# https://gist.github.com/RainoBoy97/9a63286e7c034a2ff8da68631ccd0898 | |
mongo --quiet --eval ' | |
db = db.getSiblingDB("admin"); | |
var dbs = db.adminCommand("listDatabases").databases; | |
var totalCount = 0; |
This file contains hidden or 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
/* | |
* Have tried to generate SQL statements by first retrieving table column names | |
* from Redshift pg_* tables? | |
* | |
* You probably give up due to errors regarding invalid types. | |
* | |
* Here is my suggestion for accomplishing this. | |
* | |
* First, use the create table statement below to create a temp table with the col_names for our table of interest. | |
* We must create a table otherwise we get an error that listagg must be used on a user-created table. |
This file contains hidden or 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 boto | |
import sys, os | |
from boto.s3.key import Key | |
from boto.exception import S3ResponseError | |
DOWNLOAD_LOCATION_PATH = os.path.expanduser("~") + "/s3-backup/" | |
if not os.path.exists(DOWNLOAD_LOCATION_PATH): |
This file contains hidden or 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
<!doctype html> | |
<html ng-app="locator"> | |
<head> | |
<title>Vehicle locator</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script> | |
<script> | |
angular.module('locator',[]).controller('Ctrl', | |
function ($scope, $http) { | |
var q = {"query":"query routes{agency (id:\"HSL\") {routes {gtfsId, type, longName,shortName}}}","variables":null} |
by @rane
Tori.fi, a Finnish online marketplace based on blocket.se, has a category selection input that dynamically reveals sub-categories as user selects them.
It works like this:
You got your hands on some data that was leaked from a social network and you want to help the poor people.
Luckily you know a government service to automatically block a list of credit cards.
The service is a little old school though and you have to upload a CSV file in the exact format. The upload fails if the CSV file contains invalid data.
The CSV files should have two columns, Name and Credit Card. Also, it must be named after the following pattern:
YYYYMMDD
.csv.
This file contains hidden or 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 sys | |
import os | |
import locale | |
from collections import defaultdict | |
from socket import socket, AF_INET, SOCK_STREAM | |
from urllib.parse import urlparse | |
from contextlib import closing | |
from functools import wraps |
This file contains hidden or 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
-- based on http://stackoverflow.com/questions/21767780/how-to-find-size-of-database-schema-table-in-redshift | |
SELECT name AS table_name, ROUND((COUNT(*) / 1024.0),2) as "Size in Gigabytes" | |
FROM stv_blocklist | |
INNER JOIN | |
(SELECT DISTINCT id, name FROM stv_tbl_perm) names | |
ON names.id = stv_blocklist.tbl | |
GROUP BY name | |
ORDER BY "Size in Gigabytes" DESC |