Skip to content

Instantly share code, notes, and snippets.

View inamiy's full-sized avatar

Yasuhiro Inami inamiy

View GitHub Profile
import asyncio
import base64
import json
import os
import pyaudio
from websockets.asyncio.client import connect
class SimpleGeminiVoice:
def __init__(self):
@adrienbrault
adrienbrault / llama2-mac-gpu.sh
Last active December 5, 2024 17:40
Run Llama-2-13B-chat locally on your M1/M2 Mac with GPU inference. Uses 10GB RAM. UPDATE: see https://twitter.com/simonw/status/1691495807319674880?s=20
# Clone llama.cpp
git clone https://github.com/ggerganov/llama.cpp.git
cd llama.cpp
# Build it
make clean
LLAMA_METAL=1 make
# Download model
export MODEL=llama-2-13b-chat.ggmlv3.q4_0.bin
@stammy
stammy / LiquidBlobs.swift
Last active July 24, 2024 14:49
Liquid Blob effect with SwiftUI
//
// ContentView.swift
// LiquidCircles
//
// Created by Paul Stamatiou on 10/10/22.
//
import SwiftUI
struct ContentView: View {
@swiftui-lab
swiftui-lab / showSizes.swift
Last active October 27, 2024 07:11
A debugging modifier for SwiftUI views (showSizes)
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: Implementation of the showSizes() debugging modifier
// blog article: https://swiftui-lab.com/layout-protocol-part-2
import SwiftUI
struct MeasureExample: View {
var body: some View {
VStack {
@tsuzukihashi
tsuzukihashi / toCMSampleBuffer.swift
Last active November 27, 2023 00:13
UIView to CMSampleBuffer (UIViewをCMSampleBufferに変換するExtension)
import UIKit
import CoreMedia
extension UIView {
func toCMSampleBuffer() -> CMSampleBuffer? {
let scale: CGFloat = UIScreen.main.scale
let size: CGSize = .init(width: bounds.width * scale, height: bounds.height * scale)
guard let pixelBuffer = makeCVPicelBuffer(scale: scale, size: size) else { return nil }
defer {
CVPixelBufferUnlockBaseAddress(pixelBuffer, CVPixelBufferLockFlags(rawValue: 0))

Disclaimer: I have no idea what I'm doing. This gist is a scratchpad for me to hopefully one make sense of things. Expect nonsensical notes jotted on this page.

@chockenberry
chockenberry / AttributedString.swift
Created June 1, 2022 21:08
A playground that shows how to use Swift's AttributedString with Markdown
import UIKit
import Foundation
// NOTE: This playground shows how to use Swift's AttributedString with Markdown.
//
// This code was used to display Markdown content in the Tot iOS Widget <https://tot.rocks>
// MARK: - Helpful Links
// NOTE: The following links helped me figure this stuff out.
@christianselig
christianselig / swift-async-await-example.swift
Created February 28, 2022 20:46
Some questions about async await threading in Swift's new concurrency model.
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
Task {
// 1️⃣❓ UIViewController is in a MainActor context, so this Task
// will inherit that, so the following pretend expensive call will
// be on the main thread and likely block?
ExpensiveOperationPerformer.doExpensiveLoopAndPrint()
}
@viercc
viercc / gist:37b66810257fce0489c7ffff05fbb873
Last active February 4, 2022 05:01
反対圏でのstrength
@Lysxia
Lysxia / NoZipListMonad.v
Last active May 4, 2022 10:09
There is no ZipList monad, proved in Coq; thread https://twitter.com/lysxia/status/1451202791796584454
(** Coq proof that there is no monad compatible with the ZipList applicative functor. *)
(** Based on the original proof by Koji Miyazato https://gist.github.com/viercc/38853067c893f7ad9e0894abb543178b *)
(** Main theorem: [No_LawfulJoin : forall join, ~(LawfulJoin join)]
where [~] means "not" and [LawfulJoin] is the conjunction of the following properties (monad laws):
1. [join] is associative:
join (join xs) = join (map join xs)]
2. [join] is compatible with ZipList's applicative (i.e., [zip_with]):