Skip to content

Instantly share code, notes, and snippets.

View jlamim's full-sized avatar
👨‍💻
Working and having fun

Jonathan Lamim jlamim

👨‍💻
Working and having fun
View GitHub Profile
<?php
/**
* Given a string containing any combination of YouTube and Vimeo video URLs in
* a variety of formats (iframe, shortened, etc), each separated by a line break,
* parse the video string and determine it's valid embeddable URL for usage in
* popular JavaScript lightbox plugins.
*
* In addition, this handler grabs both the maximize size and thumbnail versions
* of video images for your general consumption. In the case of Vimeo, you must
* have the ability to make remote calls using file_get_contents(), which may be
@jlamim
jlamim / .htaccess
Created November 16, 2015 00:08
CodeIgniter htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
@jlamim
jlamim / crud-database.sql
Created April 15, 2016 23:39
Instrução SQL para criação da tabela de contatos do tutorial sobre CRUD com CodeIgniter
CREATE TABLE IF NOT EXISTS `contatos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
@jlamim
jlamim / routes.php
Created April 15, 2016 23:40
Rotas - Criando um CRUD com CodeIgniter
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$route['default_controller'] = 'Base';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['salvar'] = "Base/Salvar";
$route['editar/(:num)'] = "Base/Editar/$1";
$route['atualizar'] = "Base/Atualizar";
@jlamim
jlamim / autoload.php
Created April 15, 2016 23:41
Libraries, helper e model - Criando um CRUD com CodeIgniter
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$autoload['packages'] = array();
$autoload['libraries'] = array('database','session','form_validation');
$autoload['drivers'] = array();
$autoload['helper'] = array('url');
$autoload['config'] = array();
$autoload['language'] = array();
$autoload['model'] = array('contatos_model');
@jlamim
jlamim / database.php
Created April 15, 2016 23:46
Configuração do banco de dados - Criando um CRUD com CodeIgniter
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'host',
'username' => 'usuario',
@jlamim
jlamim / home.php
Created April 15, 2016 23:49
View Home - Criando um CRUD com CodeIgniter
<div>
<div>
<h1>Criando um CRUD com CodeIgniter</h1>
</div>
<?php if ($this->session->flashdata('error') == TRUE): ?>
<p><?php echo $this->session->flashdata('error'); ?></p>
<?php endif; ?>
<?php if ($this->session->flashdata('success') == TRUE): ?>
<p><?php echo $this->session->flashdata('success'); ?></p>
<?php endif; ?>
@jlamim
jlamim / editar.php
Created April 15, 2016 23:53
View Editar - Criando um CRUD com CodeIgniter
<div>
<h1>Criando um CRUD com CodeIgniter</h1>
</div>
<?php if ($this->session->flashdata('error') == TRUE): ?>
<p><?php echo $this->session->flashdata('error'); ?></p>
<?php endif; ?>
<?php if ($this->session->flashdata('success') == TRUE): ?>
<p><?php echo $this->session->flashdata('success'); ?></p>
<?php endif; ?>
@jlamim
jlamim / MY_Model.php
Created April 16, 2016 00:03
MY_Model - Criando um CRUD com CodeIgniter
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class MY_Model extends CI_Model {
// Variável que define o nome da tabela
var $table = "";
/**
* Método Construtor
@jlamim
jlamim / Contatos_model.php
Created April 16, 2016 00:04
Contatos_model - Criando um CRUD com CodeIgniter
<?php
class Contatos_model extends MY_Model {
function __construct() {
parent::__construct();
$this->table = 'contatos';
}
/**