Skip to content

Instantly share code, notes, and snippets.

View deyvin's full-sized avatar
🏠
Working from home

Deyvid Nascimento deyvin

🏠
Working from home
View GitHub Profile
@deyvin
deyvin / hash_to_url_query.rb
Created March 10, 2011 19:20
How to Convert Hash to Url Query
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
@deyvin
deyvin / trend_topic.rb
Created March 11, 2011 14:44
Ideia para um Trend Topic pessoal
#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|
@deyvin
deyvin / sem_acentos.func.php
Created September 26, 2011 19:27
removendo Acentos com php
<?
function removeAcentos($str) {
$enc = (mb_detect_encoding($str, 'UTF-8', true)) ? 'UTF-8' : 'ISO-8859-1';
$acentos = array('A' => '/&Agrave;|&Aacute;|&Acirc;|&Atilde;|&Auml;|&Aring;/',
'a' => '/&agrave;|&aacute;|&acirc;|&atilde;|&auml;|&aring;/',
@deyvin
deyvin / buttons.css
Created November 23, 2011 18:11
WEB 2.0 buttons with css
.button {
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
-khtml-border-radius: 4px;
border-radius: 4px;
-moz-box-shadow:inset 1px 1px 0 rgba(255,255,255,0.3);
-webkit-box-shadow:inset 1px 1px 0 rgba(255,255,255,0.3);
box-shadow:inset 1px 1px 0 rgba(255,255,255,0.3);
@deyvin
deyvin / php_sintaxe_dream.php
Created March 28, 2012 14:05
Esta noite sonhei que a sintaxe do php estava assim
<?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 "{"
*/
@deyvin
deyvin / alternativa.php
Created March 28, 2012 16:36
[idéia] outras sintaxes alternativas da linguagem php
<?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)
@deyvin
deyvin / upload.js
Created March 30, 2012 00:43
image upload (device to server) with Titanium Mobile
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,
@deyvin
deyvin / php_git.php
Created April 17, 2012 18:54
Brincando com shell_exec do php com git
<?php
function limpa_array($array) {
foreach($array as $arr)
if($arr != '')
$retorno[] = $arr;
return $retorno;
}
@deyvin
deyvin / php_shell_color.php
Created May 7, 2012 19:39
shell colors with php
<?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",
@deyvin
deyvin / relative_time.php
Created June 4, 2012 12:46
relative time php
<?php
function plural($num) {
if ($num != 1)
return "s";
}
function getRelativeTime($date) {
$diff = time() - strtotime($date);