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
export const ordinal = (num) => { | |
const suffix = ['th', 'st', 'nd', 'rd'] | |
const value = val % 100 | |
return val + (suffix[(value - 20) % 10] || suffix[value] || suffix[0]) | |
} |
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 prettier = require("prettier"); | |
const pluginName = "HandleChunkLoadFailurePlugin"; | |
/** | |
* This Webpack plugin calls `window._chunkHandler.handleVersionChange()` when loading a chunk fails | |
*/ | |
class HandleChunkLoadFailurePlugin { | |
constructor(options = {}) { | |
this.options = Object.assign({}, options); |
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
# Command to check access count per unique IP | |
tail -n 10000 /var/log/apache2/access.log | awk '{print $1}'| sort| uniq -c| sort -nr| head -n 10 | |
# Command to check access per unique pathname | |
awk {'print $7'} /var/log/apache2/access.log | sort -nk1 | uniq -c | less |
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
SELECT table_schema | |
AS "Database", SUM(data_length + index_length) / 1024 / 1024 | |
AS "Size (MB)" | |
FROM information_schema.TABLES | |
GROUP BY table_schema; |
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
import crypto from 'crypto' | |
const generateChecksum = str => | |
crypto | |
.createHash('sha256') | |
.update(str, 'utf8') | |
.digest('base64') | |
const script = | |
'if (localStorage.getItem("theme")) document.documentElement.dataset.theme = localStorage.getItem("theme")' |
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
# Prune all log files whose modified time is older than 6 days | |
find /var/log -mindepth 1 -mtime +5 -delete |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
for f in cis-*; do mv "$f" "CL${f#cis-}"; done |
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
export const timeSinceNow = (timestamp) => { | |
const current = new Date() | |
const previous = new Date(timestamp * 1000) | |
const msPerMinute = 60 * 1000 | |
const msPerHour = msPerMinute * 60 | |
const msPerDay = msPerHour * 24 | |
const msPerMonth = msPerDay * 30 | |
const msPerYear = msPerDay * 365 | |
const elapsed = current - previous |
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
brew install docker docker-machine$ brew cask install virtualbox | |
docker-machine create --driver virtualbox default | |
docker-machine env default | |
eval "$(docker-machine env default)" | |
docker run hello-world | |
docker-machine stop default |