Skip to content

Instantly share code, notes, and snippets.

View claybridges's full-sized avatar
✌️
peace

Clay Bridges claybridges

✌️
peace
View GitHub Profile
@claybridges
claybridges / gist:8ca22217830e0ce1a0f1
Last active October 12, 2016 02:06
Just an easier format for code from this SO question (not mine): http://stackoverflow.com/questions/25311736.
- (void) addTasksToSessionWithTaskObject:(Task*)taskObject withSessionInitialisationNeeded:(BOOL) needed{
NSString *filePath = [[NSBundle mainBundle] pathForResource:pathForResourceFile ofType:resourceFileType];
S3PutObjectRequest *putObjectRequest = [[S3PutObjectRequest alloc] initWithKey:targetFileKey
inBucket:_bucketname];
putObjectRequest.cannedACL = [S3CannedACL publicReadWrite];
putObjectRequest.filename = filePath;
putObjectRequest.contentType = [resourceFileType isEqualToString:@"MOV"] ? @"movie/mov" : @"image/jpg";
putObjectRequest.endpoint = @"http://s3.amazonaws.com";
putObjectRequest.contentLength=[[[NSFileManager defaultManager]
@claybridges
claybridges / gist:c289d5fa6e3e386e8921
Last active November 15, 2023 18:10
Use rvm in a shell script
#!/usr/bin/env bash
# Xcode scripting does not invoke rvm. To get the correct ruby,
# we must invoke rvm manually. This requires loading the rvm
# *shell function*, which can manipulate the active shell-script
# environment.
# cf. http://rvm.io/workflow/scripting
# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
FROM XCODE CONSOLE:
*** Unable to run app in Simulator If you believe this error represents a bug, please attach the log file at /var/folders/74/k54kppb928s963936by98fzm0000gn/T/com.apple.dt.XCTest-status/Session-2014-11-21_13:05:32-Rla0wx.log
FROM THAT LOG FILE:
2014-11-21 13:05:32.265 Beginning test session with Xcode 6A1052c
2014-11-21 13:05:32.265 Testing on device: <DVTiPhoneSimulator: 0x7fa48133f4b0> {
SimDevice: SimDevice : RedactedName.PhotoTest (3219C047-04CE-41BF-9BE4-F200B2BE25C1) : state={ Booted } deviceType={ SimDeviceType : com.apple.CoreSimulator.SimDeviceType.iPhone-6 } runtime={ SimRuntime : 8.1 (12B411) - com.apple.CoreSimulator.SimRuntime.iOS-8-1 }
}
@claybridges
claybridges / WKPreferences+DevExtras.h
Created November 27, 2014 02:25
Allows setting of WKPreferences.developerExtrasEnabled flag
@import WebKit;
@interface WKPreferences (DevExtras)
@property (nonatomic, setter=_setDeveloperExtrasEnabled:) BOOL _developerExtrasEnabled;
- (void)enableDevExtras;
@end1
(defn center-y-for-note
; arity = 2
([{:keys [origin size]} note]
(let [{:keys [height]} size]
(center-y-for-note (origin :y) (size :height) note)))
; arity = 3
([origin-y height note]
(let [note-increment (/ height 8)
ymin (+ origin-y height)]
@claybridges
claybridges / save_xcode_for_el_cap.bash
Last active August 29, 2015 14:26
Xcode 6.4 and Xcode 7 beta 4 both stopped working with OS X El Cap beta 6. This seems to fix it. See comments for deets. Requires a sudo password, don't be freaked out.
#!/usr/bin/env bash
#
# Based on original solution by user lembacon, here:
# https://forums.developer.apple.com/thread/13170?start=105&tstart=0
# Watch fix added by user Richie__.
#
# Created by Clay Bridges, 5 Aug 2015
move_dyld_sim()
{
@claybridges
claybridges / xcbuild-safe.sh
Last active September 26, 2018 18:21
Drop in replacement/wrapper for xcodebuild, fixes Xcode 7 build dependency on system ruby vs. rvm. Explained further @ http://stackoverflow.com/questions/33041109.
#!/bin/bash --login
# Cf. http://stackoverflow.com/questions/33041109
#
# Xcode 7 (incl. 7.0.1) seems to have a dependency on the system ruby.
# xcodebuild is screwed up by using rvm to map to another non-system
# ruby†. This script is a fix that allows you call xcodebuild in a
# "safe" rvm environment, but will not (AFAIK) affect the "external"
# rvm setting.
#
@claybridges
claybridges / DefaultUsingBackingStore.swift
Created November 18, 2019 21:14
Property Wrapper Question
var defaultNum = 1
class MyClass {
var num: Int {
get { _num ?? defaultNum }
set { _num = newValue }
}
private var _num: Int?
}

Notification observations and handlers

For a class, each notification observation should be handled by a single method. The name of that method should be handle appended with the name of the notification being observed. For instance, for notification name

NSNotification.Name.LUUICachedPaymentMethodDidUpdate

the handler would be

private func handleCachedPaymentMethodDidUpdate(...)
@claybridges
claybridges / failure.txt
Last active April 25, 2022 13:48
RVM failure
$ ./rvm_test.sh
+ installRvmFunction
+ local found=0
+ for rvmScript in '"$HOME/.rvm/scripts/rvm"' /usr/local/rvm/scripts/rvm
+ '[' -s /Users/clay/.rvm/scripts/rvm ']'
+ . /Users/clay/.rvm/scripts/rvm
++ builtin test -n '3.2.57(1)-release' -o -n '' -o -n ''
++ case "`uname`" in
+++ uname
+++ command ps -p 31878 -o ucomm=