Skip to content

Instantly share code, notes, and snippets.

View spnkr's full-sized avatar

Will Jessop spnkr

  • New York, NY
View GitHub Profile
@spnkr
spnkr / #ChatGPT Streaming.md
Created March 5, 2024 14:25 — 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.

import Foundation
infix operator +=! { associativity right precedence 90 } // Int32 or Int64
infix operator -=! { associativity right precedence 90 } // Int32 or Int64
postfix operator ++! {} // Int32 or Int64
postfix operator --! {} // Int32 or Int64
infix operator |=! { associativity right precedence 90 } // UInt32
infix operator &=! { associativity right precedence 90 } // UInt32
//
// BottomSheetView.swift
//
// Created by Majid Jabrayilov
// Copyright © 2019 Majid Jabrayilov. All rights reserved.
//
import SwiftUI
fileprivate enum Constants {
static let radius: CGFloat = 16

Sony Bravia HTTP API

The sony bravia has a HTTP API interacted with using a Pre-Shared key. There's a more complex auth flow but I've not described it here.

There wasn't any documentation, so I've written some. If you're a TV integrator don't read this, you'll laugh. I'm probably just getting confused by UPnP.

Disclaimer: I've only tested this on my TV, which is a KDL-50W829B. Your TV might not have all of the services; see Available services section for how to discover what your TV supports.

@spnkr
spnkr / logNSNotifications.m
Created December 30, 2022 10:58 — forked from DavidNix/logNSNotifications.m
Log all NSNotifications as they are fired
static void LogNSNotifications(CFNotificationCenterRef center,
void *observer,
CFStringRef name,
const void *object,
CFDictionaryRef userInfo);
void LogNSNotifications(CFNotificationCenterRef center,
void *observer,
CFStringRef name,
const void *object,
class Singleton {
// singelton pattern
private static var privateShared : Singleton?
class func shared() -> Singleton {
// make sure we get an instance from the singleton queue
guard let uwShared = read(privateShared) else {
privateShared = Singleton()
return privateShared!
@spnkr
spnkr / github_issues_to_csv.rb
Created July 1, 2021 07:14 — forked from henare/github_issues_to_csv.rb
Exports Github issues to CSV so it can be imported into Jira
require 'json'
require 'open-uri'
require 'csv'
require 'date'
# Github credentials to access your private project
USERNAME="myusername"
PASSWORD="mypassword"
# Project you want to export issues from
@spnkr
spnkr / universal-framework.sh
Created September 23, 2020 07:15 — forked from cromandini/universal-framework.sh
This run script will build the iphoneos and iphonesimulator schemes and then combine them into a single framework using the lipo tool (including all the Swift module architectures).
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
@spnkr
spnkr / lg_portable_ac_device_info.json
Created July 21, 2020 09:47 — forked from ThatWileyGuy/lg_portable_ac_device_info.json
LG SmartThinq V2 Device Information for a Portable AC
{
"Info": {
"productType": "AC",
"country": "KR",
"modelType": "POT",
"model": "Full ModelJson",
"modelName": "Full Model",
"networkType": "WIFI",
"version": "10.53",
"productCode": "AI01"
@spnkr
spnkr / CoreDataContextObserver.swift
Last active August 5, 2020 15:51 — forked from m1entus/CoreDataContextObserver.swift
CoreDataContextObserver
//
// CoreDataContextWatcher.swift
// ContextWatcher
//
// Created by Michal Zaborowski on 10.05.2016.
// Copyright © 2016 Inspace Labs Sp z o. o. Spółka Komandytowa. All rights reserved.
//. v4
import Foundation
import CoreData