Skip to content

Instantly share code, notes, and snippets.

View marcelitocs's full-sized avatar
🎯
Focusing

Marcelito Costa marcelitocs

🎯
Focusing
View GitHub Profile
@marcelitocs
marcelitocs / remover-acentos.js
Created March 29, 2017 17:56
Remover acentos de uma string [javascript]
function removerAcentos( newStringComAcento ) {
var string = newStringComAcento;
var mapaAcentosHex = {
a : /[\xE0-\xE6]/g,
A : /[\xC0-\xC6]/g,
e : /[\xE8-\xEB]/g,
E : /[\xC8-\xCB]/g,
i : /[\xEC-\xEF]/g,
I : /[\xCC-\xCF]/g,
o : /[\xF2-\xF6]/g,
@marcelitocs
marcelitocs / golang-on-rpi.md
Last active July 1, 2023 22:24 — forked from konradko/golang_on_rpi.md
Install Golang 1.8 on Raspberry Pi
wget https://storage.googleapis.com/golang/go1.8.linux-armv6l.tar.gz
tar -C /usr/local -xzf go1.8.linux-armv6l.tar.gz
export PATH=$PATH:/usr/local/go/bin
@marcelitocs
marcelitocs / jquery-plugin-sortElements.js
Last active June 19, 2017 21:54
Plugin jQuery para ordenar elementos do DOM a partir de um callback
/*
Copyright 2017 Marcelito Costa
https://gist.github.com/marcelitocs/876edd2c70e47f16e595b4dd5f0b6c2d
Exemple of use
$(".table tbody tr").sortElements(function(a, b){
if(a.data("vencimento") < b.data("vencimento")){
return -1;
}
if(a.data("vencimento") > b.data("vencimento")){
@marcelitocs
marcelitocs / docker-guide.md
Last active May 4, 2020 15:01
Guia rápido de utilização do Docker

Inicializando containers

Opção run com interatividade:

$ docker run -it nome_da_imagem [comando]

Executando em background:

$ docker run -d nome_da_imagem
@marcelitocs
marcelitocs / distance-between-coordinates.js
Created June 26, 2017 18:34
Função que retorna a distância em metros entre coordenadas (latitude e longitude)
let distanceBetweenCoordinates = function(p1, p2){
// distância em metros
return Math.sqrt(Math.pow(p1.latitude - p2.latitude, 2) + Math.pow(p1.longitude - p2.longitude, 2)) * 111.319 * 1000;
};
@marcelitocs
marcelitocs / clone.js
Created June 26, 2017 18:56
Clona uma variável em javascript
let clone = function(obj) {
let copy;
// Handle the 3 simple types, and null or undefined
if (null === obj || "object" !== typeof obj) return obj;
// Handle Date
if (obj instanceof Date) {
copy = new Date();
copy.setTime(obj.getTime());
@marcelitocs
marcelitocs / random-int-from-interval.js
Created June 27, 2017 19:07
Função que retorna um número inteiro randômico entre um intervalo
// Retorna um número inteiro rondômico entre min (incluso) e max (incluso)
function getRandomIntFromInterval(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
@marcelitocs
marcelitocs / string-to-byte-array.js
Created June 30, 2017 03:00
Converte String UTF8 para Array de Bytes (também desconverte)
/**
* Converts a JS string to a UTF-8 "byte" array.
* @param {string} str 16-bit unicode string.
* @return {!Array<number>} UTF-8 byte array.
*/
function stringToUtf8ByteArray(str) {
// TODO(user): Use native implementations if/when available
var out = [], p = 0;
for (var i = 0; i < str.length; i++) {
var c = str.charCodeAt(i);

Consultar a saúde do servidor:

GET /_cat/health?v

Está yellow?

PUT /.kibana/_settings
{
    "index": {
@marcelitocs
marcelitocs / extend.js
Created July 2, 2017 02:31
extend function like $.extend
function extend(){
for(var i=1; i<arguments.length; i++)
for(var key in arguments[i])
if(arguments[i].hasOwnProperty(key))
arguments[0][key] = arguments[i][key];
return arguments[0];
}