Skip to content

Instantly share code, notes, and snippets.

View rodrigocnascimento's full-sized avatar
🐯
i'm a turtle

Rodrigo Nascimento rodrigocnascimento

🐯
i'm a turtle
View GitHub Profile
@rodrigocnascimento
rodrigocnascimento / webroot
Created February 21, 2014 00:09
colocar dentro de webroot
# Apache configuration file
# httpd.apache.org/docs/2.2/mod/quickreference.html
# Note .htaccess files are an overhead, this logic should be in your Apache
# config if possible: httpd.apache.org/docs/2.2/howto/htaccess.html
# Techniques in here adapted from all over, including:
# Kroc Camen: camendesign.com/.htaccess
# perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
# Sample .htaccess file of CMS MODx: modxcms.com
@rodrigocnascimento
rodrigocnascimento / app
Created February 21, 2014 00:09
dentro de app
# Apache configuration file
# httpd.apache.org/docs/2.2/mod/quickreference.html
# Note .htaccess files are an overhead, this logic should be in your Apache
# config if possible: httpd.apache.org/docs/2.2/howto/htaccess.html
# Techniques in here adapted from all over, including:
# Kroc Camen: camendesign.com/.htaccess
# perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
# Sample .htaccess file of CMS MODx: modxcms.com
@rodrigocnascimento
rodrigocnascimento / check_ports.c
Created July 21, 2014 14:56
Check if port are opened to connections in C maybe a future php module
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
@rodrigocnascimento
rodrigocnascimento / gist:dee476f5af863f0d4220
Created September 14, 2014 19:13
mime_type_functions.php
<?php
define('APACHE_MIME_TYPES_URL','http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types');
function generateUpToDateMimeArray($url){
$s=array();
foreach(@explode("\n",@file_get_contents($url))as $x)
if(isset($x[0])&&$x[0]!=='#'&&preg_match_all('#([^\s]+)#',$x,$out)&&isset($out[1])&&($c=count($out[1]))>1)
for($i=1;$i<$c;$i++)
$s[]='&nbsp;&nbsp;&nbsp;\''.$out[1][$i].'\' => \''.$out[1][0].'\'';
return @sort($s)?'$mime_types = array(<br />'.implode($s,',<br />').'<br />);':false;

Basics

Creating a new PHPExcel Object.

    $this->PHPExcel = new PHPExcel();

Working with sheets

Creating a new sheet:

@rodrigocnascimento
rodrigocnascimento / gist:1338736c0cb8af0c8ef8
Created December 2, 2014 15:46
Impedir o usuário sair da página, sem gravar os dados
$( function(){
var init_form = $('#id_form').serialize();
// Result example: "name=&email=&message="
// Cancel event onbeforeunload when Submit form
$(':submit').click(function() {
window.onbeforeunload = null;
});
<div class="col-xs-12 col-sm-4">
<div class="form-group col-xs-12">
<label for="SECAO" class="">SEÇÃO</label>
<select name="secao" id="SECAO" class="col-xs-12 select">
<option value="NULL">Todas as Seções</option>
<option value="2100">EMPREGOS</option>
<option value="1100">IMOVEIS ALUGUEL</option>
<option value="1200">IMOVEIS VENDA</option>
<option value="8100">MAQ. E EQUIPAMENTOS</option>
<option value="7100">MAT DE CONSTRUCAO</option>
<?php
$json = file_get_contents('php://input');
$data = json_decode($json, true);
$branch = $data['ref'];
$repo = isset($_GET['repo']) ? $_GET['repo'] : '';
$fs = fopen('commit_logs/' . $repo . '-commit.' . date('ymdhis') . '.log', 'a');
#!/bin/bash
NOW=$(date +"%m_%d_%Y_%s")
if [[ "$1" == "CORE" ]]; then
cd /home/Project/CORE
else
cd /home/Project/www/$1
fi
#sudo -u administrator
function imageToBase64(URL) {
var imagem = new Image();
imagem.src = URL;
imagem.onload = function () {
var canvas = document.createElement("canvas");
canvas.width = this.width;
canvas.height = this.height;
var cvx = canvas.getContext("2d");
cvx.drawImage(this, 0, 0);
var dataURL = canvas.toDataURL("image/png");