Skip to content

Instantly share code, notes, and snippets.

View lmmendes's full-sized avatar
🏠

Luís Mendes lmmendes

🏠
View GitHub Profile
@lmmendes
lmmendes / Dockerfile
Last active February 13, 2017 23:43
bitbucket pipelines + mysql + rails + cache
FROM ruby:2.4.0
MAINTAINER liquid team <[email protected]>
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -q &&\
apt-get upgrade -y -q &&\
apt-get install -y curl software-properties-common curl &&\
curl -sL https://deb.nodesource.com/setup_7.x | bash &&\
apt-get -y install nodejs mysql-server mysql-client libmysqlclient-dev --no-install-recommends
@lmmendes
lmmendes / tag_logger.rb
Last active February 8, 2017 15:23
Rails tagged logger with user id
#
# This Tag logger adds users that to the request example:
# 2017-02-08 15:07:13.227 [fyi] [ce3cfbef-792d-4606-b8d4-927cd526fe7f] Completed 200 OK in 4355ms
module WardenTaggedLogger
def self.extract_user_id_from_request(req)
session_key = Rails.application.config.session_options[:key]
session_data = req.cookie_jar.encrypted[session_key]
if session_data.present? && session_data.has_key?('warden.user.user.key')
session_data['warden.user.user.key'][0][0]
@lmmendes
lmmendes / AWS CLI.md
Last active February 8, 2017 11:36
AWS CLI commands

List instances by: name, id and type

aws --output table  ec2 describe-instances --query 'Reservations[].Instances[].[Tags[?Key==`Name`] | [0].Value,InstanceId,InstanceType]'

List users

@lmmendes
lmmendes / questions.md
Last active December 13, 2016 14:44
Spree Commerce Structuring a Site

Structuring a site using Spree

For context I'm new to spree and trying to build a site on to of it.

Right now I'm not sure on how to structure the site, I read some articles from resolve.digital a Spree Shop regarding on "How to Organize Products with Spree Commerce" (Part One, Part Two) but it didn't offer any advice on how to organize the taxonomies or Taxons that support the products.

Navigation Menu

Here is an example from a site that they did (http://au.unitedcellars.com/), how should I organize the information to represent this menu format?

@lmmendes
lmmendes / Rancher.md
Created December 9, 2016 13:25
Running Rancher locally (with two hosts) using MacOS Docker and VirtualBox

Rancher

Rancher is an open source project that provides a complete platform for operating Docker in production. It provides infrastructure services such as multi-host networking, global and local load balancing, and volume snapshots.

This documentation describes how to run Rancher localy for development and evaluation propuses.

I'm using Docker for OSX (native) but even for this to work you will need to install VirtualBox.

Launching Management Rancher Server

@lmmendes
lmmendes / active_record_finders.rb
Created November 4, 2016 12:55
ActiveRecord patch for #last/#first on collection using UUID (PostgreSQL)
require 'active_record'
message = '[ActiveRecord::FinderMethods] Applying patch for #last/#first on collection using UUID'
# rubocop:disable Rails/Output
puts message
# rubocop:enable Rails/Output
# Please read this
# https://github.com/rails/rails/blob/24d82063bcc86a86eb8c8717d74c0c7340e209e6/activerecord/lib/active_record/relation/finder_methods.rb#L479
@lmmendes
lmmendes / tools
Created September 12, 2016 12:45
Development Tools
### Gif tools
http://www.cockos.com/licecap/
@lmmendes
lmmendes / haproxy_letsencrypt.md
Last active August 31, 2024 23:22
# HAProxy and Let's Encrypt

HAProxy and Let's Encrypt

HAProxy is a open-source TCP/HTTP load-balancing proxy server supporting native SSL, keep-alive, compression CLI, and other modern features.

Let’s Encrypt is a free, automated, and open certificate authority (CA), run for the public’s benefit. Let’s Encrypt is a service provided by the Internet Security Research Group (ISRG).

Concept

@lmmendes
lmmendes / elasticache_dump_to_rdb.md
Last active May 28, 2021 07:36
Save Amazon ElastiCache Redis to file dump.rdb

Instructions to DUMP localy a Elasticache Redis database

Connect to Redis CLI

$ redis-cli

Enable the current redis as a slave for the master node

@lmmendes
lmmendes / make_y_branch_into_master.sh
Created February 23, 2016 12:41
Change the current branch to master in git
git checkout better_branch
git merge --strategy=ours master # keep the content of this branch, but record a merge
git checkout master
git merge better_branch # fast-forward master up to the merge