Find all indexes in a postgres table
select
t.relname as table_name,
i.relname as index_name,
array_to_string(array_agg(a.attname), ', ') as column_names
from
pg_class t,
pg_class i,
version: '2' | |
services: | |
# Start messaging broker | |
rabbitmq: | |
image: tutum/rabbitmq | |
dns: ["8.8.8.8"] | |
environment: | |
- "RABBITMQ_PASS=Phaish9ohbaidei6oole" |
# | |
# simpleBool.py | |
# | |
# Example of defining a boolean logic parser using | |
# the operatorGrammar helper method in pyparsing. | |
# | |
# In this example, parse actions associated with each | |
# operator expression will "compile" the expression | |
# into BoolXXX class instances, which can then | |
# later be evaluated for their boolean value. |
""" | |
Code to evaluate simple boolean logic in python | |
Taken from: http://stackoverflow.com/a/2472414/2353472 | |
Examples | |
>>> print nested_bool_eval('(True and False) or (True and False)') | |
False | |
>>> print nested_bool_eval('(True and False) or (True and (True or False))') | |
True | |
""" |
""" | |
An OrderedSet is a custom MutableSet that remembers its order, so that every | |
entry has an index that can be looked up. | |
Based on a recipe originally posted to ActiveState Recipes by Raymond Hettiger, | |
and released under the MIT license. | |
Rob Speer's changes are as follows: | |
- changed the content from a doubly-linked list to a regular Python list. | |
Seriously, who wants O(1) deletes but O(N) lookups by index? | |
- add() returns the index of the added item | |
- index() just returns the index of an item |
""" | |
An OrderedSet is a custom MutableSet that remembers its order, so that every | |
entry has an index that can be looked up. | |
Based on a recipe originally posted to ActiveState Recipes by Raymond Hettiger, | |
and released under the MIT license. | |
Rob Speer's changes are as follows: | |
- changed the content from a doubly-linked list to a regular Python list. | |
Seriously, who wants O(1) deletes but O(N) lookups by index? | |
- add() returns the index of the added item | |
- index() just returns the index of an item |
#!/usr/bin/env bash | |
#copy this in a folder from path ex: /usr/local/bin | |
#usage: docker-machine-rename default my-default | |
OLD_MACHINE_NAME=${1:-default}; | |
NEW_MACHINE_NAME=${2:-my-default-2}; | |
STORE_PATH=`docker-machine inspect $OLD_MACHINE_NAME | grep -m 1 StorePath | cut -d ':' -f 2 | cut -c 3- | rev | cut -c 3- | rev`; | |
mv "$STORE_PATH/machines/$OLD_MACHINE_NAME" "$STORE_PATH/machines/$NEW_MACHINE_NAME"; | |
cp "$STORE_PATH/machines/$NEW_MACHINE_NAME/config.json" "$STORE_PATH/machines/$NEW_MACHINE_NAME/config.json.bak" |
for i in $(docker-machine ls | grep digitalocean | awk '{print $1}'); do docker-machine ssh $i -- ls /swapfile || docker-machine ssh $i "fallocate -l 512M /swapfile && chmod 400 /swapfile && mkswap /swapfile" && docker-machine ssh $i "swapon /swapfile && echo '/swapfile none swap defaults 0 0' >> /etc/fstab" &>/dev/null; done |
mcn_name=MACHINE_NAME | |
apt_url='https://apt.dockerproject.org' | |
lsb_dist='ubuntu' | |
dist_version='trusty' | |
arch=$(docker-machine ssh ${mcn_name} dpkg --print-architecture) | |
repo='main' | |
docker-machine ssh ${mcn_name} "echo deb [arch=${arch}] ${apt_url}/repo ${lsb_dist}-${dist_version} ${repo} | sudo tee /etc/apt/sources.list.d/docker.list" | |
docker-machine ssh ${mcn_name} sudo apt-get update | |
docker-machine ssh ${mcn_name} sudo apt-get install -y docker-engine | |
docker-machine regenerate-certs ${mcn_name} |
Find all indexes in a postgres table
select
t.relname as table_name,
i.relname as index_name,
array_to_string(array_agg(a.attname), ', ') as column_names
from
pg_class t,
pg_class i,
# -*- coding: utf-8 -*- | |
import string | |
import random | |
import os | |
import re | |
from unicodedata import normalize | |
from datetime import datetime | |
import tempfile |