Skip to content

Instantly share code, notes, and snippets.

View mimshins's full-sized avatar
👾
Invading Codebases

Mostafa Shamsitabar mimshins

👾
Invading Codebases
View GitHub Profile
@mimshins
mimshins / resolve-throwable.ts
Last active March 20, 2025 09:14
An utility function to help resolve throwables in a declarative way.
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@mimshins
mimshins / create-animation-frames.ts
Last active June 10, 2024 20:05
Animation Loop
export type FrameTicker = (deltaTime: number) => void;
/**
* Creates smooth animation frames.
*
* @param frameTicker This callback will be called on each frame.\
* The `deltaTime` argument specifies the time elapsed between the last frame
* and the one preceding it (in milliseconds).
* @returns Returns animation frames controller.
*/
@mimshins
mimshins / linear-interpolation.ts
Created July 5, 2022 11:36
Lerp (linear interpolation), InverseLerp, and Remap functions in TypeScript
/**
* Linear interpolate on the scale given by `a` to `b`, using `t` as the point on that scale.
*/
export const lerp = (a: number, b: number, t: number) => a + t * (b - a);
/**
* Inverse Linar Interpolation, get the fraction between `a` and `b` on which `v` resides.
*/
export const inLerp = (a: number, b: number, v: number) => (v - a) / (b - a);
@sindresorhus
sindresorhus / esm-package.md
Last active July 2, 2025 19:35
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@jengel3
jengel3 / authentication-1.controller.ts
Last active April 23, 2024 19:26
NestJS - Implementing Access & Refresh Token Authentication
// app/modules/authentication/authentication.controller.ts
import { Body, Controller, Post } from '@nestjs/common'
import { RegisterRequest } from './requests'
import { User } from '../../modules/user'
import { UsersService } from '../users/users.service'
@sanskritkm
sanskritkm / Balsamiq Mockups 3.5.17
Last active May 26, 2025 00:31
Balsamiq Mockups 3.5.17 for Desktop full license key (Tested) or Balsamiq Wireframes for Desktop
Balsamiq Wireframes for Desktop full license key free
This old name is Balsamiq Mockups now the company changing the name to Balsamiq Wireframes for Desktop insteed
HOW TO:
First download softwere here: https://balsamiq.com/wireframes/desktop/
Install and follow screen direction
Use below serial:
=====================================================================================
@fearblackcat
fearblackcat / proxy_for_terminal.md
Last active June 17, 2025 11:52
Set proxy for terminal on mac

Shadowsocks Proxy

apt-get install python-pip
pip install shadowsocks

sudo ssserver -p 443 -k password -m aes-256-cfb --user nobody -d start
@mrchess
mrchess / gist:1820380
Created February 13, 2012 20:57
Exposes a variable openHTTPs which keeps track of how many XMLHttpRequests you have active.
<script>
(function() {
var oldOpen = XMLHttpRequest.prototype.open;
window.openHTTPs = 0;
XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
window.openHTTPs++;
this.addEventListener("readystatechange", function() {
if(this.readyState == 4) {
window.openHTTPs--;
}