Skip to content

Instantly share code, notes, and snippets.

View alexmccabe's full-sized avatar

Alex McCabe alexmccabe

View GitHub Profile
anonymous
anonymous / CategoryRepository.php
Created February 25, 2016 10:55
tree without recursion
function buildTree($data, $parentID = 0) {
// build a tree using references and not recursion
$references = array();
$tree = array();
foreach ($data as $id=> &$node) {
// Use id as key to make a references to the tree and initialize it with node reference.
$references[$node['id']] = &$node;
@cferdinandi
cferdinandi / umd-script-boilerplate.js
Last active December 10, 2023 10:23
A simple boilerplate for UMD JS modules.
(function (root, factory) {
if ( typeof define === 'function' && define.amd ) {
define([], factory(root));
} else if ( typeof exports === 'object' ) {
module.exports = factory(root);
} else {
root.myPlugin = factory(root);
}
})(typeof global !== "undefined" ? global : this.window || this.global, function (root) {
@mitchkramez
mitchkramez / gist:9144426
Created February 21, 2014 22:01
SublimeLinter - PHPLint Configuration
{
"user": {
"debug": true,
"delay": 1,
"error_color": "D02000",
"gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
"gutter_theme_excludes": [],
"lint_mode": "background",
"linters": {
"php": {
@emaildano
emaildano / flexslider-progress-bar.html
Created January 21, 2014 21:07
Progress bar add on for FlexSlider
<div class="progress_bar_container">
<div class="progress_bar"></div>
</div>
@jslegers
jslegers / style.scss
Created July 26, 2013 13:24
A CodePen by Hugo Giraudel. Sass mixin for scrollbar styling - Because I can't ever remember the right syntax for scrollbars styling in WebKit, here is a little Sass mixin to do it for you.
@import "compass";
/**
* Mixin scrollbar
*/
@mixin scrollbar($size, $primary, $secondary: lighten($primary, 25%)) {
::-webkit-scrollbar {
width: $size;
height: $size;
}
@terkel
terkel / _decimal.scss
Last active November 23, 2023 18:36
Rounding decimals in Sass
// _decimal.scss | MIT License | gist.github.com/terkel/4373420
// Round a number to specified digits.
//
// @param {Number} $number A number to round
// @param {Number} [$digits:0] Digits to output
// @param {String} [$mode:round] (round|ceil|floor) How to round a number
// @return {Number} A rounded number
// @example
// decimal-round(0.333) => 0
@paulirish
paulirish / rAF.js
Last active March 22, 2024 00:00
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];