Skip to content

Instantly share code, notes, and snippets.

View marioplumbarius's full-sized avatar
🔥

Mario Souza marioplumbarius

🔥
View GitHub Profile
@marioplumbarius
marioplumbarius / no-oop.js
Last active December 20, 2015 22:48
Comparando um código feito com base em OOP e outro não.
Object.keys = Object.keys || (function () {
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !{toString:null}.propertyIsEnumerable("toString"),
DontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
@marioplumbarius
marioplumbarius / matrices.java
Last active December 21, 2015 11:49
Criando class com metodos para manipulacao de matrizes.
public class Matrizes {
private int linhas;
private int colunas;
private int[][] matriz;
private int[] diagonalPrincipal;
private int[] diagonalSecundaria;
private Boolean isMatrizQuadrada = false;
/**
@marioplumbarius
marioplumbarius / Caixa.java
Created September 2, 2013 00:51
Projeto emporium feito em JAVA no laboratório de programação.
package emporium;
// Esta classe modela o caixa do "emporium". Ela deve receber o nome do
// cliente e a lista de produtos (conteúdo do "carrinho").
public class Caixa
{
// atributos: variáveis que armazenam os dados de um objeto, após este
// ser instanciado.
private Cliente cliente;
private Carrinho carrinho;
@marioplumbarius
marioplumbarius / npm.sh
Created September 14, 2013 00:45
Shell scripts to check if certain dpkg packages are installed on linux systems.
#!/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
@marioplumbarius
marioplumbarius / remover-acentos.js
Created October 10, 2013 18:27
Funcao marota para remover acentos de strings. Foi utilizado expressao regular em cima de caracteres representados na base hexadecimal.
/**
* 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,
@marioplumbarius
marioplumbarius / slider.js
Last active December 26, 2015 03:19
Classe JS para trabalhar com slider.
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;
@marioplumbarius
marioplumbarius / como-executar.txt
Last active April 18, 2019 00:53
Implementação de um servidor socket local em linux.
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
*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
@marioplumbarius
marioplumbarius / ciphers.js
Created May 6, 2014 00:21
Collection of functions I wrote while taking the cryptography classes from Khan Academy.
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;
@marioplumbarius
marioplumbarius / sed-find-replace-current-directory.sh
Last active August 12, 2016 20:49
Shell script which finds and replaces all occurrences of given characters in files from the current directory.
#!/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"