Skip to content

Instantly share code, notes, and snippets.

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
MM_preloadImages('img1.gif','img2.gif'); //add more if required
@plugn
plugn / index.md
Created January 28, 2020 06:07 — forked from ericandrewlewis/index.md
C++ Pointer Tutorial

C++ Pointer Tutorial

Because pointers can be ugh

"Regular" variables (not pointers)

To understand a pointer, let's review "regular" variables first. If you're familiar with a programming language without pointers like JavaScript, this is what you think when you hear "variable".

When declaring a variable by identifier (or name), the variable is synonymous with its value.

qsa = (q, c) => Array.from((c || document).querySelectorAll(q))
qs = (q, c) => (c || document).querySelector(q)
swgr = {
injected: false,
rules: `
.opblock .checked:after {
content: '✓';
font-size: 24px;
var leet = {
/**
* Map of conversions.
*
* @var object
*/
characterMap: {
'a': '4',
'b': '8',
@plugn
plugn / copyMR.js
Last active January 17, 2020 09:41
function copyMRDev() {
const confirmMR = () => {
const txt = document.querySelector('.mr-source-target .normal > strong').textContent.replace(/[\s]+/g, ' ').trim()
const url = location.href.replace(/\/diffs\/?/, '')
const msg = txt.replace('Request to merge ', 'MR\n').replace('into', '->')
return [msg, url].join('\n')
}
const writeToClipboard = (txt) => {
const range = (min, max) => Array.from(Array(max - min + 1).keys()).map(v => v + min)
const fizzBuzz = (max, min = 1) =>
range(min, max)
.reduce((acc, num) =>
[...acc, ((num % 3 ? '' : 'Fizz') + (num % 5 ? '' : 'Buzz') || num)],
[])
.join(', ')
// fizzBuzz(18)

shadowspawn John Gee 1 февр. 2019 I expect that when you reinstalled node and npm, the ownership of the installed files in /usr/local was set to root so you no longer have permission to make changes.

To allow you to do npm global installs to /usr/local without needing sudo (as recommended) you can just claim ownership of the relevant folders.

sudo chown -R $(whoami) /usr/local/lib /usr/local/bin Then you can ran the install without using sudo:

@plugn
plugn / sortObject.example.js
Last active April 24, 2020 14:01
Object deep sort by keys
var sample = {
el: {
upload: 'Upload file',
filterPopover: {
apply: 'Apply'
},
rightholdersItem: {
cardInterestedParty: 'Interested Party',
documents: 'Documents',
catalog: 'Catalogue'
@plugn
plugn / index.html
Last active January 19, 2020 22:06
flex layout with text overflow in ellipsis mode. header// source https://jsbin.com/tupifec
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>header</title>
<style id="jsbin-css">
.flex-row {
display: flex;
flex-direction: row;
poem = `my awesome poem`
result = poem.replace(/\n+/g, '\n\n')