Skip to content

Instantly share code, notes, and snippets.

View mflorida's full-sized avatar
🛹
Shredding

Mark M. Florida mflorida

🛹
Shredding
View GitHub Profile
@mflorida
mflorida / jquery.hasClasses.js
Created March 16, 2015 19:45
jQuery.hasClasses() plugin
/*!
* jQuery.hasClasses plugin
*
* Check if an element has ALL classes
* or ANY of a number of classes
*
* usage:
* $('#el-id').hasClasses('foo || bar') <- has EITHER 'foo' or 'bar'
* $('#el-id').hasClasses('|| foo bar') <- has EITHER 'foo' or 'bar'
* $('#el-id').hasClasses('any: foo bar') <- has EITHER 'foo' or 'bar'
@mflorida
mflorida / globals.js
Last active February 24, 2016 21:10
globals.js file used in XNAT
/*!
* Global general-purpose JavaScript convenience
* utlity helper functions (verbosity intentional)
*
* Some of these functions are taken straight from
* other libraries and put in the global scope here.
* Is that a good idea? Maybe, maybe not.
*/
// Avoid console errors in browsers that lack a console.
@mflorida
mflorida / xnat17dev.custom.yaml
Last active January 6, 2016 00:50
Customizations to download XNAT 1.7 via FTP
# save this to 'xnat_vagrant/configs/xnat17dev' and rename 'custom.yaml'
# make sure 'revision' is set to '1.7' for the setup script
revision: '1.7'
# use an archive of XNAT 1.7 from the NRG FTP server
xnat_src: 'ftp://ftp.nrg.wustl.edu/pub/xnat/nrg-xnat_builder_1_7dev-94504f3c6496.tar.gz'
@mflorida
mflorida / umd-templates.js
Last active February 11, 2024 22:40
Templates for UMD patterns
/**
* UMD pattern with anonymous function expression
*/
(function(){
var umd = function(factory){
if (typeof exports === 'object') {
return module.exports = factory();
}
else if (typeof define === 'function' && define.amd) {
@mflorida
mflorida / parse-args.sh
Created July 19, 2017 02:02
Parse shell script arguments - accepted in any order but executed in a specific order.
#!/usr/bin/env bash
# This script will iterate through the arguments passed to it and collect
# a list of commands and variables to execute in a specified order.
# Example usage:
# ===================================================================================
# ./parse-args.sh -ktdbyr --name=foo
# ...or...
# ./parse-args.sh --name=foo --backup --reset --delete --build --deploy --restart
@mflorida
mflorida / parse-args-vars.sh
Created July 20, 2017 12:57
Parse shell script arguments but use variables instead of a 'command' string - accepted in any order but executed in a specific order.
#!/usr/bin/env bash
# This script will iterate through the arguments passed to it and collect
# a list of commands and variables to execute in a specified order.
# It differs from the 'parse-args.sh' script in that it sets variables
# instead of building up a string of commands.
# Example usage:
# ===================================================================================
# ./parse-args-vars.sh -ktdbyr --name=foo
@mflorida
mflorida / pattern-matching.sh
Last active October 6, 2022 17:07 — forked from Error601/pattern-matching.sh
Bash string removal pattern matching samples
#!/bin/bash
# file path example
FILE=/home/user/src.dir/prog.c
echo ${FILE#/*/} # ==> user/src.dir/prog.c -- remove everything BEFORE the SECOND '/'
echo ${FILE##*/} # ==> prog.c -- remove part BEFORE LAST '/'
echo ${FILE%/*} # ==> /home/user/src.dir -- remove everything AFTER the LAST '/'
echo ${FILE%%/*} # ==> nil -- remove everything AFTER the FIRST '/' (returns empty string)
echo ${FILE%.c} # ==> /home/user/src.dir/prog -- remove everything AFTER '.c'
@mflorida
mflorida / parse-args-ez.sh
Last active August 30, 2017 03:15
Specify script arguments in any order and execute in a specific order.
#!/usr/bin/env bash
# This script will parse the arguments passed to it
# and execute commands in a specified order.
# Example usage:
# ===================================================================================
# ./parse-args-ez.sh -ktdbyr --name=foo
# ...or...
# ./parse-args-ez.sh --name=foo --backup --reset --delete --build --deploy --restart
@mflorida
mflorida / file_list.rb
Last active September 5, 2017 22:17
Create JSON and/or YAML representation of a directory tree.
#!/usr/bin/env ruby
require 'yaml'
require 'json'
# arguments: start_dir output_filename file_format
# dir=./ name=file-list.json skip=.vagrant,.work
$args_obj = {}
@mflorida
mflorida / fileList.groovy
Last active September 6, 2017 23:08
Create a JSON file representating a directory tree.
#!/usr/bin/env groovy
import groovy.json.*
// set to current directory if not specified as the first argument
def startPath = args.length >= 1 ? args[0] : '.'
// rewrite startPath to current directory if necessary
if ((startPath =~ /^(\.|\.\/)$/).matches()) {
startPath = '../' + (new File(new File(startPath).canonicalPath)).name