This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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), | |
[] | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Track class | |
*/ | |
// configure the class for runtime loading | |
if (!window.fbControls) window.fbControls = [] | |
window.fbControls.push(function(controlClass) { | |
/** | |
* Track class | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
*/ | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |