Skip to content

Instantly share code, notes, and snippets.

View below's full-sized avatar
💭
I love feedback on my ARM64 Repo

Alexander von Below below

💭
I love feedback on my ARM64 Repo
View GitHub Profile
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
@below
below / swift try
Last active August 29, 2015 14:02
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)
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()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
*/
@below
below / gist:1192cb4cb613c13c3e54
Created September 24, 2014 14:19
objc_msgSend
- (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 October 28, 2014 12:41
Swift FileHandle Test
// 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)
import UIKit
protocol myProtocol {
func dothatthing () -> Void
}
var array : [protocol<myProtocol>] = []
class A : myProtocol {
func dothatthing() {
@below
below / gist:e57cfb9323a5ef360e93
Created March 23, 2015 20:36
No longer working in Swift 1.2
// In Swift 1.1, I can use "let sideshow : Sideshow!". In Swift 1.2 it has to be a var
// Is this due to the change:
// "In an initializer, constant properties can now only assign a value once." ?
class Main {
var name : String
let sideshow : ImplicitlyUnwrappedOptional<Sideshow>
init (name : String, referenceName : String) {
self.name = name
self.sideshow = Sideshow(name: referenceName, ref: self)
#include <boost/shared_ptr.hpp>
#include <configuration/api/IConfigurationReport.hpp>
namespace whisper
{
namespace configuration
{
using boost::shared_ptr;
using whisper::configuration::PConfigurationReport;
@below
below / gist:2b9babcae6aee20c6bae
Created April 8, 2015 10:52
What … gives?
Dyld Error Message:
Library not loaded: @rpath/libswiftCore.dylib
Referenced from: /private/var/mobile/Containers/Bundle/Application/AC0A08F8-3993-48F2-A1EF-9188AC8C19BA/XYZ.app/XYZ
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/AC0A08F8-3993-48F2-A1EF-9188AC8C19BA/XYZ.app/Frameworks/libswiftCore.dylib: mmap() error 1 at address=0x1004E8000, size=0x0018C000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/AC0A08F8-3993-48F2-A1EF-9188AC8C19BA/XYZ.app/Frameworks/libswiftCore.dylib
Dyld Version: 353.12
@below
below / gist:cfc8ac57458cce66b137
Created May 14, 2015 10:36
I should admit that I don't regularly work in ruby, so I am pretty stuck here. I am trying to download a https url using NET::HTTP:get, and I get this error. Downloading the URL in curl (even if called from the script) works just fine. What to do?
/Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/http.rb:920:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
from /Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/http.rb:920:in `block in connect'
from /Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/timeout.rb:76:in `timeout'
from /Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/http.rb:920:in `connect'
from /Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
from /Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/http.rb:852:in `start'
from /Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/http.rb:583:in `start'
from /Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/http.rb:478:in `get_response'
from /Users/below/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/net/http.rb:455:in `get'
from export.rb:4:in `<main>'