Skip to content

Instantly share code, notes, and snippets.

View Munawwar's full-sized avatar
🍪
Cookies

Munawwar Firoz Munawwar

🍪
Cookies
View GitHub Profile
@imownbey
imownbey / EdgeSSETransport.ts
Created March 9, 2025 21:12
Edge / Cloudflare Worker & Durable Object driven McpServer transport
import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
import { JSONRPCMessage, JSONRPCMessageSchema } from '@modelcontextprotocol/sdk/types.js';
const MAXIMUM_MESSAGE_SIZE = 4 * 1024 * 1024; // 4MB
/**
* This transport is compatible with Cloudflare Workers and other edge environments
*/
export class EdgeSSETransport implements Transport {
private controller: ReadableStreamDefaultController<Uint8Array> | null = null;
@mebaysan
mebaysan / convert.sh
Last active April 13, 2025 05:20
Ubuntu Screen Recorder WEBM to MP4
#! /bin/bash
# sudo apt-get install ffmpeg
# if ffmpeg is not installed, install it
if ! [ -x "$(command -v ffmpeg)" ]; then
sudo apt-get install ffmpeg
fi
# if no arguments are given, print usage
import { useSignal, signal, effect } from '@preact/signals';
import { useLayoutEffect, useMemo, useRef } from 'preact/hooks';
/** @template T @typedef {T extends (infer U)[] ? U : never} Items */
/** @param {{ v, k?, f }} props */
const Item = ({ v, k, f }) => f(v, k);
/**
* Like signal.value.map(fn), but doesn't re-render.
@EllyLoel
EllyLoel / reset.css
Last active January 24, 2025 09:14
CSS Reset
/*
Made by Elly Loel - https://ellyloel.com/
With inspiration from:
- Josh W Comeau - https://courses.joshwcomeau.com/css-for-js/treasure-trove/010-global-styles/
- Andy Bell - https://piccalil.li/blog/a-modern-css-reset/
- Adam Argyle - https://unpkg.com/[email protected]/normalize.min.css / https://codepen.io/argyleink/pen/KKvRORE
Notes:
- `:where()` is used to lower specificity for easy overriding.
*/

0u+_W!+h_+h3_01d & InWithTheNew!

Modern Password Theory in a Nutshell

By Andrew Somers

In the Beginning, there was the "hard to read" paradigm

So... We've been taught now for years to make our passwords more secure by D0!n97h!n95L!k37h!5 ("doing things like this", i.e. substituting characters with numbers and so forth).

The theory was that by increasing the character set size, password entropy would improve — at the expense of being much harder to read, harder to remember, and harder to type into the hidden void that is the password field. This has long been accepted as "the way".

But does this actually improve password safety? The short answer is "not really".

Preact: Progressive Hydration

Preact now supports seamless progressive hydration.

Any component can throw during hydration (or new tree creation like a route change!), and if a component somewhere higher in the tree catches that via componentDidCatch, hydration gets paused.

Re-rendering the tree (via setState, etc) simply resumes hydration where it left off.

@Munawwar
Munawwar / daisy-chain.js
Last active July 13, 2021 11:51
Lodash chaining without importing the entire library
function chain(value) {
return {
/**
* @param {function|string} func function or function name (in chained value)
* @param {...any} args
*/
fn(func, ...args) {
if (typeof func === 'string') {
return chain(value[func](...args));
}
@Tinitto
Tinitto / generateGravatar.js
Last active September 16, 2023 00:23
Generate Gravatar or default to Initials Avatar
/**
This is in a Nodejs environment
*/
const crypto = require('crypto');
module.exports = (
email = '',
name = 'Anonymous',
initialsAvatarBackground = '000000',
@rjz
rjz / crypto-aes-256-gcm-demo.js
Last active March 4, 2025 22:24
example using node.js crypto API with aes-256-gcm
const buffer = require('buffer');
const crypto = require('crypto');
// Demo implementation of using `aes-256-gcm` with node.js's `crypto` lib.
const aes256gcm = (key) => {
const ALGO = 'aes-256-gcm';
// encrypt returns base64-encoded ciphertext
const encrypt = (str) => {
// The `iv` for a given key must be globally unique to prevent
@bsara
bsara / git-ssh-auth-win-setup.md
Last active April 11, 2025 16:35
Setup SSH Authentication for Git Bash on Windows

Setup SSH Authentication for Git Bash on Windows

Prepararation

  1. Create a folder at the root of your user home folder (Example: C:/Users/uname/) called .ssh.
  2. Create the following files if they do not already exist (paths begin from the root of your user home folder):
  • .ssh/config