Skip to content

Instantly share code, notes, and snippets.

View riquellopes's full-sized avatar

Henrique Lopes riquellopes

View GitHub Profile
@riquellopes
riquellopes / maior_menor.py
Created March 7, 2012 11:30
Maior e menor
# coding:utf-8
"""
>>> maior(1, 2, 3)
3 é o maior número!!
>>> maior(1, 2, 4)
4 é o maior número!!
>>> maior(5,5,1)
5 é o maior!!
>>> maior(5,5,5)
todos o numeros são iguais
@riquellopes
riquellopes / decrescente.py
Created March 10, 2012 10:37
Apresentar número de uma forma decrescente.
# coding: utf-8
"""
>>> decrescente(1, 2, 3)
3
2
1
>>> decrescente(100, 101, 102)
102
101
100
<?php
require_once 'PHPUnit/Autoload.php';
class AcessarHuTest extends PHPUnit_Framework_TestSuite
{
public function test_soma()
{
#$this->open('http://hu2.1/');
#$this->assertTitleEquals("Descontos em hotéis é no Hotel Urbano | Home");
@riquellopes
riquellopes / mock_url.py
Created May 27, 2012 18:48
Simple mock urllib2.
from mock import Mock
class MockUrlLib(Mock):
def __init__(self, _file, _type='html', code=200, msg='OK', headers={'content-type': 'text/plain; charset=utf-8'}):
self.file_test = ("%s.%s" % (_file, _type))
self.code = code
self.msg = msg
self.headers = headers
@riquellopes
riquellopes / array_functions.js
Created June 17, 2012 20:06
Simples solução para remover e adicionar elementos em um array.
/**
* Remove array element.
*/
Array.prototype.rm = function(value)
{
var arrays_s = this;
for( var i=0; i<this.length; i++)
{
var obj = this[i];
if( typeof obj === 'number' && obj == value )
@riquellopes
riquellopes / faixa.js
Created November 12, 2012 12:22
Validar faixa de preços
var Faixa = {
criterios:{
1:{reg:/^([1-9]|[1-9][0-9]|1[0-4][0-9]|15[0])$/, label:'1-150'},
2:{reg:/^(15[1-9]|1[6-9][0-9]|2[0-4][0-9]|25[0])$/, label:'151-250'},
3:{reg:/^(25[1-9]|2[6-9][0-9]|3[0-4][0-9]|35[0])$/, label:'251-350'},
4:{reg:/^(35[1-9]|3[6-9][0-9]|4[0-4][0-9]|45[0])$/, label:'351-450'},
5:{reg:/^(45[1-9]|4[6-9][0-9]|5[0-4][0-9]|55[0])$/, label:'451-550'},
6:{reg:/^(55[1-9]|[6-9][0-9][0-9]|[1-4][0-9][0-9][0-9]?[0-9])$/, label:'>551'}
},
execs:function(cri, value)
Array.prototype.shuffle=function(){
this.sort(function(){
return 0.5 - Math.random();
});
return this;
}
phpunit --filter name_class -c phpunit.dev --verbose
@app.route('/name.json')
def name():
name = json.dumps({"name":"recomeçar"}, ensure_ascii=False)
return Response(name, mimetype="application/json; charset=utf-8")
@riquellopes
riquellopes / serial-killer.sh
Created June 1, 2014 14:51
Esquarteja o processo sem piedade.
>>> kill -9 PID