Skip to content

Instantly share code, notes, and snippets.

View justinmc's full-sized avatar

Justin McCandless justinmc

View GitHub Profile
@weblancaster
weblancaster / gist:6e7f43fc02725ce747e224b0c4290906
Last active May 25, 2020 12:53
Kill all container, remove all images and stop all containers
#stop all containers:
docker kill $(docker ps -q)
#remove all containers
docker rm $(docker ps -a -q)
#remove all docker images
docker rmi $(docker images -q)
@luvaas
luvaas / addClass, removeClass, and hasClass shims
Last active March 15, 2016 05:11
Jquery extensions that add missing addClass, removeClass, and hasClass shims for SVG elements
//addClass shim for SVG
var originalAddClass = $.fn.addClass;
$.fn.addClass = function(value) {
var orig = originalAddClass.apply(this, arguments);
if(!value) return orig;
for (var i=0; i<this.length; i++ ) {
var elem = this[ i ];
@justinmc
justinmc / sharing.js
Created October 13, 2014 01:08
A simple example of how to share code between the front and back ends. This file could be run in either environment and work in both, without code duplication.
var config = {
version: '3.1.4'
};
// Frontend
if (window) {
window.config = config;
// Backend
} else if (typeof module !== 'undefined' && module.exports) {
@hlissner
hlissner / replace.sh
Last active September 11, 2023 10:14
Bulk search & replace with ag (the_silver_searcher)
# ag <https://github.com/ggreer/the_silver_searcher>
# usage: ag-replace.sh [search] [replace]
# caveats: will choke if either arguments contain a forward slash
# notes: will back up changed files to *.bak files
ag -0 -l $1 | xargs -0 perl -pi.bak -e "s/$1/$2/g"
# or if you prefer sed's regex syntax:
ag -0 -l $1 | xargs -0 sed -ri.bak -e "s/$1/$2/g"
@justinmc
justinmc / anchor_smooth_scroll.js
Last active May 14, 2019 19:52
Anchor Smooth Scroll - Angular Directive
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Anchor Smooth Scroll - Smooth scroll to the given anchor on click
* adapted from this stackoverflow answer: http://stackoverflow.com/a/21918502/257494
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
angular.module('yourapp').directive('anchorSmoothScroll', function($location) {
'use strict';
return {
restrict: 'A',
replace: false,
@justindujardin
justindujardin / zigzagmixin.less
Created April 7, 2014 21:14
LESS ZigZag Border
/*
border-serrated - a zig zag triangle border with linear gradient
original SASS version: https://gist.github.com/justinmc/9837998
*/
.border-top-serrated(@size, @colorOuter) {
& {
position: relative;
padding-top: @size;
}
&:before {
@justinmc
justinmc / gist:9837998
Last active February 2, 2019 21:14
SASS Zigzag Border
/* border-serrated - a zig zag triangle border with linear gradient
*/
@mixin border-top-serrated($size, $color-outer) {
& {
position: relative;
overflow: auto;
padding-top: $size;
}
&:before {
top: 0px;
@justinmc
justinmc / gist:9149719
Last active October 15, 2018 18:05
Sample Gulpfile
var gulp = require('gulp');
var clean = require('gulp-clean');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var bases = {
app: 'app/',
@justinmc
justinmc / svgclass.js
Last active August 5, 2018 15:05 — forked from shshaw/svgclass.js
(function($){
/* addClass shim
****************************************************/
var addClass = $.fn.addClass;
$.fn.addClass = function(value) {
var orig = addClass.apply(this, arguments);
var elem,
i = 0,
@shshaw
shshaw / svgclass.js
Last active January 3, 2016 22:19
Modifies Add/Remove class for jQuery to work with SVG elements.
(function($){
var addClass = $.fn.addClass;
$.fn.addClass = function(value) {
var orig = addClass.apply(this, arguments);
var elem,
i = 0,
len = this.length;
for (; i < len; i++ ) {