Skip to content

Instantly share code, notes, and snippets.

Samar Panda samarpanda

Block or report user

Report or block samarpanda

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
@samarpanda
samarpanda / readme.md
Created Nov 20, 2019
Improve modern code generation
View readme.md
  1. Javascript optimization
{
  "presets": [
    ["@babel/preset-env", {
      "targets": {
        "esmodules": true
      }
    }]
@samarpanda
samarpanda / semantic-versioning-using-npm.md
Last active Nov 15, 2019
Semantic versioning using npm
View semantic-versioning-using-npm.md

#Semantic versioning using npm

Upating node package version with npm update rules are as below

  1. ^ if you write ^0.13.0 when running npm update it can update to patch and minor releases: 0.13.1, 0.14.0 and so on.
  2. ~ if you write ~0.13.0, when running npm update it can update to patch releases: 0.13.1 is ok, but 0.14.0 is not.
  3. > you accept any version higher than the one you specify
  4. >= you accept any version equal to or higher than the one you specify
  5. <= you accept any version equal or lower to the one you specify
  6. < you accept any version lower to the one you specify
  7. = you accept that exact version
@samarpanda
samarpanda / Update-with-upstream-source.md
Created Nov 4, 2019
Keeping update with upstream source
View Update-with-upstream-source.md

Keeping update with upstream source

  1. git remote add upstream <url_to_origin>
  2. git remote -v
  3. git fetch upstream
  4. git checkout master
  5. git merge upstream/master
  6. git push origin master
@samarpanda
samarpanda / after-chrome-74.js
Last active Sep 27, 2019
Anti-incognito detection in google chrome
View after-chrome-74.js
//Credit - https://mishravikas.com/articles/2019-07/bypassing-anti-incognito-detection-google-chrome.html
if("storage" in navigator && 'estimate' in navigator.storage){
const {usage, quota} = await navigator.storage.estimate();
console.log(`Using ${usage} out of ${quota} bytes.`);
if(quota < 120000000){
console.log("Incognito")
} else {
console.log('Not Incognito')
}
} else {
@samarpanda
samarpanda / cls.js
Last active Jul 23, 2019
Measuring cumulative layout shift score
View cls.js
let cumulativeLayoutShiftScore = 0;
const observer = new PerformanceObserver((list) => {
for(const entry of list.getEntries()){
cumulativeLayoutShiftScore += entry.value;
}
});
observer.observe({entryTypes: ['layoutShift']});
View Quick-Commands.md

Quick commands

  1. Validating gzip encryption supported by the webserver
curl -k -H "Accept-Encoding: gzip" -I http://example.com/

-k, --insecure Ignoring insecure request or ssl doesn't required to be validated -H Add request headers

@samarpanda
samarpanda / readme.md
Created Jul 5, 2019
Server Load testing using apache benchmark(ab)
View readme.md

Apache Benchmark

ab -n 50 -c 10 -H "Accept-Encoding: gzip,deflate" https://example.com

-n for number of requests -c concurrent request -H Pass any specific headers

@samarpanda
samarpanda / README.md
Last active May 23, 2019
Device state detection with css media queries and javascript
View README.md
View Custom-Metric.md

Custom Metric using Element Timing Origin Trial

bit.ly/element-timing-origin-trial

Time To First Cat(TTFC)

Calculate time to first cat(TTFC) HTML

<img src="best_cat.jpg" elementtiming>
You can’t perform that action at this time.