Skip to content

Instantly share code, notes, and snippets.

View altherlex's full-sized avatar

Alther Alves altherlex

View GitHub Profile
@altherlex
altherlex / .zshrc
Created April 9, 2022 20:57
My .zshrc customs
# ---- My personal env -----
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init - zsh)"
# starts Mysql
[ $(mysql.server status|awk '{ print $1}') != 'SUCCESS!' ] && mysql.server start
alias s='subl'
alias ll='ls -lah'
@altherlex
altherlex / commands
Last active March 22, 2022 23:13
commands
$ git update-index --no-assume-unchanged .gitignore Gemfile Gemfile.lock
$ git update-index --assume-unchanged .gitignore Gemfile Gemfile.lock
$ mysqldump -u username -R oldDbName > oldDbName.sql
$ mysqladmin -u username create newDbName
$ mysql -u username newDbName < oldDbName.sql
# No ruby output during rspec
$ RUBYOPT="-W0" bundle exec rspec spec --exclude-pattern "spec/system/**/*.rb" --force-colour
### ElasticSearch was removed as part of 3.0 so this is deprecated
### 1. Run ES locally
[Official website](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html)
```
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.9.1
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.9.1
````
#!/bin/sh
#
# This script should be run via curl:
# sh -c "$(curl -fsSL https://gist.githubusercontent.com/altherlex/15315bebfd9bc65ffb02fad8f899b6a6/raw/azure-auto-changelog.sh)"
# or wget:
# sh -c "$(wget -qO- https://gist.githubusercontent.com/altherlex/15315bebfd9bc65ffb02fad8f899b6a6/raw/azure-auto-changelog.sh)"
# export USER=alther.alves
# export PASSWORD=1234
# export ORIGINAL_BRANCH=release/2.5
# export HOTFIX_BRANCH=release/2.4
#!/bin/sh
#
# This script should be run via curl:
# sh -c "$(curl -fsSL https://gist.githubusercontent.com/altherlex/15315bebfd9bc65ffb02fad8f899b6a6/raw/azure-auto-changelog.sh)"
# or wget:
# sh -c "$(wget -qO- https://gist.githubusercontent.com/altherlex/15315bebfd9bc65ffb02fad8f899b6a6/raw/azure-auto-changelog.sh)"
export FILE_NAME=CHANGELOG-v.$RELEASE_VERSION.md
export TEMPLATE_URL=https://gist.githubusercontent.com/altherlex/5f20de7a31b08be82974f8e620310b74/raw/changelog-template.hbs
export AZURE_URL=https://dev.azure.com/GetSmartSolutions/The%20Product/_apis/git/pullrequests
export API_VERSION=5.1
// HowToUse:
// {{linkWorkItem subject}}
module.exports = function (Handlebars) {
Handlebars.registerHelper('linkWorkItem', function (context) {
var index = context.search(/(\d{3,})\s/g)
if (index !== -1 && context.slice(index-1, index) !== '#') {
return context.slice(0, index) + '#' + context.slice(index)
}
return context
})
{{#each releases}}
# Release {{version}}
[![Build status](https://dev.azure.com/GetSmartSolutions/The%20Product/_apis/build/status/Product-Web%20{{version}})](https://dev.azure.com/GetSmartSolutions/The%20Product/_build/latest?definitionId=39)
from {{niceDateStart}} to {{niceDateEnd}}
## Table of Contents
1. [Features](#features)
2. [Bugfixes](#bugfixes)
3. [List of Tasks](#list-of-tasks)
@altherlex
altherlex / py&django-commands.sh
Last active February 27, 2020 19:13
py commands
$ pg_ctl -D /usr/local/var/postgres stop -s -m fast
$ pg_ctl -D /usr/local/var/postgres start
$ psql
> drop database product;
> create database product;
> \l # list all databases
> \c product #use database
> \d # list all tables
$ pg_restore --username=product --dbname=product -v --no-privileges --no-owner --clean --create ~/Downloads/dev2jan9th.gz
$ python manage.py migrate auth
@altherlex
altherlex / js_series_vs_parallel.js
Last active August 6, 2019 04:29
node js series VS parallel
// in Series
const result = await rows.reduce((p, album, i) => p.then(async () => {
var hotlink_url = '';
try {
hotlink_url = await Helper.getHotlink(album.post_url, browser);
const r = await pool.query(state, [ album.id, null, moment(new Date()) ]);
return r.rows[0];
} catch(e){
console.log('erro ocorrido:', e);
}
@altherlex
altherlex / opsworks_generator.rb
Last active April 27, 2017 17:55
Script to map in ssh_config the opsworks instances alias for vary regions
#!/usr/bin/env ruby
require "rubygems"
require "aws-sdk"
require "pry-nav"
def run_ops_client(opsworks, file_path)
true_instances = []
stacks = opsworks.describe_stacks.stacks