Skip to content

Instantly share code, notes, and snippets.

🌠

Kevin Chappell kevinchappell

🌠
Block or report user

Report or block kevinchappell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kevinchappell
kevinchappell / get_user_data.php
Last active Jul 30, 2019
Get all User data in WordPress
View get_user_data.php
<?php
/**
* Get an array of all user data
* @param string|int $user_id
* @return array merged array of user meta and data
*/
function get_user_data( $user_id ){
$user_data = (array) get_userdata( $user_id )->data;
$user_meta = array_map( function( $item ){ return $item[0]; }, (array) get_user_meta( $user_id ) );
return array_merge( $user_data, $user_meta );
@kevinchappell
kevinchappell / .bash_profile
Created Jul 2, 2015
parse_git_branch() in terminal
View .bash_profile
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
PS1='${debian_chroot:+($debian_chroot)}\[\033[1;31m\]\u\[\033[1;37m\]@\[\033[1;32m\]\h\[\033[1;37m\]:\[\033[1;36m\]\w \[\033[1;35m\]$(parse_git_branch) \[\033[1;33m\]\$ \[\033[0m\]'
@kevinchappell
kevinchappell / clamav.cron
Created Dec 6, 2015
cPanel ClamAV Cron Job
View clamav.cron
#!/bin/sh
for i in `awk '!/nobody/{print $2 | "sort | uniq" }' /etc/userdomains | sort | uniq`; do
SUBJECT="VIRUS SCAN ${i}"
EMAIL="youremail@yourdomain.com"
# Log location
LOG="/var/log/clamav/${i}-scan.log"
# Quarantine location
@kevinchappell
kevinchappell / getPercent.test.js
Last active Feb 27, 2019
Perforance test between for loop and reduce
View getPercent.test.js
const labels = Array.from({ length: 1000000 }, (v, k) => ({isVerified: Math.random() >= 0.6}))
function getAcceptedPercent1(labels) {
let acceptedCount = 0
const total = labels.length
for (let index = 0; index < total; index++) {
acceptedCount += labels[index].isVerified
}
return Math.round(acceptedCount / total * 100)
View track.js
/**
* Track class
*/
// configure the class for runtime loading
if (!window.fbControls) window.fbControls = []
window.fbControls.push(function(controlClass) {
/**
* Track class
*/
View flattenArray.js
/**
* recursively flatten a nested array
* @param {Array} arr to be flattened
* @return {Array} flattened array
*/
const flattenArray = arr =>
arr.reduce(
(acc, val) => acc.concat(Array.isArray(val) ? flattenArray(val) : val),
[]
);
View throttle.js
/**
* Throttle class provides and easy way for binding
* and throttling events. Helpful for events like window
* scroll that are fired often.
*/
export class Throttle {
/**
* Add an event and register callbacks
* @param {String} event
* @param {Function} cb
View webpack.config.js
const pkg = require('./package.json');
const {resolve} = require('path');
const {BannerPlugin} = require('webpack');
const CompressionPlugin = require('compression-webpack-plugin');
const BabiliPlugin = require('babili-webpack-plugin');
const PRODUCTION = process.argv.includes('-p');
const bannerTemplate = [
`${pkg.name} - ${pkg.homepage}`,
@kevinchappell
kevinchappell / fizzBuzz.js
Created Feb 17, 2017
Configurable FizzBuzz
View fizzBuzz.js
// Tired of seeing if else if else if else in fizzbuzz exercise I created
// this configurable FizzBuzz that uses only one if statement.
// https://jsfiddle.net/kevinchappell/44jrznbj/
/**
* Configurable fizzBuzz
* @param {Object} args
* @param {Number} until number of iterations
* @return {String} output
*/
You can’t perform that action at this time.