Skip to content

Instantly share code, notes, and snippets.

View isocroft's full-sized avatar
😜
Seriously fooling around!

Ifeora Okechukwu Patrick isocroft

😜
Seriously fooling around!
View GitHub Profile
<!-- i have to warn you, this code SUCKS! i DO NOT recommend using this code, but you can if you want -->
<div style="width:calc(442px + 28px * 2); outline:1px solid #232323; border-radius:8px;position: absolute;top:0;left:0;translate:calc(50vw - 50%) calc(50vh - 50%); box-sizing: border-box;container-type: size;height:600px;contain:strict">
<div style="overflow: clip;contain:strict;width:100%;height:100%;position:absolute">
<div style="padding:28px;display: flex;height:100%;box-sizing:border-box;flex-direction: column;align-items: center;justify-content: center;">
<svg class="nv-block sm:nv-hidden nv-h-6 nv-w-auto" style="width:100px;margin-top:2px" viewBox="0 0 1230.574 519.774" xmlns="http://www.w3.org/2000/svg" aria-label="Cloudflare"><path d="m784.025 512.011 5.872-20.311c6.998-24.169 4.394-46.511-7.349-62.926-10.801-15.122-28.804-24.022-50.666-25.056l-414.114-5.281c-2.788-.147-5.096-1.403-6.518-3.471-1.44-2.123-1.773-4.856-.886-7.478 1.366-4.08 5.41-7.164 9.62-7.349l417.954-5.299c49.576-2.271 103.2
@hacktivist123
hacktivist123 / crawler.go
Created January 9, 2025 15:15
A simple web crawler
package main
import (
"bytes"
"crypto/tls"
"fmt"
"log"

This gist is a simple no-brainer description of the 3 ways (actually 2.5) the Web handle events.

<tag onclick />

The declarative inline HTML event listener is mostly an indirection of DOM Level 0 events, meaning this simply uses the equivalent of tag.onclick = listener behind the scene.

Example

click me
@mykeels
mykeels / snake-camel.d.ts
Created May 30, 2023 23:25
Typings for the snake-camel npm package https://www.npmjs.com/package/snake-camel
type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}`
? `${T extends Capitalize<T> ? '_' : ''}${Lowercase<T>}${CamelToSnakeCase<U>}`
: S
type SnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}`
? `${T}${Capitalize<SnakeToCamelCase<U>>}`
: S
type StringKeys<TEntity extends {}> = {
[key in keyof TEntity]: key extends string ? key : never
}[keyof TEntity]
type IsLiteral<TValue> = TValue extends string | number | boolean | symbol
@Widdershin
Widdershin / ssr.md
Last active May 1, 2024 17:36
The absurd complexity of server-side rendering

In the olden days, HTML was prepared by the server, and JavaScript was little more than a garnish, considered by some to have a soapy taste.

After a fashion, it was decided that sometimes our HTML is best rendered by JavaScript, running in a user's browser. While some would decry this new-found intimacy, the age of interactivity had begun.

But all was not right in the world. Somewhere along the way, we had slipped. Our pages went uncrawled by Bing, time to first meaningful paint grew faster than npm, and it became clear: something must be done.

And so it was decided that the applications first forged for the browser would also run on the server. We would render our HTML using the same logic on the server and the browser, and reap the advantages of both worlds. In a confusing series of events a name for this approach was agreed upon: Server-side rendering. What could go wrong?

In dark rooms, in hushed tones, we speak of colours.

@rmorse
rmorse / react-router-dom-v.6.02.prompt.blocker.js
Last active January 12, 2026 13:14
Adds back in `useBlocker` and `usePrompt` to `react-router-dom` version 6.0.2 (they removed after the 6.0.0 beta, temporarily)
/**
* These hooks re-implement the now removed useBlocker and usePrompt hooks in 'react-router-dom'.
* Thanks for the idea @piecyk https://github.com/remix-run/react-router/issues/8139#issuecomment-953816315
* Source: https://github.com/remix-run/react-router/commit/256cad70d3fd4500b1abcfea66f3ee622fb90874#diff-b60f1a2d4276b2a605c05e19816634111de2e8a4186fe9dd7de8e344b65ed4d3L344-L381
*/
import { useContext, useEffect, useCallback } from 'react';
import { UNSAFE_NavigationContext as NavigationContext } from 'react-router-dom';
/**
* Blocks all navigation attempts. This is useful for preventing the page from
* changing until some condition is met, like saving form data.
@Thecarisma
Thecarisma / device-enabler.bat
Created December 28, 2019 22:05
Use brute-force method to enable a device when disabled by device control programs (e.g anti-virus). This simple script can be used to activate a disk drive even if a device control program is up.
@echo off
REM download the microsoft devcon app https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/devcon
REM Download x64 if your arch is x64 same for x32
REM change this 'USBSTOR\DISK&VEN_WD&PROD_ELEMENTS_25A2&REV_1021\57584131413438324C384543&0' to your device instace path
REM Run as Administrator
:exec
devcon enable @"USBSTOR\DISK&VEN_WD&PROD_ELEMENTS_25A2&REV_1021\57584131413438324C384543&0"
goto:exec
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active April 9, 2026 12:40
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).
@romuald
romuald / processlist.sql
Last active December 19, 2025 11:12
Show PostgreSQL current (running) process list;
SELECT user, pid, client_addr, waiting, query, query_start, NOW() - query_start AS elapsed
FROM pg_stat_activity
WHERE query != '<IDLE>'
-- AND EXTRACT(EPOCH FROM (NOW() - query_start)) > 1
ORDER BY elapsed DESC;
@nl5887
nl5887 / decode.go
Last active March 9, 2026 01:21
Golang implementation for RFC 1342: Non-ASCII Mail Headers
package main
import (
"encoding/base64"
"fmt"
"io"
"io/ioutil"
"mime/quotedprintable"
"regexp"
"strings"