Skip to content

Instantly share code, notes, and snippets.


andreas andreasvirkus

Block or report user

Report or block andreasvirkus

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
andreasvirkus / array.js
Created Oct 11, 2019
A collection of utility functions to manipulate arrays
View array.js
* Uses the Durstenfeld shuffle algorithm,
* a modern optimized version of the Fisher-Yates
* (aka Knuth) shuffle.
* @param {Array} Array to shuffle
* @return {Array} Shuffled array
View consoleGreeting.js
console.log('%c 👋 Salutations, hax0r.\nFeel free to look around. FYI, you\'ll have a better view of the code over at GitHub: \n', 'background: #223; color: #bada55');
View promisify.js
// Needs spread operator (... notation)
export const promisify = (fn) => {
return (...args) => {
return new Promise((resolve, reject) => {
fn(...args, (err, res) => {
if (err) return reject(err)
return resolve(res)
View password.js
* Medium-strength regex checks if the password contains 2 of:
* - lowercase alphabetical char
* - uppercase alphabetical char
* - numerical character
* - minimum of 6 characters
* Strong-strength regex checks if the password contains all of:
* - lowercase alphabetical char
* - uppercase alphabetical char
View webpackChunks.js
// See an excellent explanation over at
optimization: {
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
maxInitialRequests: Infinity,
// Default is 30kB, let's set it to 5kB
minSize: 5000,
cacheGroups: {

Extension reloader

This will watch a Chrome extension's file directory, compile a hash based on the file names and date and reload the extension/add-on when the directory undergoes changes.

Compatible with Webpack and any other type of build setup! 📦


Add the script to your extension's manifest.json

View index.html
<p>Photos by <a href="">random photographers</a> on <a href="">Unsplash</a></p>
<img lazy data-src="">
<img lazy data-src="">
<img lazy data-src="">
<img lazy data-src="">
View minimalJquery.js
// Minimal jQuery
const $$ = document.querySelectorAll.bind(document);
const $ = document.querySelector.bind(document);
View firstAncestor.js
const firstAncestor = (el, tagName) => {
while(el = el.parentNode && (el.tagName !== tagName.toUpperCase()))
return el
// Usage
var child = document.getElementById('child')
firstAncestor(child, 'div'); //<div id="parent">
View getPackageVersion.json
"name": "ver-extractor",
"description": "Get the version from your package.json",
"scripts": {
"get-version": "node -pe \"require('./package.json').version\""
You can’t perform that action at this time.