Skip to content

Instantly share code, notes, and snippets.

View jasondmoss's full-sized avatar
😗

Jason D. Moss jasondmoss

😗
View GitHub Profile
@jasondmoss
jasondmoss / MergeArrays.js
Last active August 26, 2017 13:12
Concatenate individual arrays into single array for easier manipulation.
/**
* Concatenate individual arrays into single array for easier manipulation.
*
* @param {Array} Individual arrays; as many as required.
*
* @returns {Array} Concatenated array.
*/
function mergeArrays()
{
return [].concat.apply([], arguments);
@jasondmoss
jasondmoss / ScrollShrink.js
Last active November 22, 2019 03:17
Add a class to site header when the page scrolls below marker. Remove the class when the page scrolls above marker.
/**
* Add a class to site header when the page scrolls below marker. Remove the
* class when the page scrolls above marker.
*/
// jshint esversion: 6
window.addEventListener("scroll", event => {
"use strict";
@jasondmoss
jasondmoss / createElementWithAttr.js
Last active November 22, 2019 03:15
Create a new element with provided attributes.
/**
* Create a new element with provided attributes.
*
* @param {String} name Element name.
* @param {Object|Array} attrs Element attributes.
*
* @return {Object} Element
*/
// jshint esversion: 6
@jasondmoss
jasondmoss / turtle.js
Last active November 22, 2019 03:22
Hide the header while scolling the page down; Show on scroll up or when the bottom of the page is reached.
/**
* Hide the header while scolling the page down; Show on scroll up or when the
* bottom of the page is reached.
*/
// jshint esversion: 6
(function (document, window, index) {
"use strict";
const element = document.querySelector("#myHeaderElement");
@jasondmoss
jasondmoss / screen-reader-style.css
Last active December 10, 2019 03:59 — forked from ffoodd/improved-sr-only.markdown
Text meant only for screen readers
.reader,
.sr-only,
.text-assistive {
clip: rect(0 0 0 0);
overflow: hidden;
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;

Keybase proof

I hereby claim:

  • I am jasondmoss on github.
  • I am jasondmoss (https://keybase.io/jasondmoss) on keybase.
  • I have a public key ASBlMWKxMIlj9MvXXxjG0FXSg4nsYECnDAMHYLQPA5BZMgo

To claim this, I am signing this object:

@jasondmoss
jasondmoss / ajax-cache-include.js
Last active November 17, 2018 06:12
jQuery: Load external scripts and cache them.
/**
* Cache AJAX-included scripts.
*/
$.cachedScript = function (url, options) {
options = $.extend(
options || {}, {
dataType: "script",
cache: true,
url: url
}
@jasondmoss
jasondmoss / redirection.php
Last active August 29, 2015 13:55
Redirect to new location.
<?php
/**
* Browser Redirection.
*
* @param string $url Redirect destination.
* @param integer $code Redirect code.
*
* Codes:
*
@jasondmoss
jasondmoss / renameExt.sh
Last active December 27, 2015 17:49
Bash: Rename the extensions of a group of files in a directory.
###
## Rename file extensions
##
## EG. renameExt old new
###
function renameExt() {
for file in *.$1
do
mv -- "$file" "$(expr "$file" : '\(.*\)\.'$1).$2"
@jasondmoss
jasondmoss / blankRename.sh
Last active December 21, 2017 15:47
Bash: Replace blank spaces with underscore for file(s) in current directory.
###
## Replace blank spaces with underscore for file(s) in current directory
###
function blankRename() {
ONE=1 # For getting singular/plural right
number=0 # Keeps track of how many files actually renamed
FOUND=0 # Successful return value
# Traverse all files in directory