Instantly share code, notes, and snippets.

# Erko Bridee erkobridee

Created January 31, 2012 12:57
[AS3] Calculo da diferença entre 2 datas
This file contains 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
 public static function dateDiff( date1:Date, date2:Date ) : String { // calculando a diferença em milisegundos das datas var sec:Number = date2.getTime() - date1.getTime(); // verificando se a segunda data é inferior que a primeira if( sec < 0 ) { Alert.show( "The second date ocurred earlier than the first one!" ); return null; }
Created February 1, 2012 01:41
This file contains 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
 ''' Curiosidades do Python e estruturas de loop uma delas temos a funcao range a qual nos possibilita criar um array facilmente... ex.: arr = range(10)
Created February 1, 2012 01:56
um calculo simples que usei para realizar ajustes nas dimensões de imagens
This file contains 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
 import math def aumentoPercentual(valorInicial, valorPercentual): resultado = math.ceil( valorInicial * valorPercentual ) return valorInicial + resultado def reducaoPercentual(valorInicial, valorPercentual): resultado = math.ceil( valorInicial * valorPercentual ) return valorInicial - resultado
Created February 1, 2012 15:49
Algoritmo matemático para calcular fatorial (com limite) e combinação
This file contains 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
 def fatorial(n, limite=1): if n == 0 or n == 1: return 1 #por definição 0! ou 1! = 1 if limite < 1 or limite >= n: return -1 #representando valor incorreto else : fatArr = range(limite,n+1) resultado = 1 for i in fatArr: resultado = resultado * i
Created February 3, 2012 12:32
um dos desafios do site rankk.org
This file contains 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
 def binaryStringCalc(strValue): result = 0 for v in strValue.split(' + '): result += int(v,2) return str(bin(result)).split('0b')[1] print binaryStringCalc('110000001 + 100111001 + 100101000 + 10000011 + 111010001')
Created February 3, 2012 12:38
um dos desafios do site rankk.org
This file contains 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
 ''' Really elementary A box contains some buttons. 1/4 of them are black, 1/8 of them are red, and the rest are white. There are 636 more white buttons than red buttons. How many buttons are there altogether?
Created February 3, 2012 13:02
um dos desafios do site rankk.org
This file contains 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 1 bucket of food feed 2 donkeys for 3 days, how many buckets are needed to feed 1314 donkeys for 1 day? donkeys | days | buckets n | 1 | x 2 | 3 | 1 x = n/2 * 1/3
Created February 3, 2012 13:17
um dos desafios do site rankk.org
This file contains 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
 ''' The nth term 1,1,2,3,5,8,13,21,34,55,89 ... Give the 119 th term. ''' def fib(n): a, b = 0, 1 r = []
Created February 27, 2012 17:23
Validação/verificação se um número é ou não um número primo
This file contains 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
 # -*- coding: latin1 -*- from math import sqrt from time import time ''' Implementar uma função que retorne verdadeiro se o número for primo (falso caso contrário). Testar de 1 a 100. ''' # verifica se o número é um valor inteiro
Created July 10, 2012 14:29
Teste de POO Herança simples em CoffeeScript
This file contains 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
 ### uma possível justificativa para utilizar o CoffeScript, ele possibilita codificar mais próximo do conceito de POO de linguagens como o Java, C#, ... http://js2coffee.org/ faça um teste na aba: CoffeeScript > JS ### class ClassA @att1 = "atributo 1" @att2 = "atributo 2"