Skip to content

Instantly share code, notes, and snippets.

View T1T4N's full-sized avatar
👽

Robert Armenski T1T4N

👽
View GitHub Profile
@T1T4N
T1T4N / object_hash.js
Created March 28, 2023 10:34
object-hash benchamark
!function(e){var t;"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):("undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.objectHash=e())}(function(){return function r(o,i,u){function s(n,e){if(!i[n]){if(!o[n]){var t="function"==typeof require&&require;if(!e&&t)return t(n,!0);if(a)return a(n,!0);throw new Error("Cannot find module '"+n+"'")}e=i[n]={exports:{}};o[n][0].call(e.exports,function(e){var t=o[n][1][e];return s(t||e)},e,e.exports,r,o,i,u)}return i[n].exports}for(var a="function"==typeof require&&require,e=0;e<u.length;e++)s(u[e]);return s}({1:[function(w,b,m){!function(e,n,s,c,d,h,p,g,y){"use strict";var r=w("crypto");function t(e,t){t=u(e,t);var n;return void 0===(n="passthrough"!==t.algorithm?r.createHash(t.algorithm):new l).write&&(n.write=n.update,n.end=n.update),f(t,n).dispatch(e),n.update||n.end(""),n.digest?n.digest("buffer"===t.encoding?void 0:t.encoding):(e=n.read(),"buffer"!==t.encoding?e.toSt
@T1T4N
T1T4N / exportActionsUnionFromSlice.ts
Last active March 27, 2023 10:05
Use Redux Toolkit's createSlice with useReducer + export a type union of all its actions defined in 'reducers'
// https://stackoverflow.com/a/64582352
export type SliceActions<T> = {
[K in keyof T]: T[K] extends (...args: any[]) => infer A ? A : never;
}[keyof T];
// USAGE - NOTE: This doesn't work with `extraReducers` and the builder syntax
export type MySlice = typeof slice;
export type StateAction = SliceActions<MySlice['actions']>;
export type SliceReducer = Reducer<IState, StateAction>;
@T1T4N
T1T4N / zip.ts
Created March 24, 2023 09:11
Typescript implementation of a zip function
// Source: https://stackoverflow.com/a/70192772/6053417
export function zip<T extends unknown[][]>(
...args: T
): { [K in keyof T]: T[K] extends (infer V)[] ? V : never }[] {
const minLength = Math.min(...args.map((arr) => arr.length));
// @ts-expect-error This is too much for ts
return [...Array(minLength).keys()].map((i) => args.map((arr) => arr[i]));
}
@T1T4N
T1T4N / gist:46e1d3839786f8977be94d46c69233a8
Created February 6, 2023 13:42
macOS: Hide a custom app's dock icon
# https://apple.stackexchange.com/questions/357109/run-applescript-in-background-without-showing-in-app-switcher#comment471468_357109
defaults write '/Applications/AppName.app/Contents/Info.plist' LSUIElement -bool yes
@T1T4N
T1T4N / react-devtools-safari.md
Last active May 18, 2024 03:06
How to get React Devtools working in Safari Developer Tools in 2023

React DevTools In Safari 2023

Credits: Forked from React DevTools in Safari 2022

Introduction

This is a successful experiment in getting React DevTools working in Safari Developer Tools in Safari 16.3 as of January 2023. Potentially, this process can be used with other extensions that extend the developer tools (e.g. Redux, Vue, etc...).

This is only a proof of concept but hopefully this may open the doors for tools that were previously accessible on other browsers to be now available on Safari spurring for a more open web experience (and debugging) for developers.

Requirements

  • macOS 13.2 Ventura
@T1T4N
T1T4N / primes.py
Created December 14, 2022 12:26
Python one liner - first 10 primes
print(list(filter(lambda x: all(x%d for d in range (2,x)), range(2, 3**10)))[:10])
@T1T4N
T1T4N / update-a-git-mirror.sh
Last active February 8, 2024 09:37
Mirroring a git repo
git clone --bare https://github.com/project/repo.git
cd repo
git push --mirror ssh://git@bitbucket/lib/new-repo.git
#f this results in the following error, go to step 4: 
#You are attempting to update refs that are reserved for Bitbucket's pull request functionality. Bitbucket manages these refs automatically, and they may not be updated by users.
#remote: Rejected refs:
#remote:     refs/pull-requests/1/from
git push ssh://git@bitbucket/lib/new-repo.git
@T1T4N
T1T4N / mirror-git-repo.sh
Last active February 7, 2024 10:37
Mirroring a git repository to Bitbucket
git clone --bare https://github.com/project/repo.git
cd repo
git push --mirror ssh://git@bitbucket/lib/new-repo.git
# if this results in the following error:
# You are attempting to update refs that are reserved for Bitbucket's pull request functionality. Bitbucket manages these refs automatically, and they may not be updated by users.
# remote: Rejected refs:
# remote: refs/pull-requests/1/from
#
# then use the following commands
Never set WKWebView as the top view in a XIB, otherwise:
WKWebView: configuration cannot be nil
Correct approach: Add it as a subview with correct constraints
@T1T4N
T1T4N / gist:a77ddb077469e3a05a29241db6dbe73d
Created October 24, 2022 12:19
Xcode 12+ - Sane navigation flow for editor tabs
⌘ + ⇧ + O - Open in temporary Tab
⌘ + ⌥ + O - Make tab permanent