Skip to content

Instantly share code, notes, and snippets.

Avatar

Alexander von Below below

  • Deutsche Telekom AG
  • Köln, Germany
View GitHub Profile
@below
below / gist:1501383
Created Dec 20, 2011
Simple Script to set a version number in the Info Plist
View gist:1501383
# This needs to go into a script build phase prior to "Copying resources"
# Set the version from version.txt
product_version=`cat version.txt`
# Instead of version.txt, you can use whatever your filthy heart desires
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion \"$product_version\"" "$TARGET_BUILD_DIR/$INFOPLIST_PATH"
exit 0
@below
below / gist:3447720
Created Aug 24, 2012
Make less do more in OS X Terminal
View gist:3447720
# Configure less to register the represented file with the terminal.
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
export LESS='-P?n?f'"$(printf '\e]6;%%f\a')"'%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x..%t'
fi
@below
below / pseudo
Created Oct 21, 2013
Total Pseudocode
View pseudo
BOOL compilerSwitch = NO;
#ifdef __FOOCOMPILERDEFINE__
compilerSwitch = YES;
#endif
if (compilerSwitch || [self someOtherActivationLikeInAppPurchaseOrYouNameIt]) {
[MrScott energize];
}
@below
below / gist:7419166
Created Nov 11, 2013
Also er baut, und dann kommt plötzlich (und ohne Ausführung der Tests):
View gist:7419166
** TEST SUCCEEDED **
[FOO] $ /bin/bash -xe /var/folders/kx/gv59n06j26n3n1fwxsxctb_m0000gq/T/hudson2864317743272309338.sh
Recording test results
No test report files were found. Configuration error?
Build step 'Publish JUnit test result report' changed build result to FAILURE
Finished: FAILURE`
View gist:c12a68772110613cbc77
I would think my question is pretty easy, as what I am trying to do seems like a very common use case.
There are two entities, "Speaker" and "Session". And the Speaker has a to-many relationship, "sessions", with an inverse in the Session entity. So a Speaker can be related to many sessions, and a Session can have many speakers.
My problem is in the UI: I have an NSArrayController, "SpeakerSessionController", its purpose is to show the sessions currently associated with the selected speaker. So the goal was to set its content array to the sessions key of the selection of my "SpeakerController". That does not work natively (neither does setting the content set), so I threw in a value transformer to transform the _NSMutableFaultingSet to an NSArray.
So far, so good. I can now add a session to the speaker it seems, putting a breakpoint into the value transformer shows me that there is an object.
But it is not shown in the table view that should be listing all the sessions for the selected speaker. Where am I
View swift try
import Foundation
var str = "https://github.com/robelkin/altconf-data/raw/master/sessions.json"
let url = NSURL(string:str)
var error : NSErrorPointer = nil
if (url != nil) {
let jsonData = NSData(contentsOfURL: url!, options: .Data, error: error)
View gist:b862564fb24dd07d0c87
var trust : Unmanaged<SecTrust>?
let status : OSStatus = SecTrustCreateWithCertificates(nil, nil, &trust)
let certificate = SecTrustGetCertificateAtIndex(trust?.takeUnretainedValue(), 0)
let serverCertData = SecCertificateCopyData(certificate).takeUnretainedValue()
/*
error: cannot convert the expression's type 'CFData' to type '$T6'
let serverCertData = SecCertificateCopyData(certificate).takeUnretainedValue()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
*/
View gist:1192cb4cb613c13c3e54
- (void) bar {
SEL selector = @selector(foo);
typedef void (send_type) (id, SEL);
send_type func = (send_type)objc_msgSend();
func (self, selector);
}
foobar.m:25:22: error: used type 'send_type' (aka 'void (__strong id, SEL)') where arithmetic or pointer type is required
send_type func = (send_type)objc_msgSend();
@below
below / FileHandle.playground
Created Oct 28, 2014
Swift FileHandle Test
View FileHandle.playground
// Playground - noun: a place where people can play
import Cocoa
import XCPlayground
let path = XCPSharedDataDirectoryPath + "log.txt"
let fileURL = NSURL(fileURLWithPath: path)
if (fileURL != nil) {
var error : NSError? = nil;
let fileHandle = NSFileHandle(forWritingToURL: fileURL!, error:&error)
View gist:475cdfd44550496e0aff
import UIKit
protocol myProtocol {
func dothatthing () -> Void
}
var array : [protocol<myProtocol>] = []
class A : myProtocol {
func dothatthing() {
You can’t perform that action at this time.