Skip to content

Instantly share code, notes, and snippets.

View arcticmouse's full-sized avatar

arcticmouse

View GitHub Profile
<?php
/**
* Convert a comma separated file into an associated array.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
* @return array
@arcticmouse
arcticmouse / scroll-back-to-top.js
Created February 24, 2017 23:54
Jquery floating scroll back to top of page button
//scroll back to the top of screen button
if ($('#back-to-top').length) {
var scrollTrigger = 100, // px
backToTop = function () {
var scrollTop = $(window).scrollTop();
if (scrollTop > scrollTrigger) {
$('#back-to-top').addClass('show');
} else {
$('#back-to-top').removeClass('show');
}
@arcticmouse
arcticmouse / gist:567e27dec2f9274f68667fcb06a05036
Created August 3, 2017 21:37
Wordpress Check for Featured Image : no more phantom images from has_post_thumbnail
$featured_image_url = wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) );
if ( ! empty( $featured_image_url ) ) {
@arcticmouse
arcticmouse / gist:44227a8a53197a5e89b44c55c5021d47
Last active September 11, 2017 23:12
Recursively search directory in terminal for duplicate files
find . -type f | sed 's/^.*\/\([^/]*\)$/\1/' | sort | uniq -c | grep -v '^ 1'
IFS=$'\n'; for f in `find . -type f | sed 's/^.*\/\([^/]*\)$/\1/' | sort | uniq -c | grep -v '^ 1'`; do echo $f; t=`echo "$f" | awk '{print $2}'`; find . -name $t; echo $'\n'; done
IFS=$'\n'
dupes=`find . -type f |
sed 's/^.*\/\([^/]*\)$/\1/' |
sort |
@arcticmouse
arcticmouse / gist:0f30f88cf5f32a4e9755c24c7ef3ec8a
Created November 22, 2017 17:29
regex(php) match url (ftp/http/https)
(((ftp|https?):\/\/)(www\.)?|www\.)([\da-z-_\.]+)([a-z\.]{2,7})([\/\w\.-_\?\&]*)*\/?
grep -rnw '/path/to/somewhere/' -e 'pattern'
@arcticmouse
arcticmouse / gist:8c97d5b14759488ae0deb6c36a084019
Created February 16, 2018 20:28
WP add user through database
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('newadmin', MD5('pass123'), 'firstname lastname', 'email@example.com', '0');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');
@arcticmouse
arcticmouse / README-Template.md
Created April 6, 2018 23:56 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

error_log( print_r($multidimensionalarray, TRUE) );