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 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();
- 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()
<?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>
@phplaw
phplaw / ng-repeat-complete.htm
Created April 12, 2018 11:26 — forked from bennadel/ng-repeat-complete.htm
Hooking Into The Complete Event Of An ngRepeat Loop In AngularJS
<!doctype html>
<html ng-app="Demo">
<head>
<meta charset="utf-8" />
<title>
Hooking Into The ngRepeat Completion Event In AngularJS
</title>
<style type="text/css">
@phplaw
phplaw / use $compile outside a directive in Angularjs
Last active July 10, 2018 11:46 — forked from shengoo/use $compile outside a directive in Angularjs
use $compile outside a directive in Angularjs
$(function() {
// myApp for test directive to work, ng for $compile
var $injector = angular.injector(['ng', 'myApp']);
$injector.invoke(function($rootScope, $compile) {
$('body').prepend($compile('<div ng-attr-tooltip="test">Cancel</div>')($rootScope));
});
});
/**
@phplaw
phplaw / domains.md
Created August 13, 2018 12:33
Node Error Handling and Domains

Node Error Handling and Domains

"Occurrences in this domain are beyond the reach of exact prediction because of the variety of factors in operation, not because of any lack of order in nature." - Albert Einstein

"Master of my domain" - Larry David

Error handling in an asynchronous language works in a unique way and presents many challenges, some unexpected. This tutorial reviews the various error handling patterns available in node, and explains how domains can be used to improve it.

There are four main error handling patterns in node:

  • Error return value
@phplaw
phplaw / .bash_profile
Created August 21, 2018 03:46 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@phplaw
phplaw / doubleclick.js
Created September 10, 2018 22:42 — forked from mauriciosoares/doubleclick.js
rxjs double click example
let clickStream = Rx.Observable.fromEvent(document.getElementById('link'), 'click');
clickStream
.buffer(clickStream.debounce(250))
.map(list => list.length)
.filter(x => x === 2)
.subscribe(() => {
console.log('doubleclick');
})