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 / inspectElement.js
Created February 29, 2012 13:19
Inspect Element With javaScript
function inspect(obj, maxLevels, level)
{
var str = '', type, msg;
// Start Input Validations
// Don't touch, we start iterating at level zero
if(level == null) level = 0;
// At least you want to show the first level
if(maxLevels == null) maxLevels = 1;
@deyvin
deyvin / jquery.serialize_replace.js
Created March 2, 2012 14:13
Forçar serialize() do jQuery reconhecer checkboxes mesmo não marcado
$(function() {
$.fn.serialize = function (options) {
return $.param(this.serializeArray(options));
};
$.fn.serializeArray = function (options) {
var o = $.extend({
checkboxesAsBools: false
}, options || {});
@deyvin
deyvin / get_remote_file_titanium_mobile.js
Created March 27, 2012 13:45
Get remote file with Titanium Mobile
function get_remote_file(filename, url, fn_end, fn_progress ) {
Ti.API.info("[filename]" + filename);
Ti.API.info("[url]" + url);
var file_obj = {file:filename, url:url, path: null};
var file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,filename);
if ( !file.exists() ) {
@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,