This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>'; | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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++; |