Skip to content

Instantly share code, notes, and snippets.

View hewerthomn's full-sized avatar
👨‍💻
Coding...

Éverton Inocêncio hewerthomn

👨‍💻
Coding...
View GitHub Profile
@hewerthomn
hewerthomn / install_postgresql9.3_postgis2.1_ubuntu.md
Last active October 19, 2020 09:02
Installing PostgreSQL 9.3 and PostGIS on Ubuntu 14.04

Remove old PostGIS Installation

The first step is to remove older version of PostGIS if any.

sudo apt-get purge postgis

Setup repository

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
/*
* This decorates Handlebars.js with the ability to load
* templates from an external source, with light caching.
*
* To render a template, pass a closure that will receive the
* template as a function parameter, eg,
* T.render('templateName', function(t) {
* $('#somediv').html( t() );
* });
* Source: https://github.com/wycats/handlebars.js/issues/82
@hewerthomn
hewerthomn / AppController.php
Created May 9, 2013 20:28
exemplo de chamada do plugin Acl + Auth
<?php
/**
* arquivo AppController.php
*/
public $components = array(
/* outros componentes chamados aqui */
'Acl',
'Auth' => array(
'authError' => 'O usuário não tem permissão para acessar essa ação',
@hewerthomn
hewerthomn / acl.php
Created May 9, 2013 20:24
exemplo de arquivo app/Config/acl.php
/**
* The role map defines how to resolve the user record from your application
* to the roles you defined in the roles configuration.
*/
$config['map'] = array(
'Pessoa' => 'Pessoa/cpf', // username login field
'Perfil' => 'Pessoa/perfil_id', // user role field
);
/**
@hewerthomn
hewerthomn / routes.php
Created April 28, 2013 15:55
exemplo de routing do cakephp
// adicionar no arquivo routes.php
Router::connect('/noticia/:id/:title',
array('controller' => 'posts', 'action' => 'view'),
array('pass' => array('id'), 'title' => '[a-z0-9-#]+','id' => '[0-9]+')
);
@hewerthomn
hewerthomn / DuinoClient.ino
Last active December 16, 2015 11:38
Arduino com Ethernet Shield WizNet W5100 que acessa uma página na Internet e escreve os valores obtidos num display LCD de 16x2.
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return Poul-Henning Kamp
* ----------------------------------------------------------------------------
*/
/*
* DuinoClient
@hewerthomn
hewerthomn / index.php
Created April 21, 2013 04:54
Página php que acessa API da wunderground e escreve a cidade, pais, umidade, temperatura e hora atual. Exemplo: <Porto Velho/RO|89% 23C|10:39>
<?php
/**
* API Index
*/
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
$service = $_GET['s'];
date_default_timezone_set('America/Porto_Velho');
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php
@hewerthomn
hewerthomn / Resource.class.php
Created May 8, 2012 10:34
Arquivo de exemplo de classe abstrata Resource
<?php
abstract class Resource
{
protected static $httpMethods = array("GET", "POST", "HEAD",
"PUT", "OPTIONS", "DELETE", "TRACE", "CONNECT");
protected $params;
public function __construct(array $params) {
$this->params = $params;