Skip to content

Instantly share code, notes, and snippets.

View eshrinivasan's full-sized avatar
🏠
Working from home

Neelmeg eshrinivasan

🏠
Working from home
View GitHub Profile
@eshrinivasan
eshrinivasan / React templates 2022
Last active January 11, 2022 06:18
react component template
import React from 'react';
import {
Box,
Grid,
Typography,
makeStyles,
Button
} from '@material-ui/core';
import IconButton from '@material-ui/core/IconButton';
import CloseIcon from '@material-ui/icons/Close';
@eshrinivasan
eshrinivasan / Interview code check 2022
Last active January 11, 2022 06:16
Interview code check 2022
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@gaearon
gaearon / modern_js.md
Last active April 18, 2024 15:01
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
1. Find > Replace
2. Click 'Regular Expression' box
3. Enter ^\s+ as your search string
4. Click 'Find' to confirm it works as anticipated
5. Use 'Replace All' to remove all leading spaces from each newline
NB. For trailing spaces replace with \s+$
@paulirish
paulirish / what-forces-layout.md
Last active May 11, 2024 00:41
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@pbojinov
pbojinov / README.md
Last active December 8, 2023 21:09
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

@CMCDragonkai
CMCDragonkai / angularjs_directive_attribute_explanation.md
Last active November 29, 2023 15:35
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@input
input / Usage
Created January 11, 2012 20:01
Add a jQuery UI library to a Drupal 7 site via template.php
Usage
-----
Place the 'themename_preprocess_html()' function in your theme's template.php file.
Rename 'themename' to your theme's actual name,
e.g. for 'bartik' the function name would be changed to 'bartik_preprocess_html'.
Change 'ui.slider' to whichever jQuery UI library you want to add.
In Drupal 7, jQuery UI library files are stored in '/misc/ui'.
See: http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_add_library/7 for reference.
@jaysonrowe
jaysonrowe / FizzBuzz.js
Created January 11, 2012 01:39
FizzBuzz JavaScript solution
for (var i=1; i <= 20; i++)
{
if (i % 15 == 0)
console.log("FizzBuzz");
else if (i % 3 == 0)
console.log("Fizz");
else if (i % 5 == 0)
console.log("Buzz");
else
console.log(i);
@mr-rock
mr-rock / first_example.rb
Created October 9, 2009 12:08
Examples for the Cookie-based Sessions in Sinatra published by RubyLearning.com blog on Sep 30, 2009.
require 'rubygems'
require 'sinatra'
enable :sessions
get '/' do
session["value"] ||= "Hello world!"
"The cookie you've created contains the value: #{session["value"]}"
end