Skip to content

Instantly share code, notes, and snippets.

View aminnj's full-sized avatar

Nick Amin aminnj

  • Austin, TX
View GitHub Profile
@aminnj
aminnj / mac_sd_preview.ipynb
Last active March 20, 2024 05:54
SDXL on Mac M1 with live previews
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aminnj
aminnj / mlx-mistral-layer-splicing.patch
Last active January 13, 2024 23:32
Evaluate layers based on a list of indices with MLX
diff --git a/llms/mistral/mistral.py b/llms/mistral/mistral.py
index 9b9a602..5fd5146 100644
--- a/llms/mistral/mistral.py
+++ b/llms/mistral/mistral.py
@@ -144,6 +144,7 @@ class Mistral(nn.Module):
self.layers = [TransformerBlock(args=args) for _ in range(args.n_layers)]
self.norm = RMSNorm(args.dim, eps=args.norm_eps)
self.output = nn.Linear(args.dim, args.vocab_size, bias=False)
+ self.ilayers = list(range(len(self.layers)))
@aminnj
aminnj / mac_tts.py
Last active March 24, 2024 21:16
TTS on Mac
import time
import objc
from Foundation import NSObject, NSRunLoop, NSDate
import AVFoundation
import Cocoa
# https://gitlab.com/gltd/say-cocoa/-/blob/master/test.py?ref_type=heads
def main1():
class SpeechSynthesizerDelegate(NSObject):
@aminnj
aminnj / mac_stt.py
Created December 30, 2023 04:44
STT on Mac using Speech framework
from datetime import datetime, timedelta
from Speech import SFSpeechRecognizer, SFSpeechAudioBufferRecognitionRequest
from AppKit import NSRunLoop
from PyObjCTools import AppHelper
import AVFoundation
# https://developer.apple.com/documentation/speech/recognizing_speech_in_live_audio
@aminnj
aminnj / storywriter.ipynb
Last active March 20, 2024 05:41
Writing long stories with Gemini Pro
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aminnj
aminnj / corebluetooth.py
Last active November 28, 2023 17:36
Get RSSI of nearby bluetooth peripherals using CoreBluetooth in python
import rich
from Foundation import NSObject, NSRunLoop, NSDefaultRunLoopMode, NSDate, NSArray
from CoreBluetooth import CBCentralManager, CBCentralManagerStatePoweredOn, CBUUID
import time
state = {}
# Create a delegate to handle CoreBluetooth events
@aminnj
aminnj / heartbeat.html
Created November 23, 2023 05:32
Accelerometer-based heart beat detection
<!DOCTYPE html>
<html>
<head>
<title>Accelerometer Data</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
@aminnj
aminnj / accelerometer.html
Last active November 22, 2023 23:14
Display and save accelerometer data from mobile browser
<!DOCTYPE html>
<html>
<head>
<title>Accelerometer Data</title>
</head>
<body>
<div id="accelerometerData">
<p>Acceleration X: <span id="accelerationX"></span></p>
<p>Acceleration Y: <span id="accelerationY"></span></p>
@aminnj
aminnj / view_source_chrome.py
Created November 21, 2023 01:15
Get page source with running chrome instance in MacOS
import sys
import time
import objc
from ScriptingBridge import SBApplication
import Foundation
import AppKit
# Hide python rocket ship from popping up in Dock when run.
import AppKit
@aminnj
aminnj / awkward_duckdb.ipynb
Last active July 4, 2022 23:10
awkward array and duckdb querying
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.