This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if canImport(Combine) | |
import Foundation | |
import Combine | |
@available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) | |
extension URLSession { | |
public typealias DataTaskProgressPublisher = | |
(progress: Progress, publisher: AnyPublisher<DataTaskPublisher.Output, Error>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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])); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class conditional_decorator(object): | |
def __init__(self, dec, condition): | |
self.decorator = dec | |
self.condition = condition | |
def __call__(self, func): | |
if not self.condition: | |
# Return the function unchanged, not decorated. | |
return func | |
return self.decorator(func) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original author: https://twitter.com/esizkur/status/1579207536812904448 | |
git clone https://github.com/ggerganov/whisper.cpp | |
cd whisper.cpp | |
make | |
./download-ggml-model.sh large | |
ffmpeg -i recording.m4a -acodec pcm_s16le -ar 16000 recording.wav | |
./main -m models/ggml-large.bin -l de -f recording.wav | tee transcript.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(list(filter(lambda x: all(x%d for d in range (2,x)), range(2, 3**10)))[:10]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
⌘ + ⇧ + O - Open in temporary Tab | |
⌘ + ⌥ + O - Make tab permanent |