Skip to content

Instantly share code, notes, and snippets.

View CMCDragonkai's full-sized avatar
🚀
Lightspeed

CMCDragonkai

🚀
Lightspeed
View GitHub Profile
@CMCDragonkai
CMCDragonkai / Truncate.Filter.js
Created August 18, 2013 20:46
JS: AngularJS Truncate Filter for Words and Characters. Adapted from https://github.com/sparkalow/angular-truncate
define(['angular'], function(angular){
'use strict';
/**
* Truncates characters or words. Truncate characters by default does not truncates on a word.
*/
angular.module('Filters')
.filter('TruncateCharacters', [
function(){
@CMCDragonkai
CMCDragonkai / DebouncedFunction.Service.js
Created August 20, 2013 10:50
JS: AngularJS Debounced Function Factory. Relies on $timeout.
/**
* This creates a trailing debounced function. The callback will only be executed at the end
* of the specified delay. Repeated calls to the debounced function will cancel the previous
* call, and restart the delay. This is perfect for form inputs that you only want to act upon
* after the user stops entering characters.
* @param {Function} callback Callback to be executed when there is no more repeated calls to
* the debounced function and when the delay has counted down
* @param {Integer} delay Delay in milliseconds. This delay will be refreshed each time
* there is a repeated call to the throttled function
* @return {Function} Debounced function
@CMCDragonkai
CMCDragonkai / ArrayDifference.Service.js
Last active December 21, 2015 08:39
JS: Array Difference for Primitive or Object Arrays. Returns the difference. Relies on lodash.
define(['angular', 'lodash'], function(angular, _){
'use strict';
angular.module('Services')
.service('ArrayDifferenceServ', [
function(){
/**
* Compares and returns the difference between arrays based on their values.
@CMCDragonkai
CMCDragonkai / angularjs_directive_attribute_explanation.md
Last active November 29, 2023 15:35
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>
@CMCDragonkai
CMCDragonkai / UrlFriendly.Filter.js
Created August 21, 2013 06:36
JS: Angular Url Friendly Filter. Can be used to create url friendly permalinks from blog titles. Port of url_title in Codeigniter.
define(['angular'], function(angular){
'use strict';
angular.module('Filters')
.filter('UrlFriendly', [
function(){
return function(text, separator, lowercase){
var output,
@CMCDragonkai
CMCDragonkai / minimum_fixed_height_sidebar.less
Created September 10, 2013 13:10
CSS: Minimum Fixed Height Sidebar. This sidebar will stretch to the height of the viewport even if the content doesn't push it down, and yet when the content pushes down, the sidebar will also stretch its height with it. Great for sidebars that need to be sticky/affixed and also occupy all of the viewport.
html{
position: relative; //relative is required to contain the absolute sidebar
min-height: 100%; //minimum height make sure that if the content is below 100% of viewport, it will still allow the sidebar to be at 100%, and if the content is greater than 100% of viewport, it will allow stretching
}
.content{
float: left;
width: 70%;
height: 1000px; //example height, you can increase and decrease this height to see it work
}
@CMCDragonkai
CMCDragonkai / php.ini
Last active December 22, 2015 19:49
PHP: Xdebug Settings For Debugging
xdebug.var_display_max_depth = -1
xdebug.var_display_max_children = -1
xdebug.var_display_max_data = -1
@CMCDragonkai
CMCDragonkai / Disqus.Directive.js
Last active December 23, 2015 00:39
JS: AngularJS Disqus Comments & Comment Count Directive
define(['angular'], function(angular){
'use strict';
//TODO:
//1. Convert to JSONP
//2. Use a cache shim like store.js
/*
<div
@CMCDragonkai
CMCDragonkai / AddThis.Directive.js
Created September 26, 2013 07:44
JS: Add This Directive
define(['angular', 'addthis'], function(angular, addthis){
'use strict';
/**
* Implements an addthis button on the element. Works with dynamically produced elements.
* You can provide addThisConfig and addThisShare as JSON or evaluated objects to configure the buttons
*/
angular.module('Directives')
.directive('addThisDir', [
@CMCDragonkai
CMCDragonkai / DecoratorAbstract.php
Last active June 23, 2019 22:58
PHP: DecoratorAbstract - Allows the creation of flexible nested decorators.
<?php
/**
* DecoratorAbstract allows the creation of flexible nested decorators. All decorators must extend from DecoratorAbstract.
* Decorators can be stacked. They can also have methods that overwrite each other.
* Decorators can omit methods that parent decorators have defined and/or child decorators have defined.
* Methods will cascade to the original child object.
* Properties will read and set from the original child object except when your instance has the property defined.
*/
abstract class DecoratorAbstract{