Skip to content

Instantly share code, notes, and snippets.

View marciofmjr's full-sized avatar
🕷️
🕸

Marcio Junior marciofmjr

🕷️
🕸
View GitHub Profile
@marciofmjr
marciofmjr / favicon.html
Last active May 11, 2018 13:02
How to use favicon
<link rel="shortcut icon" href="/img/favicon.ico" type="image/x-icon" />
<!-- .ico generator: http://convertico.com/ -->
@marciofmjr
marciofmjr / cookies.js
Last active May 4, 2018 00:50
How to manage cookies easily
function setCookie(name, value, days) {
var expires;
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toGMTString();
} else {
expires = "";
}
@marciofmjr
marciofmjr / ismobile.js
Last active May 9, 2018 20:07
Javascript function to verify if breakpoint is mobile or not based on css
function isMobile(){
var content = window.getComputedStyle(document.querySelector('body'), ':before').getPropertyValue('content');
if(content == "\"mobile\"" || content == "mobile"){
return true;
}else{
return false;
}
}
@marciofmjr
marciofmjr / charset.php
Created May 4, 2018 01:13
Forcing charset in page
<?php header ('Content-type: text/html; charset=UTF-8'); ?>
<?php header ('Content-type: text/html; charset=ISO-8859-1'); ?>
@marciofmjr
marciofmjr / responsivehelper-how-to-use.js
Created May 4, 2018 01:32
Javascript function that helps to develop responsive, easily showing changes between breakpoints
$(document).ready(function() {
responsiveHelper([
{size: 1199, label: "xlarge"},
{size: 1049, label: "Large"},
{size: 799, label: "medium"},
{size: 576, label: "small"}
]);
});

Controllers

O que o controller faz ?

  • Recebe requisições (com/sem autenticação)
  • Manipula Models
  • Cria respostas
    • Renderizando um template
    • Respondendo com um formato solicitado (json)
    • Redirecionando para outra rota

Faker

Instalação

group :development, :test do
  gem 'faker'
end

Exemplos

.slick-list
max-width: none
margin: 0 -15px // margin dos elementos internos
@marciofmjr
marciofmjr / wordpress-html-embbed-sample.html
Created July 6, 2019 11:43
wordpress html embbed sample
<html>
<head>
<title>Meu site com Wordpress</title>
</head>
<body>
<h1>meu primeiro titulo</h1>
<a href="#">Ler mais..</a>
</body>
</html>

Criar rotina para compressão/otimização de imagens

Primeiro, será necessário instalar as dependências no servidor

yum install nodejs npm
npm install optimizilla-cli -g

Em seguida, deverá ser criado o arquivo que conterá o script de execução no servidor