Skip to content

Instantly share code, notes, and snippets.

View MauMaGau's full-sized avatar

Dave Townsend MauMaGau

View GitHub Profile
@MauMaGau
MauMaGau / 0_reuse_code.js
Last active August 29, 2015 14:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@MauMaGau
MauMaGau / gist:7927864
Last active August 17, 2016 13:48
Laravel BaseModel
<?php
class BaseModel extends Eloquent
{
protected $rules = [];
protected $messages = [];
protected $errors;
public function validate(array $rules = [])
{
@MauMaGau
MauMaGau / gist:7873463
Last active December 30, 2015 19:19
Laravel Illuminate Schema : add method to updateColumn
<?php
## Migration ##
Schema::table('users', function(Blueprint $table)
{
$table->updateColumn('username', 'string')->length(250)->nullable();
});
## \Illuminate\Support\Database\Schema\Blueprint.php ##
/**
@MauMaGau
MauMaGau / gist:7872725
Created December 9, 2013 14:07
Laravel Illuminate Schema : Modify nullable
**Migration code**
<?php
Schema::table('users', function(Blueprint $table)
{
$table->setNullable('username', true);
});
**\Illuminate\Database\Schema\Blueprint**
<?php
public function setNullable($column_name, $setNullable=true)
@MauMaGau
MauMaGau / gist:7516561
Created November 17, 2013 18:37
Laravel view structure
// Controller
public function layout()
{
$tasks = array('hai');
$data = array(
'tasks' => $tasks,
);
return View::make('site_templates.default')
->nest('page_template','tasks.all', $data);
}
@MauMaGau
MauMaGau / gist:6522680
Created September 11, 2013 12:10
Sublime user preferences
{
"auto_complete_commit_on_tab": true,
"bold_folder_labels": false,
"color_scheme": "Packages/Color Scheme - Default/iPlastic.tmTheme",
"default_line_ending": "unix",
"detect_indentation": true,
"drag_text": false,
"font_size": 11.0,
"highlight_line": true,
"highlight_modified_tabs": false,
@MauMaGau
MauMaGau / gist:6522679
Created September 11, 2013 12:09
Sublime key map
[
{ "keys": ["ctrl+shift+c"], "command": "unexpand_tabs", "args": { "set_translate_tabs": false } },
{ "keys": ["ctrl+shift+x"], "command": "expand_tabs", "args": { "set_translate_tabs": false } },
{ "keys": ["ctrl+shift+alt+z"], "command": "run_macro_file", "args": {"file": "Packages/User/FixIndentation.sublime-macro"}},
{ "keys": ["f2"], "command": "next_bookmark" },
{ "keys": ["shift+f2"], "command": "prev_bookmark" },
{ "keys": ["ctrl+shift+f2"], "command": "toggle_bookmark" },
@MauMaGau
MauMaGau / gist:5714446
Created June 5, 2013 14:51
Sublime CI module controller snippet
<snippet>
<content><![CDATA[
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class $1_module extends MX_Controller {
private \$called_from_url = FALSE;
public function __construct()
{
@MauMaGau
MauMaGau / gist:5714431
Last active December 18, 2015 02:58
Sublime CI model snippet
<snippet>
<content><![CDATA[
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class $1_model extends ${2:CI}_Model {
public function get_by_id(\$$1_id)
{
\$query = \$this->db
->from('$1')
@MauMaGau
MauMaGau / gist:5411772
Created April 18, 2013 10:35
CI MODEL SNIPPET
<snippet>
<content><![CDATA[
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class $1_model extends ${2:CI}_Model {
public function get_by_id(\$$1_id)
{
\$query = \$this->db
->from('$1')