Skip to content

Instantly share code, notes, and snippets.

Avatar
🙏
Never stop learning

Omar López zomars

🙏
Never stop learning
View GitHub Profile
@zomars
zomars / modularized-nextjs-project-strucutre.md
Last active Jul 28, 2022
Reusable Next.js project structure
View modularized-nextjs-project-strucutre.md

File structure

The main file structure is organized as follows:

├── __test__
├── assets
├── configs
├── modules
│   ├── common (Here is what is reused in various modules)
@ianobermiller
ianobermiller / index.html
Created Jul 12, 2021
WiFi QR Code, single HTML file
View index.html
<!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 Jun 26, 2021
Correctly infer prop types from getServerSideProps function
View Profile.tsx
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 Dec 12, 2020
React Component for HTML Comment
View HTMLComment.tsx
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 Aug 9, 2022
Flappy bird in 205 bytes (improved!)
View flappy.html
<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>
@agungjk
agungjk / [slug].js
Last active Jul 23, 2022
Crawler example on Vercel using Puppeteer and NextJS API routes
View [slug].js
const puppeteer = require('puppeteer-core');
const cheerio = require('cheerio');
const chrome = require('chrome-aws-lambda');
export default async (req, res) => {
const slug = req?.query?.slug;
if (!slug) {
res.statusCode = 200
res.setHeader('Content-Type', 'application/json')
res.end(JSON.stringify({ id: null }))
View samizdat-shell-help.bash
#!/bin/bash
###
### my-script — does one thing well
###
### Usage:
### my-script <input> <output>
###
### Options:
### <input> Input file to read.
### <output> Output file to write. Use '-' for stdout.
@gaearon
gaearon / Classes.js
Created May 27, 2020
Beneath Classes: Prototypes
View Classes.js
class Spiderman {
lookOut() {
alert('My Spider-Sense is tingling.');
}
}
let miles = new Spiderman();
miles.lookOut();
View enable-touch-id-for-sudo.sh
#!/bin/sh
grep pam_tid /etc/pam.d/sudo >/dev/null || echo auth sufficient pam_tid.so | cat - /etc/pam.d/sudo | sudo tee /etc/pam.d/sudo > /dev/null
@KATT
KATT / favourite-ts-tricks.md
Last active Aug 11, 2022
🧙‍♂️ Favourite non-obvious TS tricks
View favourite-ts-tricks.md

Record<string, x | undefined>

Represent maps

// rather than 
const map: {[ key: string ]: string} = {
  foo: 'bar',
}