Skip to content

Instantly share code, notes, and snippets.

View kevinchappell's full-sized avatar
🌠

Kevin Chappell kevinchappell

🌠
View GitHub Profile
@kevinchappell
kevinchappell / .bash_profile
Created July 2, 2015 21:40
parse_git_branch() in terminal
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 / swagger-v-Redocly.md
Created April 27, 2023 01:19
Swagger vs Redocly

Swagger

Overview

Swagger is a set of open-source tools built around the OpenAPI Specification that can help you design, build, document and consume REST APIs. The major Swagger tools include:

  • Swagger Editor - browser-based editor where you can write OpenAPI definitions.
  • Swagger UI - renders OpenAPI definitions as interactive documentation.
  • Swagger Codegen - generates server stubs and client libraries from an OpenAPI definition.
parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
echo "(${BRANCH}${STAT})"
else
echo ""
fi
@kevinchappell
kevinchappell / screenpad-reinstall.sh
Created October 22, 2021 13:46
screenpad-reinstall.sh
#!/bin/sh
#remove asus-wmi module
sudo dkms remove -m asus-wmi -v 1.0 --all
sudo rm -r /usr/src/asus-wmi-1.0
# install asus-wmi module
sudo mkdir /usr/src/asus-wmi-1.0
cd /usr/src/asus-wmi-1.0
sudo wget 'https://github.com/Plippo/asus-wmi-screenpad/archive/master.zip'
<?php
/**
* Super simple class for logging. Generates regular logs and csv files
* @package lightLogger
* @author Kevin Chappell <kevin.b.chappell@gmail.com>
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
* @since lightLogger .5
*/
/**
@kevinchappell
kevinchappell / get_user_data.php
Last active June 14, 2021 04:07
Get all User data in WordPress
<?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 / emp_grid.rb
Created October 13, 2020 21:03
EMP Grid Challenge
# safe? should return true or false if the absolute coordinate digit sum is a multiple of 3
def safe?(x,y)
# [true, false].sample
# ([x, y].map(&:abs).to_s.chars.map(&:to_i).sum) % 3 == 0
(x.abs + y.abs) % 3 == 0
end
def fill_cell(x, y)
safe?(x,y) ? '■ ' : '□ '
end
@kevinchappell
kevinchappell / clamav.cron
Created December 6, 2015 15:21
cPanel ClamAV Cron Job
#!/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 February 27, 2019 19:44
Perforance test between for loop and reduce
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)