Skip to content

Instantly share code, notes, and snippets.

View ar5had's full-sized avatar
🎯
Focusing

Arshad Khan ar5had

🎯
Focusing
View GitHub Profile
@ar5had
ar5had / RandomColorGenerator
Last active December 3, 2016 16:23
Random Color Generator
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
@ar5had
ar5had / hex-opacity-values.txt
Created January 3, 2017 10:45 — forked from frankyonnetti/CSS--hex-opacity-values.css
#css Hex Opacity Values
Hex Opacity Values
100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6

Parens And Performance

Years ago, some smart folks that worked on JS engines realized that not all JS that's loaded into a page/app initially is needed right away. They implemented JIT to optimize this situation.

JIT means Just-In-Time, which means essentially that the engine can defer processing (parsing, compiling) certain parts of a JS program until a later time, for example when the function in question is actually needed. This deferral means the engine is freer to spend the important cycles right now on the code that's going to run right now. This is a really good thing for JS performance.

Some time later, some JS engine devs realized that they needed to get some hints from the code as to which functions would run right away, and which ones wouldn't. In technical speak, these hints are called heuristics.

So they realized that one very common pattern for knowing that a function was going to run right away is if the first character before the function keyword was a (, because that usually m

Keybase proof

I hereby claim:

  • I am arshdkhn1 on github.
  • I am arshdkhn1 (https://keybase.io/arshdkhn1) on keybase.
  • I have a public key ASBWaziczjSQHUbAQzWKWrLU1er2gvrX45TAYHZ2ye9ZUAo

To claim this, I am signing this object:

@ar5had
ar5had / deepCopy.js
Created March 11, 2017 13:32 — forked from azurite/deepCopy.js
Quick and dirty way to deep copy json objects in javascript (object prototypes are not copied)
function isNull(v) {
return typeof v === "object" && !v;
}
function isPrimitive(v) {
return ["number", "string", "boolean", "undefined"].indexOf(typeof v) !== -1 || isNull(v);
}
function isPlainObject(o) {
return o && typeof o === "object" && o.constructor === Object;
@ar5had
ar5had / whatsappAutoMsgSender.js
Last active March 18, 2017 13:32
Open chat in web whatsapp then open console and paste this code in console terminal and hit enter.
setInterval(function(){
if(document.querySelector(".icon.icon-smiley.btn-emoji") != null)
document.querySelector(".icon.icon-smiley.btn-emoji").click();
document.querySelector(".emojik.emojiordered1200").click();
document.querySelector(".icon.btn-icon.icon-send.send-container").click();
}, 500);
arshad@asd:~/Documents/gr/comm-central$ ./mozilla/mach build
0:01.21 /usr/bin/make -f client.mk -s
0:01.55 Adding client.mk options from /home/arshad/Documents/gr/comm-central/mozconfig:
0:01.55 FOUND_MOZCONFIG := /home/arshad/Documents/gr/comm-central/mozconfig
0:10.53 make[2]: Circular /home/arshad/Documents/gr/comm-central/mozilla/CLOBBER <- /home/arshad/Documents/gr/comm-central/mozilla/CLOBBER dependency dropped.
0:10.59 make[3]: Circular /home/arshad/Documents/gr/comm-central/mozilla/CLOBBER <- /home/arshad/Documents/gr/comm-central/mozilla/CLOBBER dependency dropped.
0:10.76 Elapsed: 0.00s; From dist/public: Kept 0 existing; Added/updated 0; Removed 0 files and 0 directories.
0:10.78 Elapsed: 0.02s; From dist/private: Kept 0 existing; Added/updated 0; Removed 0 files and 0 directories.
0:10.97 Elapsed: 0.10s; From dist/xpi-stage: Kept 15 existing; Added/updated 0; Removed 2 files and 0 directories.
0:21.03 Elapsed: 10.28s; From dist/idl: Kept 1333 existing; Added/updated 0; Removed 0 files
// state = { len: 2, arr: [1,2] };
const newState = Object.assign({}, state);
// for simplicity sake
newState.arr = [3, 4];
this.setState({state: newState});
// or