Skip to content

Instantly share code, notes, and snippets.

View surrealroad's full-sized avatar

Jack James surrealroad

View GitHub Profile
@Cikmo
Cikmo / README.md
Last active April 18, 2025 11:19
Connection handler that keeps Supabase Realtime channels alive. It automatically reconnects after errors, handles reauthentication, and more.

I had some issues getting a reliable connection up. Made this after a lot of experimentation and it now works well.

Includes how to keep the connection alive when the document is not visible, handles reconnecting on errors, and also fixes certain authentication issues when coming back to a document that has not been visible while the token expired.

To use it, you pass in a factory function for your RealtimeChannel. Do not call .subscribe() on the channel, the handler will do this for you. See example.

PS: If you're not using supabase-js you'll need to change stuff a bit. Instead of passing in SupabaseClient switch it to use RealtimeClient, and update the refreshSessionIfNeeded method to your authentication implementation.

If you see any problems or have suggestions for improvements, please leave a comment.

@erikdoe
erikdoe / CCMKeychainHelper.m
Last active March 17, 2023 18:06
It took me way too long to wade through Keychain documentation and examples, but, finally, I got to a sane implementation of a basic Objective-C interface for managing internet passwords in Keychain. This is from my CCMenu project (http://ccmenu.org).
#import "CCMKeychainHelper.h"
@implementation CCMKeychainHelper
+ (BOOL)setPassword:(NSString *)password forURLString:(NSString *)aString error:(NSError **)errorPtr
{
return [self setPassword:password forURL:[NSURL URLWithString:aString] error:errorPtr];
}
+ (BOOL)setPassword:(NSString *)password forURL:(NSURL *)aURL error:(NSError **)errorPtr
@andyvanee
andyvanee / MyModule.py
Created September 20, 2012 07:26
Embed Python in Objective-C (without PyObjC)
def my_func():
return "embedding?"