Skip to content

Instantly share code, notes, and snippets.

@stephandesouza
stephandesouza / example.php
Created October 18, 2012 21:08
Recursively map a string function from a array/object
<?php
//Array from JSON Webservice
$array = array();
//Decoding all values from UTF-8
str_recursive_map('utf8_decode',$array);
//Applying htmlentities ( Good for other charset )
str_recursive_map('htmlentities',$array);
@stephandesouza
stephandesouza / includes-advert.class.php
Last active December 16, 2015 09:49
Better jQuery Support on ML Advert Wordpress Plugin http://wordpress.org/extend/plugins/ml-adverts
<?php
/*
* With this we remove all not necessary HTML Tags for the URL and use the Title attr, also add a "ml-advert" metada for jQuery on() control
Where:
$ret_val = "<a" .
" href='" . MLA_BASE_URL . "out.php?id=" . $this->get_advert_id() . "'" .
" onmouseover='maskLink(this,event,\"" . $url_mask . "\")'" .
" onclick='maskLink(this,event,\"" . $url_mask . "\")'" .
" onmouseout='maskLink(this,event,\"" . $url_mask . "\")'" .
@stephandesouza
stephandesouza / Exemplo Chamada
Last active December 22, 2015 06:18
Exemplo de como chamar um formulário/include usando shortcode
[include_form template="contato" titulo="Formulário de Contato"]
// É feito o include do arquivo "forms/contato.php", com uma variável $titulo, com valor "Formulário de Contato"
@stephandesouza
stephandesouza / gist:6820103
Last active December 24, 2015 15:29
PHP: Extract + List // Lat Lang Geo
<?php
list($lat, $lon) = explode(',', '-22.903322,-43.173098');
echo $lat; //-22.903322
echo $lon; //-43.173098
@stephandesouza
stephandesouza / 0_reuse_code.js
Created November 20, 2013 01:31
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?php
interface Atendimento
{
const SUPORTE = 1;
const FINANCEIRO = 2;
const ADMINISTRATIVO = 3;
public function encerrar();
}
<?php
interface Produto
{
public function especificacoes();
}
class Livro implements Produto
{
public function especificacoes() {
}
@stephandesouza
stephandesouza / Gruntfile.js
Created July 3, 2014 14:05
Uso do Grunt + Spritemisth
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
sprite:{
all: {
algorithm: 'binary-tree',
src: 'public/r/sprites/*.png',
destImg: 'public/r/sprites.794984.png',
destCSS: 'public/r/css/sprites.less',
<?php
use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;
FacebookSession::setDefaultApplication('YOUR_APP_ID','YOUR_APP_SECRET');
// Use one of the helper classes to get a FacebookSession object.
// FacebookRedirectLoginHelper
@stephandesouza
stephandesouza / encurtarNome.php
Last active October 19, 2023 14:28
Encurtador de Nomes (similar a cartões de crédito)
<?php
/**
* Função que recebe o nome completo de uma pessoa redunzido as partes do meio - maiores que 3 caracteres- a ponto, ou sem, conforme combinado
*
* Ex.: JOÃO BELTRANO CICLANO DA SILVA > (com ponto) > JOÃO B. C. DA SILVA
* Ex.: JOÃO BELTRANO CICLANO DA SILVA > (sem ponto) > JOÃO B C DA SILVA
* Ex.: MARIA ANTONIETA > (sem nomes do meio) > MARIA ANTONIETA)
*
* @param string $nome Nome completo a ser encurtado.
* @param bool $ponto Será usado ponto no encurtamento do nome? Padrão: true