Skip to content

Instantly share code, notes, and snippets.

View luisdalmolin's full-sized avatar
👨‍💻

Luís Dalmolin luisdalmolin

👨‍💻
View GitHub Profile
@luisdalmolin
luisdalmolin / regexp-name-id.md
Created November 6, 2012 16:37
Remove name and ID attribute

Removendo todos os atributos name e ID

  • \s*(name|id)="[^"]+"\s*
  • # (1 espaço)

Adicionando style="display: block"

  • \s*(border)="[^"]+"\s*
  • border="0" style="display: block"
@luisdalmolin
luisdalmolin / controller.php
Created September 25, 2012 01:39
EscapeWork: Controller
<?php
/**
* Controlador da página ...
*
* @author ... <email@escape.ppg.br>
*/
if( !defined('ESCAPEWORK') ) {
exit();
@luisdalmolin
luisdalmolin / baseclass.php
Created September 25, 2012 01:34
EscapeWork: Base Class
<?php
/**
* Description
*
* @author Seu nome <email@escape.ppg.br>
*/
class NomeDaClasse extends EscapeWork
{
@luisdalmolin
luisdalmolin / openstack.php
Created July 17, 2012 17:12
Congrats to Openstack
<?php
interface Congratulations
{
public function congrats();
}
class OpenStack implements Congratulations
{
static $instance;
@luisdalmolin
luisdalmolin / index.html
Created June 19, 2012 02:14
Carregando os gists por ajax
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Carregando GIST's por ajax</title>
<style type="text/css">
body {
font-family: Helvetica, sans-serif;
font-size: 13px;
<?php
$str = "Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός";
$str = mb_strtolower($str, 'UTF-8');
echo $str; // Prints τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός
<?php
$texto = 'ESTA É UMA FRASE COM ACENTUAÇÃO';
echo strtolower( $texto ); // escreve: 'esta �� uma frase com acentua����o'
echo mb_strtolower( $texto, 'UTF-8' ); // escreve: 'esta é uma frase com acentuação'
<?php
$cep = new Cep('SEU CEP');
echo $cep->uf;
echo $cep->cidade;
echo $cep->bairro;
echo $cep->logradouro;
@luisdalmolin
luisdalmolin / gist:1657650
Created January 22, 2012 16:51
Chamando a função pra limitar
<?php
$texto = 'Lorem Ipsum is simply dummy text of the printin';
echo limitar($texto, 15);
// Escreve na tela "<strong>Lorem Ipsum i...</strong>"
@luisdalmolin
luisdalmolin / limitar.php
Created January 22, 2012 16:49
Limitando caracteres sem erros de caracteres
<?php
function limitar($string, $tamanho, $encode = 'UTF-8') {
if( strlen($string) > $tamanho )
$string = mb_substr($string, 0, $tamanho - 3, $encode) . '...';
else
$string = mb_substr($string, 0, $tamanho, $encode);
return $string;
}