Skip to content

Instantly share code, notes, and snippets.

@PseudoSky
PseudoSky / range-to-regex.ts
Created February 9, 2024 18:05
Utility to create numeric range validators
const RegexRange = {
cache: {},
clearCache: () => (RegexRange.cache = {})
}
interface CacheEntry {
min: number
a: number
max: number
b: number
@PseudoSky
PseudoSky / types.ts
Created December 14, 2020 02:13 — forked from ClickerMonkey/types.ts
Typescript Helper Types
// when T is any|unknown, Y is returned, otherwise N
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N;
// when T is never, Y is returned, otherwise N
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N;
// empty object
type EmptyObject = { [key: string]: never };
@PseudoSky
PseudoSky / Awesome.md
Last active August 22, 2020 07:18
Awesome list
@PseudoSky
PseudoSky / 1_Notes.md
Last active July 2, 2020 14:53
Data structures & Algorithms
Input : Inorder -> 4 2 5 1 3
        Preorder -> 1 2 4 5 3
        Postorder -> 4 5 2 3 1
Output : Yes
Exaplanation : All of the above three traversals are of 
the same tree              1
@PseudoSky
PseudoSky / vindecoder.js
Created December 3, 2019 02:22 — forked from kevboutin/vindecoder.js
Decode a VIN
/**
* VIN decoder.
*
* kevinboutin on 3/11/18.
*
* My VIN for testing is WBA3A5G59DNP26082 so use the following command to invoke:
* node vindecoder WBA3A5G59DNP26082
*
* Examples:
* KM8JM12D56U303366
@PseudoSky
PseudoSky / README.md
Created October 31, 2018 13:18
Extract a dom nodes css selector

SmartSelect

Compute and minify an element's css selector

gistFileNameInput = '#gists > div:nth-child(4) > div > div.file-header > div.input-group.gist-filename-input > input.form-control.filename.js-gist-filename.js-blob-filename'
gistFileNameInput.length
> 151

newSelect = SmartSelect.cssPath(gistFileNameInput)
@PseudoSky
PseudoSky / export-style.js
Last active October 9, 2018 21:50
Javascript function that will export all current css arrtibutes on a dom element
Element.prototype.es = (function () {
// Mapping between tag names and css default values lookup tables. This allows to exclude default values in the result.
var defaultStylesByTagName = {};
// Styles inherited from style sheets will not be rendered for elements with these tag names
var noStyleTags = {"BASE":true,"HEAD":true,"META":true,"NOFRAME":true,"NOSCRIPT":true,"PARAM":true,"SCRIPT":true,"STYLE":true,"TITLE":true};
// This list determines which css default values lookup tables are precomputed at load time
// Lookup tables for other tag names will be automatically built at runtime if needed
@PseudoSky
PseudoSky / Default (OSX).sublime-keymap
Last active September 26, 2018 03:35
Sublime Key Bindings
[
{
"keys": ["option+i"],
"args": null,
"command": "swap_case"
},
{
"keys": ["option+="],
"command": "show_overlay",
@PseudoSky
PseudoSky / nmap-scripts.json
Created November 9, 2016 20:44
Security Tools Help & Data
[
{
"link": "https://nmap.org/nsedoc/scripts/acarsd-info.html",
"name": "acarsd-info",
"info": "Retrieves information from a listening acarsd daemon. Acarsd decodes ACARS (Aircraft Communication Addressing and Reporting System) data in real time. The information retrieved by this script includes the daemon version, API version, administrator e-mail address and listening frequency."
},
{
"link": "https://nmap.org/nsedoc/scripts/address-info.html",
"name": "address-info",
"info": "Shows extra information about IPv6 addresses, such as embedded MAC or IPv4 addresses when available."
var SEPARATION = 80, AMOUNTX = 50, AMOUNTY = 50;
var container, stats;
var camera, scene, renderer;
var startX, startY;
var particles, particle, count = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 3;
var mouseX = 0, mouseY = 50;