Skip to content

Instantly share code, notes, and snippets.

Avatar

Mario Luan marioluan

View GitHub Profile
View sample.sh
#!/bin/bash
execute(){
echo "sample execute like a charm!"
}
@marioluan
marioluan / .git.aliases
Created Feb 24, 2017
Git related gists.
View .git.aliases
alias glog="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@marioluan
marioluan / export-linkedin-profile-as-pdf.js
Last active Mar 11, 2020
Export your linkedin public profile to PDF if you're having trouble with internationalization.
View export-linkedin-profile-as-pdf.js
// Reason to create this script:
// My profile was created in portuguese, but when I translated
// it to english and tried to save my profile as PDF, it could not
// translate some words and dates to english, so I created this gist
// as an alternative.
// Usage
// 1. open your public profile in an incognito* browser tab. E.g.: https://www.linkedin.com/in/marioluan
// 2. copy-n-past the code below into the browser console
// 3. save as PDF
@marioluan
marioluan / sed-find-replace-current-directory.sh
Last active Aug 12, 2016
Shell script which finds and replaces all occurrences of given characters in files from the current directory.
View sed-find-replace-current-directory.sh
#!/bin/bash
current_name=$1
new_name=$2
files=`grep -irl $current_name`
num_files=`grep -irl $current_name | wc -l`
echo "found $num_files file(s) with import name $current_name"
@marioluan
marioluan / ciphers.js
Created May 6, 2014
Collection of functions I wrote while taking the cryptography classes from Khan Academy.
View ciphers.js
var alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
function encryption ( word, shift ) {
var encryptedWord = '';
for (var i = 0; i < word.length; i++) {
var letter = word[i].toUpperCase();
var letterIndex = alphabet.indexOf(letter);
var shiftedIndex = letterIndex+shift;
var newLetterIndex = shiftedIndex % alphabet.length;
View binary-search.js
*linear:
- somente 1 dimensao
- lista finita e sequencial de items
A escolha do metodo a ser utilizado depende de:
- quantidade de dados envolvidos
- volume de operacoes de inclusao/exclusao
Algoritmos relacionados à memória primária
Busca linear/sequencial
@marioluan
marioluan / como-executar.txt
Last active Apr 18, 2019
Implementação de um servidor socket local em linux.
View como-executar.txt
Compile os arquivos:
$ gcc -o executavel_server socket_server.c
$ gcc -o executavel_client socket_client.c
Inicie o server:
$ ./executavel_server
Rode o client:
$ ./executavel_client
@marioluan
marioluan / slider.js
Last active Dec 26, 2015
Classe JS para trabalhar com slider.
View slider.js
function Slider( containerSlider ){
this.container = document.querySelector( containerSlider );
this.botoesSlider = this.container.querySelectorAll( '.slider-navegacao-botao' );
this.tagImagem = this.container.querySelector( '.slider-imagem' );
this.listaImagens = this.tagImagem.attributes['data-images'].value.split(',');
this.areaClicavelImagem = this.container.querySelector( '.area-clicavel-imagem' );
this.botaoRetroceder = this.areaClicavelImagem.querySelector( '.botao-retroceder' );
this.botaoAvancar = this.areaClicavelImagem.querySelector( '.botao-avancar' );
this.posicaoSlider = 0;
this.quantidade = this.listaImagens.length;
@marioluan
marioluan / remover-acentos.js
Created Oct 10, 2013
Funcao marota para remover acentos de strings. Foi utilizado expressao regular em cima de caracteres representados na base hexadecimal.
View remover-acentos.js
/**
* Remove acentos de caracteres
* @param {String} stringComAcento [string que contem os acentos]
* @return {String} [string sem acentos]
*/
function removerAcentos( newStringComAcento ) {
var string = newStringComAcento;
var mapaAcentosHex = {
a : /[\xE0-\xE6]/g,
e : /[\xE8-\xEB]/g,
@marioluan
marioluan / npm.sh
Created Sep 14, 2013
Shell scripts to check if certain dpkg packages are installed on linux systems.
View npm.sh
#!/bin/bash
## npm
is_npm_installed=$(dpkg -l | grep -i npm | awk '{print $2}')
if [ '$is_npm_installed' == 'npm' ]
then
is_npm_installed=true
else
is_npm_installed=false
fi
You can’t perform that action at this time.