Skip to content

Instantly share code, notes, and snippets.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Input extends CI_Input {
/**
* Variables
*
*/
protected $delete;
<?php
function pr($var) { echo '<pre>' .print_r($var, true). '</pre>'; }
$array = array(
(object) array('title'=>'a','ordering'=>2),
(object) array('title'=>'x','ordering'=>0),
(object) array('title'=>'r','ordering'=>4),
(object) array('title'=>'b','ordering'=>21),
(object) array('title'=>'b1','ordering'=>21),
(object) array('title'=>'q','ordering'=>6),
(object) array('title'=>'o','ordering'=>7),
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Session extends CI_Session{
private $sess_use_redis = TRUE;
private $redis = '';
public function __construct($params = array()) {
//parent::__construct();
$this->CI =& get_instance();
@phplaw
phplaw / PhpStorm_CI_autocomplete.php
Last active August 29, 2015 14:07
Setting CI Autocomplete for PhpStorm 8
<?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
@phplaw
phplaw / backbonejs_todo.md
Last active August 29, 2015 14:08
Backbonejs Todo Example.

todos.js

// An example Backbone application contributed by
// [Jérôme Gravel-Niquet](http://jgn.me/). This demo uses a simple
// [LocalStorage adapter](backbone-localstorage.html)
// to persist Backbone models within your browser.

// Load the application once the DOM is ready, using `jQuery.ready`:
$(function(){
- Defining a field
- hook_field_info()
- hook_field_schema()
- hook_field_validate()
- hook_field_is_empty()
- Defining a formatter for the field (the portion that outputs the field for display)
- hook_field_formatter_info()
- hook_field_formatter_view()
- Defining a widget for the edit form
- hook_field_widget_info()
@phplaw
phplaw / heredoc.php
Created November 13, 2014 03:28
PHP Tips & Tricks
<?php
$mystring = <<<EOT
This is some PHP text.
It is completely free
I can use "double quotes"
and 'single quotes',
plus $variables too, which will
be properly converted to their values,
you can even type EOT, as long as it
is not alone on a line, like this:
@phplaw
phplaw / CI_Loader_helper.php
Created February 2, 2015 10:18
CI Loader Helper
<?php
public function helper($helpers = array())
{
foreach ($this->_ci_prep_filename($helpers, '_helper') as $helper)
{
if (isset($this->_ci_helpers[$helper]))
{
continue;
}
<?php
function time2str($ts) {
if(!ctype_digit($ts)) {
$ts = strtotime($ts);
}
$diff = time() - $ts;
if($diff == 0) {
return 'now';
} elseif($diff > 0) {
$day_diff = floor($diff / 86400);
@phplaw
phplaw / angularjs_directive_attribute_explanation.md
Created March 6, 2017 03:21 — forked from CMCDragonkai/angularjs_directive_attribute_explanation.md
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>