Skip to content

Instantly share code, notes, and snippets.

@jasny
jasny / bootstrap-em.less
Last active January 5, 2020 15:36
Use em or rem font-size in Bootstrap 3
/**
* Use em or rem font-size in Bootstrap 3
*/
@font-size-root: 14px;
@font-unit: 0rem; // Pick em or rem here
// Convert all variables to em
@kris-ellery
kris-ellery / JS-error-tracking-with-GA.js
Last active November 18, 2021 19:00
Track JavaScript errors using Universal Analytics from Google.
/**
* Track JS error details in Universal Analytics
*/
function trackJavaScriptError(e) {
var errMsg = e.message;
var errSrc = e.filename + ': ' + e.lineno;
ga('send', 'event', 'JavaScript Error', errMsg, errSrc, { 'nonInteraction': 1 });
}
@justindujardin
justindujardin / complexRequireDirective.js
Last active May 26, 2018 16:16
AngularJS Directive require ancestor AND this controller
var app = angular.module('yourApp');
app.directive("parentDirective", function(){
return {
restrict: "A",
controller:function(){
this.test = function(){
console.log("parentController - okay");
}
}
};
@ohryan
ohryan / responsive-align.less
Last active April 30, 2019 17:27
Bootstrap 3 Responsive Text Align
.text-xs-left { text-align: left; }
.text-xs-right { text-align: right; }
.text-xs-center { text-align: center; }
.text-xs-justify { text-align: justify; }
@media (min-width: @screen-sm-min) {
.text-sm-left { text-align: left; }
.text-sm-right { text-align: right; }
.text-sm-center { text-align: center; }
.text-sm-justify { text-align: justify; }
// 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() {
@addyosmani
addyosmani / package.json
Last active May 29, 2024 15:54
npm run-scripts boilerplate
{
"name": "my-app",
"version": "1.0.0",
"description": "My test app",
"main": "src/js/index.js",
"scripts": {
"jshint:dist": "jshint src/js/*.js",
"jshint": "npm run jshint:dist",
"jscs": "jscs src/*.js",
"browserify": "browserify -s Validating -o ./dist/js/build.js ./lib/index.js",
@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
@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>
@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();