Skip to content

Instantly share code, notes, and snippets.

View mpmont's full-sized avatar

Marco Monteiro mpmont

View GitHub Profile
@mpmont
mpmont / full_url_helper.php
Created September 28, 2012 10:01
always save the query string at the end of file
/**
* Return the entire current url including querystring
*
* @author Jeroen v.d. Gulik
*/
function full_url()
{
return current_url() . get_querystring();
}
@mpmont
mpmont / app-controllers-home2.php
Created September 25, 2012 18:31 — forked from dshoreman/app-config-blade.php
Custom loader class for CodeIgniter that implements Laravel's Blade templating engine
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home extends CI_Controller {
public function index()
{
$this->view = false;
echo $this->load->blade('home.index');
}
}
@mpmont
mpmont / MY_controller.php
Created September 25, 2012 13:22
Loading blade views automatically
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Controller extends CI_Controller {
public $data = array();
public $view;
public function __construct() {
parent::__construct();
$this->view = ($this->view !== null) ? $this->view : $this->router->directory . $this->router->class . '/' . $this->router->method;
@mpmont
mpmont / CI_ide_helper.php
Created September 20, 2012 18:26 — forked from autokludge/CI_ide_helper.php
Code Completion helper for CodeIgniter
<?php die('This file is not really here!');
/**
* ------------- DO NOT UPLOAD THIS FILE TO LIVE SERVER ---------------------
*
* Implements code completion for CodeIgniter in phpStorm
* phpStorm indexes all class constructs, so if this file is in the project it will be loaded.
* -------------------------------------------------------------------
* Drop the following file into a CI project in phpStorm
* You can put it in the project root and phpStorm will load it.
@mpmont
mpmont / example.blade.php
Created September 5, 2012 15:22
blade template system example
@if ( $message == 'success' )
It was a success!
@elseif ( $message == 'error' )
An error occurred.
@else
Did it work?
@endif
@foreach ($comments as $comment)
The comment body is {{ $comment->body }}.
@mpmont
mpmont / database.php
Created September 4, 2012 14:25
double connection codeigniter
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'username';
$db['default']['password'] = 'password';
$db['default']['database'] = 'myDatabase';
$db['default']['dbdriver'] = 'mysql';
@mpmont
mpmont / pagination.php
Created August 23, 2012 20:07
codeigniter pagination params
protected $base_url = ''; // The page we are linking to
protected $prefix = ''; // A custom prefix added to the path.
protected $suffix = ''; // A custom suffix added to the path.
protected $total_rows = 0; // Total number of items (database results)
protected $per_page = 10; // Max number of items you want shown per page
protected $num_links = 2; // Number of "digit" links to show before/after the currently viewed page
protected $cur_page = 0; // The current page being viewed
protected $use_page_numbers = FALSE; // Use page number for segment instead of offset
protected $first_link = '&lsaquo; First';
protected $next_link = '&gt;';
// CONTROLLER
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Controllername extends CI_Controller {
public function index()
{
if (!empty($_POST)) {
@mpmont
mpmont / app.js
Created April 26, 2012 13:30
todos da mesma altura
var maxHeight = 0;
$(".waa3").each(function(){
maxHeight = $(this).height() > maxHeight ? $(this).height() : maxHeight;
}).height(maxHeight);​
@mpmont
mpmont / config.json
Created April 25, 2012 13:30
sublime text 2 config
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"draw_white_space": "all",
"file_exclude_patterns":
[
"*.pyc",
"*.pyo",
"*.exe",
"*.dll",
"*.obj",