Instantly share code, notes, and snippets.

View .vimrc
set encoding=utf-8
set nocompatible
set autoindent
set backspace=indent,eol,start
set nu
filetype off
call plug#begin('~/.vim/plugged')
Plug 'vim-syntastic/syntastic'
View postgres-cheatsheet.md

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
View hadoop_install.sh
# Ubuntu 16.04
# Configuração inicial
apt-get update
apt-get install ssh rsync
apt-get install default-jdk
# Download Hadoop
wget http://ftp.unicamp.br/pub/apache/hadoop/common/hadoop-3.1.0/hadoop-3.1.0.tar.gz
View Dockerfile
FROM ruby:2.4.2-alpine
ADD Gemfile /app/
ADD Gemfile.lock /app/
RUN apk add --no-cache bash gawk sed grep bc coreutils vim
RUN apk add --update ruby-dev build-base git \
libxml2-dev libxslt-dev pcre-dev libffi-dev \
postgresql-dev
RUN gem install bundler --no-ri --no-rdoc && \
View sublime_config.json
{
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"color_inactive_tabs": false,
"color_scheme": "Packages/Python 3/Gloom.tmTheme",
"copy_with_empty_selection": true,
"ensure_newline_at_eof_on_save": true,
"font_size": 13,
"ignored_packages":
[
View .matplotlib
backend: TkAgg
View rails-jsonb-queries.rb
"http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query"
"http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails"
# payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
# data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
View aws_setup.txt
AWS ECS setup
1. Create VPC
VPC Dashboard > Start VPC Wizard > VPC with a Single Public Subnet
- CIRD: 10.0.0.0/16
- VPC name: <project>-<environment>
- Public Subnet: 10.0.0.0/24
- Availiability Zone: us-east-1a
View databse_sample.yml
default: &default
adapter: postgresql
encoding: unicode
pool: 5
development:
<<: *default
database: myapp_api_development
host: db
View docker-compose.yml
version: '2'
services:
db:
image: gordlea/postgis:9.5
environment:
- POSTGRES_DB=myapp_api_development
- POSTGRES_USER=root
dbtest:
image: gordlea/postgis:9.5