Skip to content

Instantly share code, notes, and snippets.

View ferrao's full-sized avatar
🎯
Focusing

Rui Ferrão ferrao

🎯
Focusing
View GitHub Profile
@ferrao
ferrao / agnoster-mod.js
Last active July 12, 2017 08:39
oh-my-zsh agnoster theme modification for multiline support
PROMPT='%{%f%b%k%}$(build_prompt)%{$reset_color%}
➜ '
@ferrao
ferrao / EntityManagerHelper.java
Last active October 9, 2017 21:27
JPA EntityManager util class using thread local to assure thread-safety
public class EntityManagerHelper {
private static final EntityManagerFactory emf;
private static final ThreadLocal<EntityManager> threadLocal;
static {
emf = Persistence.createEntityManagerFactory("BookStoreUnit");
threadLocal = new ThreadLocal<EntityManager>();
}
@ferrao
ferrao / highlight.js
Created October 4, 2018 15:24
React DraftJS WYSIWYG prism syntax highlight
const convertContent = content => {
const blockMap = content.getBlockMap();
let newBlockMap = Map();
blockMap.valueSeq().forEach(block => {
if (block.getType() === 'code') {
const data = block.getData().merge({ language: 'javascript' });
const newBlock = block.merge({ type: 'code-block', data });
newBlockMap = newBlockMap.set(block.key, newBlock);
}
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@ferrao
ferrao / asciidoctor-pdf-theme.yaml
Created January 19, 2019 22:07
Asciidoctor pdf theme to use as base for corporate theme
title_page:
logo_image: image:logo.png[]
page:
layout: portrait
margin: [3.2cm, 2cm, 2.2cm, 2cm]
size: A4
base:
font_color: #333333
font_family: Helvetica
font_size: 12
@ferrao
ferrao / aws-key-verifiy.sh
Last active July 19, 2019 09:03
AWS Key Pair verification
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#verify-key-pair-fingerprints
openssl rsa -in ~/.ssh/privatekey -pubout -outform DER | openssl md5 -c
openssl pkcs8 -in path_to_private_key -inform PEM -outform DER -topk8 -nocrypt | openssl sha1 -c
@ferrao
ferrao / aws-beenstalk.md
Last active September 27, 2019 07:59
AWS beenstalk

AWS BeenStalk and Node.JS

Create new ebs application

eb init

Rename EBS environment name

eb config save my-env-name --cfg my-config-name # save the environment config
eb terminate # terminate the environment
eb create my-new-env-name --cfg my-config-name # Create a new cloned environment with a new name
@ferrao
ferrao / aws-rds.md
Last active November 6, 2019 13:44
AWS RDS

AWS RDS - Postgres 11

Recreate Database

\c postgres
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'postgres'
  AND pid <> pg_backend_pid();
\c template1;
@ferrao
ferrao / aws-iam.md
Last active March 19, 2020 21:14
AWS cli IAM examples

AWS IAM

aws iam create-user --profile <aws-cli-profile> --user-name <username> 
aws iam create-login-profile --profile <aws-cli-profile> --user-name <username> --password '<password>'
aws iam delete-login-profile --profile >aws-cli-profile> --user <username>
@ferrao
ferrao / git-gist.md
Last active May 24, 2021 15:11
Git most used

Update fork from upstream

git fetch upstream master
git merge upstream/master

Deploy from branch

Overwrite local staging branch (tracking upstream) with master(upstream fork) :