Skip to content

Instantly share code, notes, and snippets.

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

Praveen apnerve

🏠
Working from home
View GitHub Profile
@apnerve
apnerve / base-image.md
Last active September 15, 2023 17:00

Simpler NextJS development environment

Most of my NextJS projects have the same config and settings. Only thing that changes across is the app folder. So, making a base nextjs docker image made sense for me

Create a file called page.js which exports a React component

export default function Home() {
 return (
@apnerve
apnerve / getNameByEmoji
Last active March 29, 2022 15:42
JS snippet to get all names baed on the emoji reactions they get on group chats in google chats
[...document.querySelectorAll("[data-id$=🤗]")].map(x=>x.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.previousSibling.firstChild.innerText).join(",")
@apnerve
apnerve / cheat wordle.js
Last active January 22, 2022 07:35
A Chrome bookmarklet to cheat in wordle by tweeting the stats. #bookmarklet
javascript:(function() {localStorage.setItem("gameState",JSON.stringify({"gameStatus":"WIN","rowIndex":1,"boardState":["loser","","","","",""],"evaluations":[["correct","correct","correct","correct","correct"],null,null,null,null,null],"lastPlayedTs":Date.now()}));location.reload()})()
@apnerve
apnerve / rss.xml
Created January 14, 2022 15:45
RSS for InvertedPassion
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Notes of InvertedPassion</title>
<link>https://notes.invertedpassion.com/</link>
<description>Hi 👋, I'm Paras Chopra and you're looking at my knowledge garden, a place where I publish my raw notes and thoughts.</description>
<lastBuildDate>Fri, 14 Jan 2022 15:45:04 GMT</lastBuildDate>
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
<generator>Obsidian RSS feed generator by apnerve</generator>
<language>en</language>
<h1>Hello</h1>
function average(x, n=1) {
return function(y) {
if(y) {
n++
return average(x+y, n)
}
return x/n
}
}
@apnerve
apnerve / instagram-video-story-download.url
Last active January 22, 2022 07:29
A Chrome bookmarklet to download Instagram video stories. #bookmarklet
javascript:(function(){var v = [...document.getElementsByTagName("source")][0].src;var l = document.createElement('a'); l.href = v; l.download = "video.mp4"; document.body.appendChild(l); l.click()})()
@apnerve
apnerve / sum.js
Created December 10, 2021 16:42
Write a function sum such that sum(a)(b)(c)...(n)() returns a+b+c+...+n
const sum = x => y => y ? sum(x+y) : x
@apnerve
apnerve / there-is-a-hole-in-my-bucket.js
Created June 25, 2021 14:14
There's a hole in my bucket song as a state chart
const bucketMachine = Machine({
id: 'fetch',
initial: "There's a hole in my bucket",
states: {
"There's a hole in my bucket": {
on: {
THEN_FIX_IT: 'With what should I fix it?'
}
},
@apnerve
apnerve / machine.js
Created January 8, 2021 17:37
Generated by XState Viz: https://xstate.js.org/viz
const webSocketMachine = Machine({
id: "Web Socket",
initial: "connecting",
states: {
connecting:{
on: {
SUCCESS: "open",
ERROR: "closed"
}
},