Skip to content

Instantly share code, notes, and snippets.

View alexruzenhack's full-sized avatar

Alex Ruzenhack alexruzenhack

View GitHub Profile
@alexruzenhack
alexruzenhack / mysql-function-gender.sql
Last active November 27, 2018 14:35
Query para criar uma função de retorno padrao de genero em string no #mysql
CREATE FUNCTION dermage_regua.gender(currentGender varchar(1)) RETURNS varchar(1) CHARSET utf8
BEGIN
declare gender varchar(1);
IF currentGender IN ('F','M') THEN SET gender = currentGender;
ELSE SET gender = 'F';
END IF;
RETURN gender;
END
@alexruzenhack
alexruzenhack / check-services-and-ports.md
Last active November 27, 2018 14:31
📋 Check witch ports are open and witch services are running #linux #wildfly

Verify services

Status of all services:

service --status-all

Status of any service:

service wildfly status
@alexruzenhack
alexruzenhack / include-assets-per-controller.md
Last active April 20, 2017 02:41
🍕 add javascript asset per controller on page if the asset exists

Rails assets per controller

Check if asset exists with find_asset before include it.

<!-- Include javascript per-controller - vendor plugins -->
<%= javascript_include_tag params[:controller] 
        if ::Rails.application.assets.find_asset("#{params[:controller]}.js") %>
@alexruzenhack
alexruzenhack / cut-sqlserver-log.sql
Last active November 27, 2018 14:30
✂️ Shrink log file of #sqlserver
USE [nomeSeuBancoDeDados];
CHECKPOINT;
GO
CHECKPOINT; -- run twice to ensure database file wrap-around last transactions
GO
-- 200 MB
DBCC SHRINKFILE(nomeSeuBancoDeDados_log, 200);
@alexruzenhack
alexruzenhack / emergency-repair-sqlserver.sql
Last active November 27, 2018 14:29
💉 Repair #sqlserver database into emergency mode
-- step 01 - Set the database into emergency mode
ALTER DATABASE yourDatabase SET EMERGENCY;
-- step 02 - Emegency mode repair
ALTER DATABASE yourDatabase SET SINGLE_USER
DBCC CHECKDB(yourDatabase, REPAIR_ALLOW_DATA_LOSS);
-- steop 03 - Unlock the database setting it into multiuser again
ALTER DATABASE yourDatabase SET MULTI_USER;
@alexruzenhack
alexruzenhack / full-backup-and-log-control.sql
Last active November 27, 2018 14:30
🐇 🐇 Protect your #sqlserver database with backup and control log volume
-- ============================================================================
-- 1. Limitamos o tamanho do log a 200MB com variação de 50MB;
-- alter log size of database
USE [yourDatabase];
GO
ALTER DATABASE [yourDatabase]
MODIFY FILE
(NAME = yourDatabase_log,SIZE = 200MB, FILEGROWTH = 50MB);
GO
@alexruzenhack
alexruzenhack / How to create an enum in Java.java
Last active November 27, 2018 14:28
📙 This #enum implements static functions in enum to get self values, and a list of parameters.
public enum Status {
P("Pending"),
A("Approved");
private String name;
Status(String name) {
this.name = name;
}
@alexruzenhack
alexruzenhack / clean_code.md
Last active November 27, 2018 14:29 — forked from wojteklu/clean_code.md
Summary of #cleancode by Robert C. Martin #unclebob

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@alexruzenhack
alexruzenhack / apsnetcore-logging.md
Created November 28, 2018 14:19
Customizing ASP.NET Core Logging #aspnetcore #log
@alexruzenhack
alexruzenhack / pull-request-process.md
Created December 13, 2018 16:37
Processo de Pull Request #git #pullrequest
  1. Criar nova branch com as alterações realizadas na base do código
    • git checkout -b <branch name>
  2. Adicionar alterações na staging area
    • git add <. para adicionar tudo | path endereço do arquivo>
  3. Criar um commit descritivo da tarefa realizada, dos arquivos alterados
    • git commit -m "Descrever atividade"
  4. Puxar alterações da master para o repositório local
    • git pull origin master
  5. Atualizar a branch com as alterações da master, se existirem alterações
  • git merge master