Skip to content

Instantly share code, notes, and snippets.

View brendomaciel's full-sized avatar

Brendo Maciel brendomaciel

  • Else Consultoria
  • Brazil
View GitHub Profile
accent: "#80cbc4"
background: "#263238"
foreground: "#eeffff"
details: "darker"
terminal_colors:
bright:
black: "#464b5d"
green: "#c3e88d"
cyan: "#89ddff"
red: "#f07178"
const helpMeTo = {
get: {
entry: {
from: (array) => {
return {
where: (property) => {
return {
equalsTo: (value) => {
return array.find((item) => item[property] === value);
},
@brendomaciel
brendomaciel / useClassName.js
Last active September 20, 2021 21:32
React Hook for simulate Vue's class name features
const useClassName = (...args) => {
const parse = (classNames) => {
let actualClassNames = [];
if ('string' === typeof classNames) {
actualClassNames.push(classNames);
}
else if (Array.isArray(classNames)) {
for (const className of classNames) {
actualClassNames = actualClassNames.concat(parse(className));
@brendomaciel
brendomaciel / .gitconfig
Last active November 16, 2019 19:20
Git aliases
[alias]
history = log --pretty=format:'%Cred%h%Creset %C(bold)%cr%Creset %Cgreen<%an>%Creset %s' --max-count=30
incoming = !(git fetch --quiet && git log --pretty=format:'%C(yellow)%h %C(white)- %C(red)%an %C(white)- %C(cyan)%d%Creset %s %C(white)- %ar%Creset' ..@{u})
outgoing = !(git fetch --quiet && git log --pretty=format:'%C(yellow)%h %C(white)- %C(red)%an %C(white)- %C(cyan)%d%Creset %s %C(white)- %ar%Creset' @{u}..)
remove = reset HEAD --
restore = checkout --
rollback = reset --soft HEAD~1
@brendomaciel
brendomaciel / flot_tooltip.js
Created March 10, 2018 15:00
Bootstrap tooltip on Flot chart
var previousPoint = null;
$("#selector").on("plothover", function(event, pos, item) {
if (item) {
if (previousPoint != item.dataIndex) {
previousPoint = item.dataIndex;
É interessante:
• Considerar itens frágeis
• Considerar posição item (quando precisar)
• O objeto possuir medidas específicas para envio. Por exemplo: o objeto dobra ou é flexível, como no caso de tecidos
• Empacotar objetos maiores primeiro
• Posicionar ao lado dos itens já empacotados anteriormente, se couber
• Não permitir saliências para que não haja dobras/quebras durante o trânsito (lados lisos)
• Balancear caixas para que não haja muita discrepância de tamanho e peso. Por exemplo: Três caixas médias, são melhores do que 1 caixa pequena e 2 grandes, por exemplo
• Exibir modelo 3D com o resultado
@brendomaciel
brendomaciel / utils.sql
Last active January 4, 2018 21:38
Comandos úteis para servidores MySQL.
SET @@session.foreign_key_checks = 0;
SET @@global.connect_timeout = 200;
SET @@session.max_allowed_packet = 16M;
SET @@session.wait_timeout = 200;
SET @@session.interactive_timeout = 200;
SET @@session.net_read_timeout = 200;
SET @@session.net_write_timeout = 200;
@brendomaciel
brendomaciel / calculo_organizacao_imagens.txt
Last active May 17, 2017 18:36
Cálculo para encontrar as medidas relativas de imagens e suas margens em um grid do tipo: 6 linhas na primeira coluna x 1 linha na segunda coluna.
Declaração de variáveis
LIP: Largura da imagem principal
AIP: Altura da imagem principal
MIP: Margem da imagem principal
LMI: Largura da miniatura
AMI: Altura da miniatura
MMI: Margem da miniatura
NMI: Número de miniaturas
NMA: Número de margens de miniaturas
@brendomaciel
brendomaciel / merge_white_spaces.php
Last active October 13, 2016 22:22
Função para mesclar múltiplos espaços, quebras de linhas ou tabs em um único espaço.
<?php
function merge_white_spaces($string) {
// Remove multiple line breaks
$string = preg_replace("/[\n\r]{3,}|[\r\n]{3,}|[\n]{3,}|[\r]{3,}/", PHP_EOL . PHP_EOL, $description);
// Remove tabs
$string = preg_replace("/\t+/", "", $description);
// Remove multiple spaces (the character " " is used instead \s because the second removes line breaks too)
@brendomaciel
brendomaciel / limit_string.js
Created October 11, 2016 20:47
Function to limit a string.
String.prototype.limit = function(size, cutWord, suspensionPoints) {
var str = this;
cutWord = typeof cutWord == "undefined" ? true : cutWord;
if (typeof size == "number" && size > 0 && str.length >= size) {
str = str.substr(0, size);
if (!cutWord) {
str = str.substr(0, Math.min(str.length, str.lastIndexOf(" ")));