Skip to content

Instantly share code, notes, and snippets.

View xta's full-sized avatar

Rex Feng xta

View GitHub Profile
@chockenberry
chockenberry / PrivacyInfo.xcprivacy
Last active April 19, 2024 18:39
PrivacyInfo.xcprivacy sample
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
@kj800x
kj800x / Hacking the LG Monitor's EDID.md
Last active May 3, 2024 20:14
Hacking the LG Monitor's EDID

preface: Posting these online since it sounds like these notes are somewhat interesting based on a few folks I've shared with. These are semi-rough notes that I basically wrote for myself in case I ever needed to revisit this fix, so keep that in mind.

I recently bought an LG ULTRAGEAR monitor secondhand off of a coworker. I really love it and it's been great so far, but I ran into some minor issues with it in Linux. It works great on both Mac and Windows, but on Linux it displays just a black panel until I use the second monitor to go in and reduce the refresh rate down to 60 Hz.

This has worked decent so far but there's some issues:

  • It doesn't work while linux is booting up. The motherboards boot sequence is visible just fine, but as soon as control is handed over to Linux and I'd normally see a splash screen while I'm waiting for my login window, I see nothing.
  • It doesn't work on the login screen. This would be fine if login consistently worked on my second screen, but I need to manually switch
@obahareth
obahareth / #ChatGPT Streaming.md
Created May 13, 2023 22:43 — forked from alexrudall/#ChatGPT Streaming.md
ChatGPT streaming with ruby-openai, Rails 7, Hotwire, Turbostream, Sidekiq and Tailwind!

How to add ChatGPT streaming to your Ruby on Rails 7 app!

This guide will walk you through adding a ChatGPT-like messaging stream to your Ruby on Rails 7 app using ruby-openai, Rails 7, Hotwire, Turbostream, Sidekiq and Tailwind. All code included below!

Alt Text

First, add the ruby-openai gem! Needs to be at least version 4. Add Sidekiq too.

@mayoff
mayoff / UnitPoint.angle.swift
Last active July 16, 2023 15:07
point on unit square at a given angle
import SwiftUI
extension UnitPoint {
/// - returns: The point on the perimeter of the unit square that is at angle `angle` relative to the center of the unit square.
init(_ angle: Angle) {
// Inspired by https://math.stackexchange.com/a/4041510/399217
// Also see https://www.desmos.com/calculator/k13553cbgk
let s = sin(angle.radians)
let c = cos(angle.radians)
@UnderscoreDavidSmith
UnderscoreDavidSmith / UnitSquareIntersectionPoint.swift
Created February 22, 2023 11:59
SwiftUI UnitPoint for Angle
//
// ContentView.swift
// GradientComponenet
//
// Created by David Smith on 2/21/23.
//
import SwiftUI
struct ContentView: View {
@JohnSundell
JohnSundell / ContentViewWithCollapsableHeader.swift
Last active April 25, 2024 06:41
A content view which renders a collapsable header that adapts to the current scroll position. Based on OffsetObservingScrollView from https://swiftbysundell.com/articles/observing-swiftui-scrollview-content-offset.
import SwiftUI
/// View that observes its position within a given coordinate space,
/// and assigns that position to the specified Binding.
struct PositionObservingView<Content: View>: View {
var coordinateSpace: CoordinateSpace
@Binding var position: CGPoint
@ViewBuilder var content: () -> Content
var body: some View {
// Gradient Shader for arbitrary gradient stops, three gradient types and rotation
// For the details please visit: https://mtldoc.com/metal/2022/08/04/shaders-explained-gradients.html
// MARK: - Gradient Texture
struct GradientTextureVertex {
float4 position [[ position ]];
float4 color;
};
import React, { useState } from 'react';
import {default as UUID} from "node-uuid";
export default function App() {
const [books, setBooks] = useState([]);
const [action, setAction] = useState('list');
const [formData, setFormData] = useState({title: "", author: ""});
const [currentBookId, setCurrentBookId] = useState(null);
const deleteBook = (id) => { setBooks(books.filter((book) => book.id != id)); };
@swiftui-lab
swiftui-lab / grid-trainer.swift
Last active March 29, 2024 01:46
A grid trainer for Grid views
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: this learning tool is designed to showcase the different
// Grid and GridRow view options, added in SwiftUI 2022. It is part of the
// blog article: https://swiftui-lab.com/eager-grids
//
import SwiftUI
import UniformTypeIdentifiers
// The root view of the application
struct ContentView: View {
@brettohland
brettohland / 1.README.md
Last active October 23, 2023 20:47
ISBN example with FormatStyle, AttributedStringFormatStyle, ParseableFormatStyle conformance.

Supporting FormatStyle & ParseableFormatStyle To Your Custom Types

A full example of adding String and AttributedString output to our custom types, as well as adding the ability to parse String values into your custom type.

Read the blog post

See the Xcode Playground

ko-fi