Skip to content

Instantly share code, notes, and snippets.

View mikoloism's full-sized avatar
🌱

mikoloism mikoloism

🌱
View GitHub Profile
@mikoloism
mikoloism / (1) assign.ts
Last active May 30, 2023 08:46
Global Utilities #Assign and #Object
export function define<T extends {}>(source: T, ...sources: any[]): T {
return Object.assign(source, ...sources) as T;
}
export function assign<T extends {}>(...sources: any[]): T {
return Object.assign({}, ...sources) as T;
}
export function sureAssign<T>(
value: T | undefined,
@mikoloism
mikoloism / (1) storage.ts
Created May 17, 2023 22:02
Class based `localStorage` API
export class storage {
public static canUse(): boolean {
return typeof localStorage !== 'undefined';
}
public static hasKey(key: string): boolean {
return storage.canUse() && localStorage.getItem(key) !== null;
}
public static getJson<T>(key: string): T | null {
@mikoloism
mikoloism / (0) readme.md
Last active January 18, 2024 21:42
DOTFILES Installer.py script

DOTFILES (Installer.py script)

Contents:

  • installer.sh
  • installer.py

Requirments:

Python3

@mikoloism
mikoloism / type-safe-getter-hoc.ts
Last active April 18, 2024 11:48
Safest Object Getter Higher-Order Function and Clousor
function typeSafeGetter<V extends object>(o: V) {
return function <
K extends keyof V,
P extends undefined | K = undefined,
R = P extends K ? V[P] : V,
>(property?: P): R {
if (typeof o === 'undefined') throw 'error';
if (typeof property === 'undefined') {
return o as never
@mikoloism
mikoloism / http-proxy.pac
Created May 29, 2024 07:49
http-proxy.pac file
function FindProxyForURL(url, host) {
var PROXY_LIST_FILE = 'https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/http.txt';
var TEST_TARGET_URL = 'https://google.com';
var TEST_TIMEOUT = 5000;
var proxyList = [];
function addProxy(proxy) {
if (proxyList.indexOf(proxy) === -1) {
proxyList.push(proxy);
}