Skip to content

Instantly share code, notes, and snippets.

View andreasvirkus's full-sized avatar
🙊
made you look

andreas andreasvirkus

🙊
made you look
View GitHub Profile
export const ordinal = (num) => {
const suffix = ['th', 'st', 'nd', 'rd']
const value = val % 100
return val + (suffix[(value - 20) % 10] || suffix[value] || suffix[0])
}
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);
# 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
SELECT table_schema
AS "Database", SUM(data_length + index_length) / 1024 / 1024
AS "Size (MB)"
FROM information_schema.TABLES
GROUP BY table_schema;
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")'
# Prune all log files whose modified time is older than 6 days
find /var/log -mindepth 1 -mtime +5 -delete
@andreasvirkus
andreasvirkus / background-pattern.svg
Last active November 2, 2020 16:07
background-pattern.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
for f in cis-*; do mv "$f" "CL${f#cis-}"; done
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
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