Skip to content

Instantly share code, notes, and snippets.

@josetapadas
josetapadas / database.yml
Last active January 12, 2017 18:49
Sample dockerized database.yml
default: &default
adapter: postgresql
pool: 5
timeout: 5000
host: database
username: <%= ENV['POSTGRES_USER'] %>
password: <%= ENV['POSTGRES_PASSWORD'] %>
development:
<<: *default
@josetapadas
josetapadas / .env
Last active January 12, 2017 18:50
Sample .env file
POSTGRES_USER=postgres
POSTGRES_PASSWORD=password4postgres
@josetapadas
josetapadas / docker-compose.yml
Last active January 12, 2017 18:54
Rails and PostgreSQL simple docker-compose.yml
version: '2'
services:
database:
image: postgres
volumes:
- ./data/pgdata:/pgdata
env_file:
- '.env'
web:
links:
@josetapadas
josetapadas / Dockerfile
Last active January 6, 2017 18:11
Sample Dockerfile
FROM ruby:2.3-slim
RUN apt-get update \
&& apt-get install -qq -y --no-install-recommends \
build-essential \
nodejs \
libpq-dev \
git \
tzdata \
libxml2-dev \
@josetapadas
josetapadas / arrowfunctionex1.js
Last active August 18, 2016 16:41
Map arrow function
[ [1, 2], [3, 4] ].map( ([a, b]) => a + b );
module CruisesCore
module Models
module Article
module Elasticsearch
extend ActiveSupport::Concern
included do
include ::Elasticsearch::Model
index_name "cruises-#{Rails.env}"
@josetapadas
josetapadas / .json
Created September 3, 2015 18:26
Sample reply from CruiseLine.com
{
"{": {
"\"request\":": {},
"{": {
"\"type\":\"ship\",": {},
"\"slug\":\"norwegian-breakaway\",": {},
"\"api\":\"api\",": {},
"\"key\":\"abc123\"": {},
"\"object\":": {},
"{": {
@josetapadas
josetapadas / gist:780d6104904d3df7e4ad
Created September 10, 2014 16:40
Simple responsive tooltip system
#seller-name {
color: #34495e;
&:hover {
cursor: help;
text-decoration: none;
}
/* pseudo element to put after our link */
&:after {
@josetapadas
josetapadas / gist:3b70c20405a50bf5df1c
Created July 30, 2014 10:06
Insert or update on PostgresSQL
begin;
savepoint insert_save_point;
insert into params values('email', 'lol@lol.pt');
rollback to insert_save_point;
update params set value = 'lol@lol.pt' where name = 'email';
commit;
@josetapadas
josetapadas / gist:cb8047c2044166ef8363
Created July 25, 2014 17:00
Load a script asynchronously for a responsive site (e.g, jQuery mobile)
var mediaQueryListElement = window.matchMedia("all and (max-width: 990px)");
function loadjQueryMobile() {
// listner to this callback very carefully, we should load this script only once
mediaQueryListElement.removeListener(loadjQueryMobile);
var helper_script = $('#holder-element').data('helper');
if (helper_script) {
$.getScript(helper_script)