miniscripts Profile Banner
MiniScripts Profile
MiniScripts

@miniscripts

Followers
305
Following
1
Media
12
Statuses
95

Bite-sized scripts for everyday use. Tweets will largely cover front-end development technologies: HTML, CSS, and JavaScript. Managed by @jonathansampson

Joined January 2014
Don't wanna be here? Send us removal request.
@rauschma
Axel Rauschmayer (also on 🦣)
6 years
function shallowEqual(obj1, obj2) { const keys1 = Object.keys(obj1); if (keys1.length !== Object.keys(obj2).length) return false; for (const k1 of keys1) { if (! (k1 in obj2)) return false; if (obj1[k1] !== obj2[k1]) return false; } return true; }
10
3
34
@anatudor
Ana Tudor 🐯 (find me on Bluesky/ Mastodon)
6 years
HEX to RGB in a tweet let hex = '#​c71585'; let rgb = `rgb(${hex.match(/[0-9a-f]{2}/gi).map(c => parseInt(c, 16)).join()})`; #js
5
41
199
@miniscripts
MiniScripts
8 years
Both Alt and Ctrl keys on your keyboard produce character 65, so how can you tell which is which? The KeyboardEvent.location property tells you the location of the key on your keyboard: 1 means left, and 2 means right (0 for keys with no ambiguity).
0
0
3
@miniscripts
MiniScripts
8 years
Need to pad your strings? Now you can with padStart and padEnd. You can even provide a pad character: › "Hello".padStart(10) ‹ " Hello" › "Hello".padEnd(10) ‹ "Hello " › "Hello".padEnd(10, ".") ‹ "Hello....."
0
1
4
@BraveSampson
Sampson
9 years
Now in @brave: Search GitHub, MDN, Stack Overflow from the address bar: :gh brave :m spread :s reactjs {'🦁':'Developers'.repeat(3)+'!'}
4
16
12
@miniscripts
MiniScripts
9 years
Curious which version of http-server you have installed? Easy! Run from project directory w/o -g for local modules. npm list http-server -g
0
1
0
@miniscripts
MiniScripts
10 years
Speak to me, Browser. var a = "Hello, friend."; speechSynthesis.speak( new SpeechSynthesisUtterance(a) ); Edge 14, Firefox 49, Chrome 33
0
7
14
@miniscripts
MiniScripts
10 years
Speak to me, Browser. var a = "Hello, friend."; speechSynthesis.speak( new SpeechSynthesisUtterance(a) ); Edge 14, Firefox 49, Chrome 33
0
7
14
@miniscripts
MiniScripts
10 years
Notification.requestPermission().then( p => p[0] == "g" && new Notification( "Smile", { icon: "ico.png", body: "🙂" } ) ); #Notifications
0
1
1
@ericelliott_
Eric Elliott
10 years
ES6 array of numbers: const range = (start, end) => ( Array.from({ length: end - start + 1 }, (x, i) => i + start) ); #JavaScript #es6
9
56
147
@miniscripts
MiniScripts
10 years
Chaining handlebars Helpers: {{ encodeURI ( join values '|' ) }}
0
1
0
@miniscripts
MiniScripts
10 years
The window.getComputedStyle method works for both elements, and pseudo elements: getComputedStyle( el ) getComputedStyle( el, "::before" );
0
1
2
@miniscripts
MiniScripts
10 years
let debounce; win.addEventListener('scroll', () => { clearTimeout(debounce); debounce = setTimeout( () => { /*logic*/ }, 100); });
0
0
2
@jonathansampson
Sampson
10 years
Unicode code point escape syntax, recently added in JavaScript 2015, also found its way into PHP 7. This makes me very happy. \u{2661} ♡
0
1
2
@miniscripts
MiniScripts
10 years
An option element's end tag may be omitted if the element is followed by another option, optgroup, or no more content in the parent element.
1
1
2
@miniscripts
MiniScripts
10 years
4.10.8 The datalist element <input list="fam"> <datalist id="fam"> <option>Luke <option>Vader </datalist>
1
5
6
@miniscripts
MiniScripts
10 years
Trying to convert RGB values to HEX? You can do so quickly in the console of your @f12devtools: 185..toString(16); // b9
0
1
0
@miniscripts
MiniScripts
10 years
When gradients are leveraged as solid background images, the angle value can be omitted. linear-gradient( blue, blue );
1
0
0
@miniscripts
MiniScripts
10 years
Angles can be "deg" (360 in a circle), "grad" (400 in a circle), "rad" (2π in a circle), or "turn" (1 in a circle).
0
0
0
@miniscripts
MiniScripts
10 years
Planning on using linear-gradient? While Chrome and Edge implicitly understand 0 to mean 0deg, Firefox and IE do not. Don't cut corners.
3
3
6