Skip to content

Instantly share code, notes, and snippets.

View dgmike's full-sized avatar

Michael Granados dgmike

View GitHub Profile
<?php
/**
* Exemplo de uso:
*
* echo change_str(',', '|', 'a,b,c,d,e', 3);
* >>> 'a,b,c,d|e'
*/
function change_str($str, $replacer, $string, $pos)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>Select</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="seu_javascript.js" type="text/javascript"></script>
</head>
<body>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Integers</title>
</head>
<body>
<script type="text/javascript">
Number.prototype.fixIt = function(){
@dgmike
dgmike / gist:401706
Created May 14, 2010 21:39
Regras do pedra, papel, tesoura, lagarto, spok
pedra, papel, tesoura, lagarto, spok
Regras:
-------
tesoura corta papel
papel cobre pedra
pedra esmaga lagarto
lagarto envenena spok
spok quebra tesoura
$especiais = unserialize(PARTICIPANTES_ESPECIAIS);
$parNomeEspecial = isset($participante)
&& isset($participante['PARNOME'])
&& in_array($participante['PARNOME'], $especiais);
if (!$participante || !$parNomeEspecial):
<?php
$perfil = 'dgmike';
$saida = file_get_contents("http://util.dgmike.com.br/meadiciona/{$perfil}.json");
$perfil = json_decode($saida);
if ($perfil->r) {
echo '<h2>'.$perfil->data->nome.'</h2>';
foreach ($perfil->data->servicos as $servico) {
if (!$servico->url) continue; // Se não tiver a url, não irei exibir
echo "<a href='{$servico->url}' style='float:left; width: 190px; height:35;text-align:center'>";
@dgmike
dgmike / new.google.charts.js
Created June 2, 2010 13:05
Criando LineChart com o google Charts é fácil!
function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Ano');
data.addColumn('number', 'Visualizacoes');
// [ column, column, ... ] => row
// column pode ser uma String/Int/Float/Date ou o seguinte objeto
// { v: "", p : {} } => column, onde v = valor; p: properties
// http://code.google.com/apis/visualization/documentation/reference.html#cell_object
<?php
$object = array(
array(
'a' => 'Como vai você?',
'b' => 'Vou bem',
),
array(
'c' => 'E a família',
),
@dgmike
dgmike / extending-pdo.php
Created September 8, 2010 18:00
Simple way to use PDO
<?php
class Con extends PDO
{
function Con()
{
self::PDO(CONFIG_DNS, CONFIG_USER, CONFIG_PASS);
}
function get($table, $id)
@dgmike
dgmike / vertical-align.html
Created December 6, 2010 21:45
Alinhando uma div verticalmente. Baseado no código do CSSplay
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title> Stu Nicholls | CSSplay | Centering an image using CSS</title>
<style type="text/css">
/* for non-IE browsers */
div.holder {width:748px; height:300px; background:#f8f8f8; border:1px solid #777; text-align:center; display:table-cell; vertical-align:middle;}