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
require "addressable/uri" | |
class Hash | |
def to_url_params | |
uri = Addressable::URI.new | |
keys.size.times do |i| | |
self[keys[i]] = "#{values[i].to_s}" | |
end |
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
#idéia inicial | |
class TrendTopics | |
attr_accessor :texto | |
def meu_trend_topic | |
words = texto.downcase.gsub(/[^a-z\s]/, "").split | |
hash_words = Hash.new(0) | |
words.each do |word| |
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
<? | |
function removeAcentos($str) { | |
$enc = (mb_detect_encoding($str, 'UTF-8', true)) ? 'UTF-8' : 'ISO-8859-1'; | |
$acentos = array('A' => '/À|Á|Â|Ã|Ä|Å/', | |
'a' => '/à|á|â|ã|ä|å/', |
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
<?php | |
/* | |
* Tive um sonho muito estranho essa noite, | |
* sonhei que estava escrevendo php desta forma abaixo | |
* no meu sonho parecia algo meio ruby + php + python | |
* | |
* sei lá acho que estou com pânico de "{" | |
*/ |
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
<?php | |
# ATENÇÃO - PARTE DESTE CÓDIGO NÃO FUNCIONA! | |
# Hoje em dia temos | |
if($cor == "Vermelho") | |
echo "Faça algo"; | |
endif; | |
# e também | |
switch($cor) |
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
var win = Titanium.UI.currentWindow; | |
var ind=Titanium.UI.createProgressBar({ | |
width:200, | |
height:50, | |
min:0, | |
max:1, | |
value:0, | |
style:Titanium.UI.iPhone.ProgressBarStyle.PLAIN, | |
top:10, |
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
<?php | |
function limpa_array($array) { | |
foreach($array as $arr) | |
if($arr != '') | |
$retorno[] = $arr; | |
return $retorno; | |
} |
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
<?php | |
# first define colors to use | |
$_colors = array( | |
LIGHT_RED => "[1;31m", | |
LIGHT_GREEN => "[1;32m", | |
YELLOW => "[1;33m", | |
LIGHT_BLUE => "[1;34m", | |
MAGENTA => "[1;35m", | |
LIGHT_CYAN => "[1;36m", | |
WHITE => "[1;37m", |
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
<?php | |
function plural($num) { | |
if ($num != 1) | |
return "s"; | |
} | |
function getRelativeTime($date) { | |
$diff = time() - strtotime($date); |
OlderNewer