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 / dynamic_thumbnail_with_php.php
Created January 14, 2013 16:27
This script is a perfect method to create thumbnail with uploaded images. Enjoy us!
<?php
# ----------------------------------------------------------------------
# DFN Thumbnailer
# http://www.digifuzz.net
# [email protected]
# ----------------------------------------------------------------------
# Constants
@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);
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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;