Skip to content

Instantly share code, notes, and snippets.

View zomars's full-sized avatar
🙏
Never stop learning

Omar López zomars

🙏
Never stop learning
View GitHub Profile
@feedthejim
feedthejim / import-timing-plugin.js
Created April 10, 2023 20:47
Webpack Import timing plugin
const { ConcatSource } = require('webpack-sources')
class ImportTimingPlugin {
constructor(options = {}) {
this.options = options
}
apply(compiler) {
compiler.hooks.compilation.tap('ImportTimingPlugin', (compilation) => {
compilation.hooks.processAssets.tap(
@bashbunni
bashbunni / .zshrc
Created October 27, 2022 21:41
CLI Pomodoro for Mac
# I'll be doing another one for Linux, but this one will give you
# a pop up notification and sound alert (using the built-in sounds for macOS)
# Requires https://github.com/caarlos0/timer to be installed
# Mac setup for pomo
alias work="timer 60m && terminal-notifier -message 'Pomodoro'\
-title 'Work Timer is up! Take a Break 😊'\
-appIcon '~/Pictures/pumpkin.png'\
-sound Crystal"
@belgattitude
belgattitude / ci-yarn-install.md
Last active April 9, 2024 09:40
Composite github action to improve CI time with yarn 3+ / node-modules linker.
@lyzs90
lyzs90 / handler.ts
Created June 29, 2022 16:01
Next.js Stripe Webhook Handler
import { NextApiRequest, NextApiResponse } from 'next';
import Stripe from 'stripe';
import { Readable } from 'node:stream';
export const config = {
api: {
bodyParser: false,
},
};
@zomars
zomars / modularized-nextjs-project-strucutre.md
Last active July 28, 2022 23:26
Reusable Next.js project structure

File structure

The main file structure is organized as follows:

├── __test__
├── assets
├── configs
├── modules
│   ├── common (Here is what is reused in various modules)
@franky47
franky47 / stripe-webhooks.ts
Created December 21, 2021 09:44
Strongly-typed webhook handlers for Stripe (Node.js)
import type { Stripe } from 'stripe'
export type StripeWebhookEventTypes =
Stripe.WebhookEndpointCreateParams.EnabledEvent
export type StripeWebhookEvent<
EventType extends StripeWebhookEventTypes,
Payload
> = {
eventType: EventType
@ianobermiller
ianobermiller / index.html
Created July 12, 2021 00:47
WiFi QR Code, single HTML file
<!DOCTYPE html>
<html>
<head>
<title>WiFi Login</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- https://news.ycombinator.com/item?id=26923316 -->
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>&#128272;</text></svg>">
<style>
body, textarea {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
@nenadfilipovic
nenadfilipovic / Profile.tsx
Created June 26, 2021 16:41
Correctly infer prop types from getServerSideProps function
const Profile = ({
user,
}: InferGetServerSidePropsType<typeof getServerSideProps>): JSX.Element => {
return (
<section>
<div>{user.image}</div>
<div>{user.name}</div>
<div>{user.email}</div>
<div>{user.role}</div>
<div>{user.id}</div>
@JonathonRichardson
JonathonRichardson / HTMLComment.tsx
Created December 12, 2020 17:30
React Component for HTML Comment
import * as React from 'react';
import * as ReactDOM from 'react-dom';
interface IProps {
text: string;
}
export class HTMLComment extends React.Component<IProps> {
private node: Comment;
private ref$rootDiv = React.createRef<HTMLDivElement>();
@gullyn
gullyn / flappy.html
Last active November 28, 2023 18:23
Flappy bird in 205 bytes (improved!)
<body onload=z=c.getContext`2d`,setInterval(`c.width=W=150,Y<W&&P<Y&Y<P+E|9<p?z.fillText(S++${Y=`,9,9|z.fillRect(p`}*0,Y-=--M${Y+Y},P+E,9,W),P))):p=M=Y=S=6,p=p-6||(P=S%E,W)`,E=49) onclick=M=9><canvas id=c>