Skip to content

Instantly share code, notes, and snippets.

View pranabmitra's full-sized avatar

Pranab Mitra pranabmitra

  • Tokyo, Japan
View GitHub Profile
@pranabmitra
pranabmitra / dom_performance_reflow_repaint.md
Created July 28, 2020 02:17 — forked from faressoft/dom_performance_reflow_repaint.md
DOM Performance (Reflow & Repaint) (Summary)

DOM Performance

Rendering

  • How the browser renders the document
    • Receives the data (bytes) from the server.
    • Parses and converts into tokens (<, TagName, Attribute, AttributeValue, >).
    • Turns tokens into nodes.
    • Turns nodes into the DOM tree.
  • Builds CSSOM tree from the css rules.
@pranabmitra
pranabmitra / scrollToRN.js
Last active December 23, 2018 15:55
Scroll To in React Native
import React from 'react';
import { StyleSheet, Text, View, ScrollView, Button, Dimensions } from 'react-native';
const { width, height } = Dimensions.get('window');
let footerY;
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
/* 5 Photos */
<View style={{ width: width, height: width / 2}}>
<View style = {{ flex: 1, flexDirection: 'row', height: '100%', width: '100%',paddingVertical: 20, paddingHorizontal: 20, borderRadius: 30}}>
<View style={{ flex: 1, borderTopLeftRadius: 30, borderBottomLeftRadius: 30, overflow: 'hidden'}}>
<Image
style = {{ flex: 1, height: '100%', width: '100%', resizeMode: 'stretch' }}
source={require('./assets/scenery-1.jpg')}
/>
</View>
<View style={{ flex: 1, flexDirection: 'column', height: '100%', width: '100%'}}>
@pranabmitra
pranabmitra / transit_response_getter.js
Last active November 15, 2018 22:51
Get necessary Transit details information from direction API
const formattedRespose = (leg) => {
let result = {},
legInfo = leg || response.routes[0].legs[0],
basicInfo = {},
resultantSteps = [],
lastStep = {},
nextPointInfo = {};
basicInfo = {
startAddress: legInfo.start_address,
@pranabmitra
pranabmitra / latlondelta.js
Created November 4, 2018 09:15
Latitude and Longitude Delta
let { width, height } = Dimensions.get('window');
const ASPECT_RATIO = width / height;
const LATITUDE = 0;
const LONGITUDE = 0;
const LATITUDE_DELTA = 0.0922;
const LONGITUDE_DELTA = LATITUDE_DELTA * ASPECT_RATIO;
/* Component */
constructor() {
super();
const repl = require('repl');
repl.start({ prompt: '> ', eval: myEvalFunc, writer: outputFunc});
function myEvalFunc(cmd, context, filename, callback) {
callback(null, 'Hello!!');
}
function outputFunc(output) {
return output;
}
@pranabmitra
pranabmitra / config
Created September 22, 2018 11:45
A sample config
/** ~/.ssh/config **/
Host dev
HostName 10*.19*.**.2**
Port 22
User user
IdentityFile ~/.ssh/id_rsa
Host live
HostName 10*.19*.**.2
@pranabmitra
pranabmitra / canvas-rendering.js
Last active August 1, 2018 11:48
Canvas Rendering
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Canvas rendering</title>
</head>
<body>
@pranabmitra
pranabmitra / node-chat-server.js
Last active July 21, 2018 11:33
Simple Node Chat Server
const server = require('net').createServer();
let counter = 0,
sockets = {};
function getTimestamp() {
const now = new Date();
return `${now.getHours()}:${now.getMinutes()}`;
}
server.on('connection', socket => {
@pranabmitra
pranabmitra / node_installation
Created December 15, 2017 18:50
Node and NPM installation command
For updating npm:
sudo npm install npm@latest -g
For updating node:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Download current: