Skip to content

Instantly share code, notes, and snippets.

View danwood's full-sized avatar

Dan Wood danwood

View GitHub Profile
@danwood
danwood / SpotifyAPIExampleApp-PKCE.patch
Last active January 23, 2024 19:45
Patch Peter-Schorn/SpotifyAPIExampleApp to use Authorization Code Flow with PKCE, for users of Peter-Schorn/SpotifyAPI
diff -crB -x S SpotifyAPIExampleApp-main/SpotifyAPIExampleApp/Model/Spotify.swift SpotifyAPIExampleApp-PKCE/SpotifyAPIExampleApp/Model/Spotify.swift
*** SpotifyAPIExampleApp-main/SpotifyAPIExampleApp/Model/Spotify.swift Thu Feb 16 22:38:40 2023
--- SpotifyAPIExampleApp-PKCE/SpotifyAPIExampleApp/Model/Spotify.swift Tue Jan 23 11:35:44 2024
***************
*** 22,35 ****
fatalError("Could not find 'CLIENT_ID' in environment variables")
}()
- private static let clientSecret: String = {
- if let clientSecret = ProcessInfo.processInfo
- (void)ks_tryToMakeObjectsPerformSelector:(SEL)selector withObject:(id)object;
{
for (id <NSObject> anObject in self)
{
if ([anObject respondsToSelector:selector])
{
[anObject performSelector:selector withObject:object];
}
}
}
@danwood
danwood / gist:2481732
Created April 24, 2012 17:27
Base 64 Encoding/Decoding
+ (NSData *)dataWithBase64EncodedString:(NSString *)base64String
{
NSData *retVal = nil;
if([base64String canBeConvertedToEncoding:NSASCIIStringEncoding])
{
NSData *stringData = [base64String dataUsingEncoding: NSASCIIStringEncoding];
/* base64 decode
* in -- input data
@danwood
danwood / gist:1513093
Created December 23, 2011 04:03
Scroll the the bottom if you are at the bottom
- (void) scrollToVisible:(id)unused
{
// Only show bottom if we are already scrolled down at/near the bottom.
NSScrollView *scrollView = [oLog enclosingScrollView];
NSPoint currentScrollPosition=[[scrollView contentView] bounds].origin;
float diff = oLog.frame.size.height - (scrollView.contentSize.height + currentScrollPosition.y);
if (diff < 50) // Seems like it's often 39 when we're at the bottom, so give some slack.
{
// [oLog scrollRangeToVisible:NSMakeRange([[oLog textStorage] length], 0)];