Skip to content

Instantly share code, notes, and snippets.

@henshaw
henshaw / disallow-genai-bots.txt
Last active April 13, 2025 15:10
Disallow all pages from being trained for LLMs by all major GenAI bots
User-agent: Amazonbot
User-agent: Anthropic-ai
User-agent: Applebot-Extended
User-agent: AwarioRssBot
User-agent: AwarioSmartBot
User-agent: Bytespider
User-agent: CCBot
User-agent: ChatGPT-User
User-agent: ClaudeBot
User-agent: Claude-Web
/* eslint-disable func-style */
const InputEvent = window.Event || window.InputEvent;
const ONE_MINUTE = 60_000;
const TEN_SECONDS = 10_000;
const CONFIG = {
GLOBAL_INTERVAL: ONE_MINUTE,
MESSAGES_INTERVAL: TEN_SECONDS,
};
/**
* A bookmarklet for viewing the largest contentful paint in a page.
* Will show each LCP after the bookmarklet is clicked.
*
* To install:
* 1. Copy the code starting from the line beginning `javascript:`
* 2. Add a new bookmark in Chrome, and paste the code in as the URL.
**/
javascript:(function(){
try {
@tyingq
tyingq / sites
Created May 21, 2020 12:44
newscatcher
01net.com
057.ua
0629.com.ua
10best.com
112.ua
161.ru
163.com
180.com.uy
1limburg.nl
20minutes.fr
@reginpv
reginpv / robots next.js
Created December 7, 2019 00:48
How to add robot.txt to next.js
// Post verion 9.1
A public dir now can be added and will be rendered to root
source: https://nextjs.org/blog/next-9-1
// Prior to version 9.1
import React from 'react';
const robotsTxt = `User-agent: *
Disallow: `;
@fredrikbergqvist
fredrikbergqvist / Rss.ts
Created November 29, 2019 15:21
How to create an RSS feed for next.js
import React from "react";
import { NextPageContext } from "next";
const blogPostsRssXml = (blogPosts: IBlogPost[]) => {
let latestPostDate: string = "";
let rssItemsXml = "";
blogPosts.forEach(post => {
const postDate = Date.parse(post.createdAt);
if (!latestPostDate || postDate > Date.parse(latestPostDate)) {
latestPostDate = post.createdAt;
@fecori
fecori / thumbor-php
Created October 16, 2019 22:06
Generar imagenes thumbor con php
<?php
$imgTest = 'https://arc-anglerfish-arc2-prod-gruporepublica.s3.amazonaws.com/public/GDAJPDXRN5EJHNC22N6FTPAWEA.png';
function generarImagen($imgUrl, $witdh = 0, $height = 0)
{
if (!empty($imgUrl) && strpos($imgUrl, 'https') !== false) {
$thumbor_server = "SERVER";
$thumbor_key = "APIKEY";
$parametros = array(
$witdh . "x" . $height,
@joshuacerbito
joshuacerbito / useScroll.js
Last active January 8, 2024 13:44
Custom React hook for listening to scroll events
/**
* useScroll React custom hook
* Usage:
* const { scrollX, scrollY, scrollDirection } = useScroll();
*/
import { useState, useEffect } from "react";
export function useScroll() {
const [lastScrollTop, setLastScrollTop] = useState(0);
@jakub-g
jakub-g / async-defer-module.md
Last active October 9, 2025 12:15
async scripts, defer scripts, module scripts: explainer, comparison, and gotchas

<script> async, defer, async defer, module, nomodule, src, inline - the cheat sheet

With the addition of ES modules, there's now no fewer than 24 ways to load your JS code: (inline|not inline) x (defer|no defer) x (async|no async) x (type=text/javascript | type=module | nomodule) -- and each of them is subtly different.

This document is a comparison of various ways the <script> tags in HTML are processed depending on the attributes set.

If you ever wondered when to use inline <script async type="module"> and when <script nomodule defer src="...">, you're in the good place!

Note that this article is about <script>s inserted in the HTML; the behavior of <script>s inserted at runtime is slightly different - see Deep dive into the murky waters of script loading by Jake Archibald (2013)

@whoisryosuke
whoisryosuke / nextjs-hoc-authorization.js
Created June 26, 2018 22:24
ReactJS - NextJS - A HOC for wrapping NextJS pages in an authentication check. Checks for getInitialProps on the child component and runs it, so you still get SSR from the page. Also includes a user agent for Material UI.
import React, {Component} from 'react'
import Router from 'next/router'
import AuthService from './AuthService'
export default function withAuth(AuthComponent) {
const Auth = new AuthService('http://localhost')
return class Authenticated extends Component {
static async getInitialProps(ctx) {
// Ensures material-ui renders the correct css prefixes server-side