Skip to content

Instantly share code, notes, and snippets.

Rob Fahrni Fahrni

Block or report user

Report or block Fahrni

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View CreatorExample.swift
fileprivate func displayOptionsViewController() {
guard let optionsViewController = OptionsViewController.create(completionBlock: optionsCompletionHandler) else {
NSLog("Failed to create OptionsViewController, whoops")
return
}
self.show(optionsViewController, sender: nil)
self.optionsViewController = optionsViewController as? OptionsViewController
}
View CreatorExtensionSample.swift
extension OptionsViewController {
class func create(completionBlock: @escaping OptionsCompletionHandler) -> UIViewController? {
let storyboard = UIStoryboard(name: "Options", bundle: nil)
guard let vc =
storyboard.instantiateViewController(withIdentifier:"OptionsViewController") as? OptionsViewController else {
return nil
}
vc.completionBlock = completionBlock
return vc
}
@Fahrni
Fahrni / CCswiftTest.swift
Last active Nov 20, 2016
Using Objective-C++ from Swift
View CCswiftTest.swift
func testCreateDeleteMaleCalculate() {
guard let cc = PKMCreatinineClearance(40, height: 75, weight: 70, scr: 1.0, gender: PKMMale) else {
XCTFail("Create Creatinine Clearance Male Instance failed")
return
}
let clcr = cc.calculate()
XCTAssertEqualWithAccuracy(clcr, 97.2, accuracy: 0.2, "Male clcr should be around 97.2, range allowed to be +/- 0.2")
}
@Fahrni
Fahrni / CCbridgeCode.mm
Created Nov 20, 2016
Objective-C++ bridge to C++ Creatinine Clearance calculation
View CCbridgeCode.mm
#import "PKMCreatinineClearance.h"
#import "PKMConvert.h"
#import "CreatinineClearance.h"
@interface PKMCreatinineClearance ()
@property (nonatomic, assign) PKMath::CreatinineClearance* ccInstance;
@end
@implementation PKMCreatinineClearance
@Fahrni
Fahrni / ACLMessageDispatch.cpp
Last active May 28, 2016
ACL Library Message Dispatch Mechanism
View ACLMessageDispatch.cpp
LRESULT ACLWinBase::DispatchMessage
(
IN UINT uMsg,
IN WPARAM wParam,
IN LPARAM lParam
)
{
LRESULT lResult(1);
UINT uSubMsg(WM_NULL); // By default this really isn't looked at.
@Fahrni
Fahrni / BaseClassWindowProc.cpp
Last active May 28, 2016
Base Class Window Procedure
View BaseClassWindowProc.cpp
EXTERNC ACLWINCB(LRESULT) ACLWindowDispatchProc
(
IN HWND hWnd,
IN UINT uMsg,
IN WPARAM wParam,
IN LPARAM lParam
)
{
UNALIGNED ACLWinBase* pWindow = NULL;
PWINMSGHNDLR pHandler = NULL;
@Fahrni
Fahrni / NewSchoolWindowProc.cpp
Last active May 28, 2016
Window Proc built in C++ using ACL Window Library
View NewSchoolWindowProc.cpp
static ACLWinMessageMap stcMsgMap[] =
// message sub msg/ctl id message handler method.
//
{ { WM_CREATE, WM_NULL, (PWINMSGHNDLR)&SampleWindow::OnCreate }
, { WM_DESTROY, WM_NULL, (PWINMSGHNDLR)&SampleWindow::OnDestroy }
, { WM_COMMAND, IDM_ABOUT, (PWINMSGHNDLR)&SampleWindow::OnAbout }
, { WM_COMMAND, IDM_EXIT, (PWINMSGHNDLR)&SampleWindow::OnExit }
, { WM_SIZE, WM_NULL, (PWINMSGHNDLR)&SampleWindow::OnResize }
}; // stcMsgMap
@Fahrni
Fahrni / OldSchoolWindowProc.c
Last active May 28, 2016
Old school Window Procedure
View OldSchoolWindowProc.c
LRESULT CALLBACK WindowProc
(
HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam
)
{
switch (message)
{
View gist:14650fd5a65a21798570
static void FizzBuzz()
{
static int kBufferMax = 256;
char outputBuffer[kBufferMax];
for (int x = 1; x <= 100; x++)
{
memset(&outputBuffer, 0, kBufferMax);
if (0 == (x % 3))
You can’t perform that action at this time.