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 / mergeObjects.js
Last active April 30, 2023 08:20 — forked from Error601/mergeObjects.js
Merge/Extend Objects in native JS
/*!
* Replace some functionality of jQuery's $.extend() method
* with only native JavaScript. Unlike $.extend(), this
* function will ONLY merge plain objects (not arrays).
* https://gist.github.com/Error601/9a181a0b9f414b752c38
*/
function isObject( obj ){
return Object.prototype.toString.call(obj) === '[object Object]';
@mflorida
mflorida / hipster-filler.js
Created April 1, 2022 18:48 — forked from Error601/hipster-filler.js
Hipster filler text generator.
/*!
* Hipster filler text generator.
* Inspired by (and words taken from):
* http://hipsum.co/
*
* Usage:
*
* // sentences only
* APP.utils.hipster.sentence(); // generates 1 sentence with 9, 12, or 18 words
* APP.utils.hipster.sentences(3); // generates 3 sentences
@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'