Skip to content

Instantly share code, notes, and snippets.

@marlun78
marlun78 / Intercept.js
Last active August 29, 2015 14:08
Simple meta-programming for methods
/**
* Intercept.js
* Simple meta-programming for methods
* Copyright (c) 2014 marlun78
* MIT License, https://gist.github.com/marlun78/bd0800cf5e8053ba9f83
*
* The intercept-function provides a pre and a post hook that
* will run before and after the original implementation
* respectively. In the pre-hook you have access to the
* arguments passed, and in the post-hook you have access to
@rjgotten
rjgotten / foreach.less
Last active August 29, 2015 14:15
Using detached rulesets as lambda delegates without scoping issues; in reply to: https://gist.github.com/seven-phases-max/5280eacdf3d591f35163
// @mixin
// Loops over all items in the specified list and for each item executes
// a special `.\\` mixin declared by the specified ruleset. The ruleset
// and mixin combination is used to emulate a lambda function delegate.
// @param {List} list
// The list over which to loop.
// @param {Ruleset} lambda
// A ruleset that may define the `.\\` mixin that is used to process the
// individual list items. The mixin should correspond to the
// following signature:
.each(@list, @ruleset) {
@plugin "plugins/lambda";
@length : length(@list);
._iterate(1);
._iterate(@index) when (@index =< @length) {
@item : extract(@list, @index);
@lambda : lambda(@item, @index, item index, @ruleset);
@lambda();
@raldred
raldred / TweenMax.SVGJSPlugin.js
Last active December 30, 2015 03:28
svg.js plugin for TweenMax, heavily based on the Raphael plugin.
/*!
* VERSION: 0.0.1
* DATE: 2013-12-03
*
* @description: Plugin to manipulate transform properties of SVGJS objects, heavily based on the RaphaelPlugin
*
* @author: Rob Aldred, raldred@gmail.com
*/
(window._gsQueue || (window._gsQueue = [])).push( function() {
@jclem
jclem / base.js
Last active February 28, 2016 16:06
Base Bookshelf Model
'use strict';
const _ = require('lodash');
module.exports = bookshelf => {
return bookshelf.Model.extend({
hasTimestamps: true,
initialize() {
this.on('saving', this.beforeSave);
@joladev
joladev / state.js
Last active April 18, 2016 13:28
Simple AngularJS State Service for sharing state between controllers.
angular.module('services', [])
.factory('State', function ($rootScope) {
'use strict';
var state;
var broadcast = function (state) {
$rootScope.$broadcast('State.Update', state);
};
var update = function (newState) {
@wilsonpage
wilsonpage / umd-module.js
Last active August 19, 2016 13:18
UMD (amd, common.js, window)
;(function(define){define(function(require,exports,module){
//...
});})(typeof define=='function'&&define.amd?define
:(function(n,w){'use strict';return typeof module=='object'?function(c){
c(require,exports,module);}:function(c){var m={exports:{}};c(function(n){
return w[n];},m.exports,m);w[n]=m.exports;};})('module-name',this));
@bisubus
bisubus / .htaccess
Last active November 4, 2016 06:40
Yii 2 Advanced Application Template on virtual hosting
Options -Indexes
<IfModule !mod_rewrite.c>
Deny from all
</IfModule>
<IfModule mod_rewrite.c>
// Forked from: https://gist.github.com/melbourne2991/8822609
//
// Below is an example of a directive that let's other directives know when there has been a change
// in a breakpoint, as well as a windows resize, the event is triggered on the window resize and
// broadcast on $rootScope. The arguments contain the current & previous breakpoints. Previous will
// be null if there is yet to be a change in breakpoint.
//
app.directive('bsBreakpoint', function($window, $rootScope, $timeout) {
return {
controller: function() {
@RubaXa
RubaXa / Promise.js
Last active September 16, 2017 18:17
«Promise.js» — is supported as a native interface and $.Deferred.
/**
* @author RubaXa <trash@rubaxa.org>
* @license MIT
*/
(function () {
"use strict";
function _then(promise, method, callback) {
return function () {