Skip to content

Instantly share code, notes, and snippets.

@dikaio
dikaio / data.csv
Created January 2, 2022 09:27
City, Latitude, Longitude, Country, Population in CSV Format
city lat lng country population
Tokyo 35.685 139.7514 Japan 35676000
New York 40.6943 -73.9249 United States 19354922
Mexico City 19.4424 -99.131 Mexico 19028000
Mumbai 19.017 72.857 India 18978000
São Paulo -23.5587 -46.625 Brazil 18845000
Delhi 28.67 77.23 India 15926000
Shanghai 31.2165 121.4365 China 14987000
Kolkata 22.495 88.3247 India 14787000
Los Angeles 34.1139 -118.4068 United States 12815475
@dikaio
dikaio / sw.js
Created January 8, 2022 08:45
Unregister Service Worker
navigator.serviceWorker.getRegistrations().then(function (registrations) {
for (const registration of registrations) {
registration.unregister()
}
})
if (window.navigator && navigator.serviceWorker) {
navigator.serviceWorker.getRegistrations().then(function (registrations) {
for (const registration of registrations) {
registration.unregister()
@dikaio
dikaio / bad-bots.js
Created January 8, 2022 22:13
Cloudflare Worker that redirects spiders and crawlers, classified as "bad", to a 403 error response.
// Protect origin from unwanted spiders and crawlers.
// the worker returns the response instead of sending the request to the origin.
///////////////////////////////////////////////////////////////////////////////
// Good bots:
// AdsBot-Google
// DoCoMo
// Feedfetcher-Google
// Google-HTTP-Java-Client
// Googlebot
// Googlebot-Image
@dikaio
dikaio / image.ts
Created January 16, 2022 09:47 — forked from jacob-ebey/image.ts
Remix Image Component
import { createHash } from "crypto";
import fs from "fs";
import fsp from "fs/promises";
import path from "path";
import https from "https";
import { PassThrough } from "stream";
import type { Readable } from "stream";
import type { LoaderFunction } from "remix";
import sharp from "sharp";
import type { Request as NodeRequest } from "@remix-run/node";
@dikaio
dikaio / cities.csv
Created January 7, 2023 03:22
City, Latitude, Longitude, Country, Population
city lat lng country population
Tokyo 35.6839 139.7744 Japan 39105000
Jakarta -6.2146 106.8451 Indonesia 35362000
Delhi 28.6667 77.2167 India 31870000
Manila 14.6 120.9833 Philippines 23971000
São Paulo -23.5504 -46.6339 Brazil 22495000
Seoul 37.56 126.99 South Korea 22394000
Mumbai 19.0758 72.8775 India 22186000
Shanghai 31.1667 121.4667 China 22118000
Mexico City 19.4333 -99.1333 Mexico 21505000
whois 100.64.0.31
% IANA WHOIS server
% for more information on IANA, visit http://www.iana.org
% This query returned 1 object
refer: whois.arin.net
inetnum: 100.0.0.0 - 100.255.255.255
organisation: ARIN
status: ALLOCATED
@dikaio
dikaio / header-ux.tsx
Created April 11, 2023 00:32
Simple Fade in Fade out navigation menu using framer motion
"use client"
import { useEffect } from "react"
import Link from "next/link"
import {
motion,
useMotionTemplate,
useMotionValue,
useScroll,
useTransform,
@dikaio
dikaio / i18n.md
Last active April 17, 2023 01:27
Internationalization

Internationalization

North America

  • United States
    • English: en-US
  • Canada
    • English: en-CA
  • Mexico
  • Spanish: es-MX
@dikaio
dikaio / fetch-strategies.tsx
Created April 20, 2023 02:29
Example nextjs fetch strategy using both SSG and SSR
import Image from 'next/image'
import { Layout, Text, Page, Code, Link, List } from '@vercel/examples-ui'
import { GetStaticProps } from 'next'
import useSWR from 'swr'
import { useEffect, useState } from 'react'
import board from '../public/board.jpg'
interface Product {
id: string
@dikaio
dikaio / wealth-preservation.md
Created April 20, 2023 21:46
There's a reason why you people pay more in taxes to the U.S. Government than the most wealthy people in the world. Learn.

Wealth Preservation

The rich avoid taxes with a strategy “Buy, Borrow, Die”:

  1. Buy assets & hold (to avoid capital gains tax)

  2. Use assets as collateral to borrow money (while assets appreciate)

  3. Interest paid on loans is a tax deduction