Skip to content

Instantly share code, notes, and snippets.

struct InjectedNSView<Content: View, Injected: NSView>: NSViewRepresentable {
let content: Content
let injected: () -> Injected
func makeNSView(context: Context) -> Injected {
let injected = injected()
let hostingView = NSHostingView(rootView: content)
hostingView.translatesAutoresizingMaskIntoConstraints = false
injected.addSubview(hostingView)
hostingView.topAnchor.constraint(equalTo: injected.topAnchor).isActive = true
hostingView.bottomAnchor.constraint(equalTo: injected.bottomAnchor).isActive = true
@bacongravy
bacongravy / .zshrc
Last active December 13, 2021 15:09
pwcopy.zsh
function pwcopy {
< /dev/urandom \
LANG= \
tr -dc a-zA-Z0-9 \
| head -c ${1:-16} \
| pbcopy \
&& pbpaste \
&& echo
}
name: deploy
on:
push:
branches: [ master ]
tags: [ v* ]
jobs:
deploy:
runs-on: macos-latest
#!/bin/bash
set -euo pipefail
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
echo "$PROVISIONING_PROFILE_DATA" | base64 --decode > ~/Library/MobileDevice/Provisioning\ Profiles/profile.mobileprovision
#!/bin/bash
set -euo pipefail
security create-keychain -p "" build.keychain
security list-keychains -s build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "" build.keychain
security set-keychain-settings
security import <(echo $SIGNING_CERTIFICATE_P12_DATA | base64 --decode) \
#!/bin/bash
set -euo pipefail
SCHEME="$(xcodebuild -list -json | jq -r '.project.schemes[0]')"
PRODUCT_NAME="$(xcodebuild -scheme "$SCHEME" -showBuildSettings | grep " PRODUCT_NAME " | sed "s/[ ]*PRODUCT_NAME = //")"
echo "::set-env name=PRODUCT_NAME::$PRODUCT_NAME"
/*
!api
!public
!vercel.json
{
"version": 2,
"functions": {
"api/**/*.[jt]s": { "runtime": "vercel-deno@0.3.0" }
}
}
import { listenAndServe } from "https://deno.land/std@0.58.0/http/server.ts";
import hello from "./api/hello.ts"
const s = listenAndServe({ port: 8000 }, hello);
console.log("http://localhost:8000/");
<html>
<head>
<title>
Hello API Example
</title>
<script lang="javascript">
fetch("/api/hello")
.then((res) => res.text())
.then((text) => {
document.getElementById("api-response").innerHTML = text;