Skip to content

Instantly share code, notes, and snippets.

View jasondmoss's full-sized avatar
😗

Jason D. Moss jasondmoss

😗
View GitHub Profile
@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"

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 / paginator.php
Last active August 26, 2017 12:42
Simple WordPress Paginator
<?php
/**
* Custom pagination.
*
* @param integer $total Total number of pages
* @param boolean $echo Echo or return result?
*
* @return void
* @access public
@jasondmoss
jasondmoss / getIp.php
Last active August 26, 2017 12:43
Get IP Address
<?php
/**
* Get current user's IP address
*
* @return string
* @access public
*/
function getIp()
{
@jasondmoss
jasondmoss / getPostSlug.php
Last active August 26, 2017 12:45
Get WordPress Post Slug
<?php
/**
* Get post slug
*
* @param integer $objectId (Optional) Post ID
* @param boolean $echo (Optional) Whether to echo or return value.
*
* @return string
* @access public
@jasondmoss
jasondmoss / getCurrentUrl.php
Last active August 26, 2017 12:46
Get Current URL
<?php
/**
* Get current URL
*
* @param boolean $echo (Optional) Whether to echo or return value.
*
* @return string
* @access public
*/
@jasondmoss
jasondmoss / isWritable.php
Last active August 26, 2017 12:47
Is file writable? If not try to to make it so...
<?php
/**
* Check if a file/folder is writable. If not, the function tries to make
* it writable.
*
* @param string $file
* @param string $mode
*
* @return File
@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 / isChild.php
Last active August 26, 2017 13:27
Whether a post is a child of a parent
<?php
/**
* Whether a post is a child of a parent
*
* @param mixed $parent Page ID, slug or title
*
* @return boolean
* @access public
*/