Skip to content

Instantly share code, notes, and snippets.

View pexavc's full-sized avatar

PEXAVC pexavc

View GitHub Profile
import Foundation
import Combine
extension Publisher {
func pausableSink(
receiveValue: @escaping (Output) -> Void,
receiveCompletion: @escaping (Subscribers.Completion<Failure>) -> Void
) -> PausableSinkSubscriber<Output, Failure> {
let subscriber = PausableSinkSubscriber<Output, Failure>(
@pexavc
pexavc / CustomMacTextView.swift
Created August 18, 2023 15:06 — forked from antingle/CustomMacTextView.swift
CustomMacTextView - A simple NSScrollView wrapped by SwiftUI with placeholder text
//
// CustomMacTextView.swift
//
// MacEditorv2 Created by Marc Maset - 2021
// Changes inspired from MacEditorTextView by Thiago Holanda
//
// Modified by Anthony Ingle - 2022
//
import SwiftUI
@pexavc
pexavc / SearchConductor.swift
Created July 26, 2023 03:13
Simple Search Query Debouncer
import Foundation
import SwiftUI
import Combine
class SearchConductor: ObservableObject {
var searchTimer: Timer? = nil
private var task: Task<Void, Error>? = nil
@Published var query: String
@Published var isEditing: Bool = false
@pexavc
pexavc / Pager.swift
Created July 26, 2023 03:10
Simply Paging Manager/UI for an infinite scrolling feed.
import Foundation
import Combine
import SwiftUI
protocol Pageable: Equatable, Identifiable, Hashable {
var id: String { get }
}
class Pager<Model: Pageable>: ObservableObject {
@pexavc
pexavc / markdown.min.js
Created July 22, 2023 17:58
Rehosting markdown.min.js
This file has been truncated, but you can view the full file.
/*! @wcj/markdown-to-html v2.2.1 | MIT © 2022 kenny wang <wowohoo@qq.com> (https://github.com/jaywcjlove) https://github.com/jaywcjlove/markdown-to-html */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).markdown={})}(this,(function(e){"use strict";
/*!
* Determine if an object is a Buffer
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/var t=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)};function n(e){return e&&"object"==typeof e?"position"in e||"type"in e?a(e.position):"start"in e||"end"in e?a(e):"line"in e||"column"in e?r(e):"":""}function r(e){return i(e&&e.line)+":"+i(e&&e.column)}function a(e){return r(e&&e.start)+"-"+r(e&&e.end)}function i(e){return e&&"number"==typeof e?e:1}class o extends Error{constructor(e,t,r){const a=[null,null];let i={start:
@pexavc
pexavc / TableView.swift
Created May 3, 2023 00:26
Basic TableView starter implementation w/ resultBuilder in SwiftUI
//
// TableView.swift
// Stoic
//
// Created by PEXAVC on 5/2/23.
//
/* Basic TableView starter implementation w/ resultBuilder
Example Usage:
@pexavc
pexavc / understandingShaders_simplex_noise.txt
Last active February 2, 2022 08:24
[ Understanding Shaders ] // :: Simplex Noise
vec2 hash( vec2 p ) // replace this by something better
{
p = vec2( dot(p,vec2(127.1,311.7)), dot(p,vec2(269.5,183.3)) );
return -1.0 + 2.0*fract(sin(p)*43758.5453123);
}
float noise( in vec2 p )
{
const float K1 = 0.366025404; // (sqrt(3)-1)/2;
const float K2 = 0.211324865; // (3-sqrt(3))/6;
@pexavc
pexavc / marbler.html
Last active February 2, 2022 08:12
Test webGL shaders from a single html file using GLSL Canvas. Enter the raw shader code into the text box and click submit. A super light-weight alternative to shader toy.
<!DOCTYPE html>
<html>
<head>
<meta property="og:image" content="https://gateway.ipfs.io/ipfs/QmQt9J74g3daLLG12nTH4VpUMst3Y51uCcSYCgkWbyppSA" /><meta name="description" content="Lightweight shader toy."><title>Marble Shader Toy</title>
<meta name="viewport" content="width=device-width">
<meta name="keywords" content="shader, generator">
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<style>
@import url('https://fonts.googleapis.com/css2?family=Courier+Prime:wght@400&display=swap');