Skip to content

Instantly share code, notes, and snippets.

@caionitro
caionitro / buscaXML.sql
Created August 28, 2014 18:24
MSSQL para buscar XML
SELECT TOP 100
acao,
dados.value('(/*/*/@bimestre)[1]' , 'int') bimestre,
dados.value('(/*/*/@cargaHoraria)[1]', 'int') cargaHoraria,
dados.value('(/*/*/@conteudo)[1]' , 'varchar(550)') conteudo,
dados.value('(/*/*/@material)[1]' , 'varchar(550)') material,
dados.value('(/*/*/@orientacao)[1]' , 'varchar(550)') orientacao,
dados.value('(/*/*/@dataCriacao)[1]' , 'date') dataCriacao
FROM Log_Data..LD_Xml
WHERE TABELA = 'Aux_temp.dbo.PE_CONTEUDO'
@caionitro
caionitro / tabelaDinamica.php
Created July 17, 2014 18:36
Tabela dinâmica
<div class='tableGrid'>
<?php if ($query != null){
$cols = mysql_num_fields($query); ?>
<table class='table-striped table-hover table-ellipsis'>
<thead>
<tr>
<?php for($i=0;$i<$cols;$i++){ ?>
<th title='<?=mysql_field_name($query,$i)?>'><?=mysql_field_name($query,$i)?></th>
}
</tr>
@caionitro
caionitro / httpd.conf
Created July 10, 2014 19:41
Para ativar o mod_deflate no Apache
#http://httpd.apache.org/docs/2.2/mod/mod_deflate.html
# Insert filter
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
@caionitro
caionitro / desabJS.js
Created June 10, 2014 19:08
Verificação de JS na página.
<noscript>JavaScript Desativado!</noscript>
<style type="text/css">plaintext{display:none}</style>
<script>
(function(){
try{
var win=this;
while("<plaintext/>"){
if(win.parent==win)
break;
win.frameElement.src.substr(0,1);
@caionitro
caionitro / url_friendly.php
Last active August 29, 2015 14:01
URL Amigável
<?php
$aux = substr( $_SERVER['REQUEST_URI'], strlen('/'));
if( substr( $aux, -1) == '/'){
$aux=substr( $aux, 0, -1);
}
$url = explode( '/', $aux);
@caionitro
caionitro / .htaccess
Last active August 29, 2015 14:01
htacess para o CodeIgniter
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
@caionitro
caionitro / JsonEncoder.php
Created March 28, 2014 18:42
Transformando o objeto da classe em array JSON recursivamente.
<?php
class JsonEncoder{
//basta chamar este método!
public function json_encode($object){
return json_encode($this->getFields($object));
}
private function getFields($classObj){
$fields = array();
$reflect = new ReflectionClass($classObj);
@caionitro
caionitro / geraSenha.php
Last active August 10, 2018 13:01
função para gerar CAPTCHA
<?php
function geraSenha($tamanho = 6, $maiusculas = true, $numeros = true, $simbolos = false)
{
$lmin = 'abcdefghjkmnpqrstuvwxyz';
$lmai = 'ABCDEFGHJKMNPQRSTUVWXYZ';
$num = '23456789';
$simb = '!@#$%*-';
$retorno = '';
$caracteres = '';
@caionitro
caionitro / getset.sublime-snippet
Last active August 29, 2015 13:57 — forked from eminetto/gist:2137945
Snippet pro getset sublime text
<snippet>
<content><![CDATA[public function get${1/(.*)/\u$1/}()
{
return \$this->${1:$SELECTION};
}
public function set${1/(.*)/\u$1/}(\$$1)
{
return \$this->$1 = \$$1;
}
@caionitro
caionitro / view.php
Last active April 2, 2016 15:42
classe view da MVC
<?php
/**
* Essa classe é responsável por renderizar os arquivos HTML
*
* @package Exemplo simples com MVC
* @author DigitalDev
* @version 0.1.1
*
* Diretório Pai - lib
* Arquivo - View.php