Skip to content

Instantly share code, notes, and snippets.

View marioplumbarius's full-sized avatar
🔥

Mario Souza marioplumbarius

🔥
View GitHub Profile
@marioplumbarius
marioplumbarius / connection.php
Created January 21, 2013 22:14
Simple web application I've coded to insert, delete and select data from database using PHP and MySQL. I've also made both client and server-side validation. Check out a live demo at http://www.marioluan.com.br/php/.
<?php
// openning connection
$link = mysqli_connect('host', 'user', 'password', 'database')
or die('Could not connect to server'.'<br>');
// uncomment next line to debug
//print 'connection opened'.'<br>';
?>
@marioplumbarius
marioplumbarius / arrays-of-objects.js
Last active December 12, 2015 02:29
Programinhas que escrevo enquanto estudo JavaScript.
/*
Exercice:
Define a function called olderAge. We want the function to return the age of the person who is older.
*/
// Our person constructor
function Person (name, age) {
this.name = name;
this.age = age;
}
@marioplumbarius
marioplumbarius / control-flow.rb
Last active December 12, 2015 05:29
Anotações e informações básicas que agrupei sobre a linguagem de programação Ruby.
# if/else
if x > y
print "x é maior que y"
elsif x < z
print "x é menor que y"
else
print "valor padrão"
end
# unless
@marioplumbarius
marioplumbarius / contador-de-palavras.rb
Last active April 9, 2021 23:11
Programinhas que fiz utilizando a linguagem de programação Ruby enquanto estudo pelo code academy.
=begin
Recebe uma entrada de dados (palavra(s)), faz a contagem de cada palavra e mostra na tela em ordem crescente por quantidade de repetições
=end
puts "Enter some text"
text = gets.chomp # recebe a entrada de dados
words = text.split(" ") # cria um array, onde cada palavra ficará em uma posição
# cria um hash vazio para armazenar as palavras e a quantidade de vezes que apareçem
@marioplumbarius
marioplumbarius / built-in.js
Last active December 15, 2015 01:58
Pieces of code I've written while taking 10gen's M101J MongoDB for Java Developers course.
// querying and cursors
cursor = db.people.find(); null ;
cursor.hasNext() // returns true (if there is another set of results) and false (if not)
cursor.next() // returns the next result and move the cursor foward
// Limiting the set of results returned by the queries
cursor.limit(5); null; // limit the results returned by the cursor (default is 20)
// note: the 'null' keyword is used to prevent the mongoshell from printing that query out
@marioplumbarius
marioplumbarius / 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 "
@marioplumbarius
marioplumbarius / 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
*/
@marioplumbarius
marioplumbarius / 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';
@marioplumbarius
marioplumbarius / 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);
@marioplumbarius
marioplumbarius / 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++;