Skip to content

Instantly share code, notes, and snippets.

@marioluan
marioluan / 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,
@marioluan
marioluan / 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
@marioluan
marioluan / 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;
@marioluan
marioluan / 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;
/**
@marioluan
marioluan / 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',
@marioluan
marioluan / quick-sort.js
Created May 18, 2013 19:52
Lista de algoritmos úteis em javascript: quicksort,...
function partition( array, left, right ) {
var pivot = array[Math.floor((left + right)/2)],
i = left,
j = right;
while ( i <= j ) {
while ( array[i] < pivot ) {
i++;
@marioluan
marioluan / limpar-codigo-barra.js
Last active December 17, 2015 08:59
Script para limpar codigo de barras.
var codigoSujo = prompt('Digite o número do código de barras');
var codigoLimpo = '';
// mantem somente letras e numeros
codigoLimpo = codigoSujo.replace(/\W/g, '');
alert('Aqui está o código de barras limpo: ' + codigoLimpo);
@marioluan
marioluan / figures.js
Last active December 16, 2015 21:29
Lista de classes de figuras geométricas utilizando javascript, html e css.
function Circle(width, height, color){
/*
** @param {Integer} largura
** @param {Integer} altura
** @param {String} cor
*/
this.width = width || 100;
this.height = height || 100;
this.color = color || 'red';
@marioluan
marioluan / ease-functions.js
Created May 2, 2013 03:12
list of ease functions created by Robert Penner.
/*
* This is a near-direct port of Robert Penner's easing equations. Please shower Robert with
* praise and all of your admiration. His license is provided below.
*
* For information on how to use these functions in your animations, check out:
* http://www.kirupa.com/html5/animating_with_easing_functions_in_javascript.htm
*
* -Kirupa
*/
@marioluan
marioluan / calculo-parcela-financiamento.txt
Last active December 15, 2015 16:19
Algoritmos/problemas desenvolvidos nas aulas de lógica de programação da Universidade São Judas Tadeu com a linguagem portugol.
inicio
real valorPresente, valorFuturo, taxaJuros, numParcelas, valorPrestacao
escrever "Digite o valor presente do bem "
ler valorPresente
escrever "Digite a taxa de juros em %"
ler taxaJuros
escrever "Digite a quantidade de parcelas "