Skip to content

Instantly share code, notes, and snippets.

View alexruzenhack's full-sized avatar

Alex Ruzenhack alexruzenhack

View GitHub Profile
@alexruzenhack
alexruzenhack / index.html
Last active August 29, 2015 14:12
HTML Email Basics Course of Treehouse// source http://jsbin.com/dikez
Paste your HTML in here and click Convert It!<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="description" content="Exemple code of the HTML Email Basics Course of Treehouse" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>square gallery | Newsletter</title>
<!--
This email is based on the idea that the most common design
@alexruzenhack
alexruzenhack / insert_hardcode_javascript_in_body_tag_dom.html
Last active April 6, 2017 19:53
How to insert a hardcode javascript in body tag of the HTML DOM
<script type="text/javascript">
(function () {
var ss = document.createElement('script');
ss.type = 'text/javascript';
ss.async = true;
ss.src = '//app.shoptarget.com.br/js/tracking.js';
var body = document.getElementsByTagName('body')[0]; // seleciona o elemento body
body.appendChild(ss); // adiciona elemento script antes do fechamento do elemento body
})();
</script>
@alexruzenhack
alexruzenhack / insert_hardcode_javascript_in_head_tag_dom.html
Last active April 6, 2017 19:54
How to insert a hardcode javascript in head tag of the HTML DOM
<script type="text/javascipt">
try{
(function(window,document){
head=document.getElementsByTagName('head')[0];
script=document.createElement('script');
// treat the hardcode script tag
head.appendChild(script);
})(window,document);
} catch(e) {
console.log('[GTM][Error in tag "nomeDaTag"]: '+e);
@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 / 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 / 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 / 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 / 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