Skip to content

Instantly share code, notes, and snippets.

View sriramrudraraju's full-sized avatar

Sriram Rudraraju sriramrudraraju

  • Bentonville, AR
View GitHub Profile
@sriramrudraraju
sriramrudraraju / variable-hoisting.md
Created January 24, 2019 20:12
Javascript: Variable Hoisting

Variable hoisting

let a = 1;
const b = 2;
var c = 3;
function x() {};

Execution context - Creation phase

@sriramrudraraju
sriramrudraraju / Readme.md
Last active September 11, 2018 15:46
E2E Testing with Puppeteer

End to End Testing techniques for Puppeteer in React

Get Element's details

.$eval is like running document.querySelector

eg:

// html file
Hello
@sriramrudraraju
sriramrudraraju / Readme.md
Last active September 10, 2018 14:23
Responsive Placeholder Image

Transparent responsive data uri

data:image/svg+xml;charset=utf-8,%3Csvg xmlns%3D"http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg" viewBox%3D"0 0 228.5 127.22"%2F%3E

  • 228.5 represents width
  • 127.22 respresents height
  • height and width preserve aspect ratio.
  • more info
@sriramrudraraju
sriramrudraraju / lozad-image-wrapper.tsx
Created August 22, 2018 20:30
lazy loading images in react
// React wrapper for lozad.js for images
import * as React from 'react';
import * as lozad from 'lozad';
// src: the image path that will be lazyloaded
// customClass: css class that will be applied to img element
// defaultImageSrc: image path (preferebly local to this app) that needs to be displayed
// by default before the required imgae lazy loaded
interface LozadWrapperProps {
@sriramrudraraju
sriramrudraraju / create-react-app-webpack-prod.md
Last active April 8, 2021 02:20
Optimizing production build create-react-app using svg-url-loader

Create-React-App Production build Optimizataion

Svg-Url-Loader

Requirement

Instead moving .svg files from src/assets/ to build/static/media/ during npm run build. .svg files have to be bundled into build/static/js/main.js

Steps

@sriramrudraraju
sriramrudraraju / Express-Seed-Project.md
Last active November 2, 2017 16:51
Creating Express Js seed project
@sriramrudraraju
sriramrudraraju / React-Redux-Unit-Tests.md
Last active November 11, 2023 02:00
React Redux Unit Tests: Full App
@sriramrudraraju
sriramrudraraju / React-Redux-Unit-Testing-Part-3.md
Last active November 2, 2017 16:47
React Redux Unit Testing with Jest part 3: Components

React Redux Unit Testing: Part 3

Example for Components using jest

Thanks to Max Stoiber for his blog

>Note: I didnt get as successfull snapshot as followed from blog. So I tweaked it to make it work

@sriramrudraraju
sriramrudraraju / React-Redux-Unit-Testing-Part-2.md
Last active November 2, 2017 16:48
React Redux Unit Testing with Jest part 2: Reducers

React Redux Unit Testing: Part 2

Example for Reducers using jest

Thanks to Max Stoiber for his blog