Skip to content

Instantly share code, notes, and snippets.

View marceloxp's full-sized avatar
:octocat:
Learning

Marcelo de Souza Lima marceloxp

:octocat:
Learning
View GitHub Profile
@marceloxp
marceloxp / FileNameUtils.php
Last active June 13, 2016 18:45
Captura um nome de arquivo de devolve um array de 2 elementos com o nome e extensão.
<?
function GetFileParts($file_name)
{
$tmp = explode("/", $file_name);
$_filename = array_pop($tmp);
$tmp = explode(".", $_filename);
$ext = array_pop($tmp);
$fil = substr($_filename, 0, ((strlen($ext)+1) * -1));
$r = array();
$r["name"] = $fil;
@marceloxp
marceloxp / gist:5759727
Created June 11, 2013 19:09
setToCenterOfParent
function setToCenterOfParent(obj, parentObj)
{
var height = $( obj ).height();
var width = $( obj ).width();
if ( parentObj == window ) {
$( obj ).css( 'top', ( $( parentObj ).height() / 2 ) - ( height / 2 ) );
$( obj ).css( 'left', ( $( parentObj ).width() / 2 ) - ( width / 2 ) );
}
else {
$( obj ).css( 'top', ( $( parentObj ).height() / 2 ) - ( height / 2 ) + $( parentObj ).position().top );
@marceloxp
marceloxp / switch-case.php
Last active December 18, 2015 08:29
switch case
switch ($i)
{
case 0:
echo "i equals 0";
break;
case 1:
echo "i equals 1";
break;
case 2:
echo "i equals 2";
@marceloxp
marceloxp / log-to-file.php
Created June 7, 2013 20:54
Save log to disk
function Log($texto)
{
$tw = $texto;
if (is_array($texto))
{
ob_start();
print_r($texto);
$tw = ob_get_contents();
ob_end_clean();
}
@marceloxp
marceloxp / gist:5731211
Last active December 18, 2015 05:18
AjaxRequest
function AjaxRequest(args)
{
try
{
$.ajax
(
{
url: "arquivo.php",
type: "POST",
data:
@marceloxp
marceloxp / gist:5731198
Last active April 18, 2016 13:06
jQuery onReady
$(document).ready
(
function()
{
}
);