Skip to content

Instantly share code, notes, and snippets.

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

Punith K kpunith8

🏠
Working from home
View GitHub Profile
@kpunith8
kpunith8 / Interfaces.java
Last active January 11, 2025 12:13
Java Examples - Tested
// An interface can extend any number of interfaces but a class can extend only one class (multiple inheritance is not
// supported in Java - diamond problem)
// Diamond Problem
// When A and B class have the same method and when the class C extends A, B
// implementing the method name from either of A or B, compiler doesn't from which
// class the method should be overridden or considerd.
interface Vehicle {
void accelerate();
@kpunith8
kpunith8 / mac-tips.md
Last active October 3, 2023 12:28
Mac Tips
@kpunith8
kpunith8 / scroll-hooks.js
Created April 29, 2022 04:47
Custom scroll hooks - refer react-use library - unit tests with RTL
import {useEffect} from 'react'
import globalProxy from '../../lib/global-proxy'
import useRafState from './use-raf-state'
// Adopted from https://github.com/streamich/react-use/blob/master/src/useWindowScroll.ts
export const useWindowScroll = () => {
const [state, setState] = useRafState(() => ({
x: globalProxy().window.pageXOffset,
y: globalProxy().window.pageYOffset,
}))
@kpunith8
kpunith8 / index.html
Created February 12, 2022 14:16
Responsive image grid using flexbox
<!DOCTYPE html>
<html>
<head>
<title>Parcel Sandbox</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
href="https://fonts.googleapis.com/css2?family=Baloo+2:wght@400;500&display=swap"
rel="stylesheet"
/>
@kpunith8
kpunith8 / naval-podcast.md
Last active October 4, 2023 16:17
Naval - How to get rich

Tweet thread on how to get rich

Tweet

  1. Seek wealth, not money or status. Wealth is having assets that earn while you sleep. Money is how we transfer time and wealth. Status is your place in the social hierarchy.
  2. Understand that ethical wealth creation is possible. If you secretly despise wealth, it will elude you.
  3. Ignore people playing status games. They gain status by attacking people playing wealth creation games.
  4. You’re not going to get rich renting out your time. You must own equity - a piece of a business - to gain your financial freedom.
  5. You will get rich by giving society what it wants but does not yet know how to get. At scale.
@kpunith8
kpunith8 / new-tech-links.md
Last active September 30, 2021 04:55
Random links for new tech and tools
@kpunith8
kpunith8 / AWS-Related-Issues-Fixes.md
Created September 23, 2021 04:54
AWS Related Issues and fixes
@kpunith8
kpunith8 / babel.config.js
Created September 17, 2021 11:22
Jest setup with babel and webpack-5 (React testing library, Jest)
const requiredPlugins = [
'@emotion',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-optional-chaining',
]
const plugins = {
development: requiredPlugins,
test: requiredPlugins,
production: requiredPlugins,
@kpunith8
kpunith8 / latest-updated-items.js
Last active July 14, 2021 08:02
Keep only latest updated docs using lodash and keep unique entries
const lastUpdatedEngines =
_.map(
_.filter(
_.groupBy(actualData, 'engine'), // Group each engine
status => _.size(status) > 1 // Look for arrays having more than one entry
),
engines => {
const lastUpdatedEngine = engines.reduce((a, b) =>
new Date(a?.updatedAt) > new Date(b?.updatedAt) ? a : b // compare the updatedAt for each engine and pick the latest
)
@kpunith8
kpunith8 / multi-context-global-store.js
Last active July 4, 2021 08:23
React Custom hooks
const storeContext = React.createContext()
const dispatchContext = React.createContext()
export const StroreProvider = ({childre, reducer, initialState = {}}) => {
const [store, dispatch] = React.useReducer(reducer, initialState)
return (
<dispatchContext.Provider value={dispatch}>
<storeContext.Provider value={store}>
{children}