Skip to content

Instantly share code, notes, and snippets.


Keybase proof

I hereby claim:

  • I am ndurell on github.
  • I am ndurell ( on keybase.
  • I have a public key ASD0kOZ-goL-15d8OGtpW-7l2DFasfT6Zbm_yIgd9T4NrQo

To claim this, I am signing this object:

ndurell / github.swift
Created Nov 27, 2018
point free caching github api example
View github.swift
let cachingGitHub = CachingGitHub()
struct GitHub {
var latestRepos: () -> [Repo] = { return cachingGitHub.latestRepos }
var fetchRepos: (@escaping (Result<[Repo], APIError>) -> Void) -> Void = cachingGitHub.fetchRepos
class CachingGitHub {
var latestRepos = [Repo]()
func fetchRepos(completion: @escaping (Result<[Repo], APIError>) -> Void) {
ndurell / example.swift
Created Aug 25, 2017
Weak self example
View example.swift
create(image: image) { [weak self] key, error in
guard let `self` = self else {
if let error = error {
self.completion?(nil, error)
self.completion = nil
ndurell / stuff.swift
Created Apr 26, 2017
Instructions for reading a file from the bundle
View stuff.swift
let path : URL = Bundle.main.path(forResource: "scifi-novels", ofType: "json").flatMap {
URL.init(fileURLWithPath: $0)
let data = try! Data(contentsOf: path)
let json = try! JSONSerialization.jsonObject(with: data) as? [String: Any]
ndurell /
Last active May 23, 2016
Gist detail how we use Fused Location Provid

Build google api client:

m_googleApiClient = builder.

The location request looks like this:

ndurell /
Last active Jan 4, 2016
This gist demonstrates how to log an action using the SessionM SDK. Actions trigger achievements which allow to you reward your users for performing actions in your app. Go to for more info.
package com.sessionm.example;
import com.sessionm.api.SessionM;
public class MyClass {
public void myAwesomeMethod() {
ndurell /
Last active Jan 4, 2016
This sample activity shows how to extend the SessionM BaseActivity conveinence class.
import com.sessionm.api.BaseActivity;
//Just extend the BaseActivity class.
//This will automatically make lifecycle calls for you.
public class MainActivity extends BaseActivity {
protected void onCreate(Bundle savedInstanceState) {
ndurell / proguard.cfg
Last active Jan 4, 2016
This show what to add to your proguard config for SessionM.
View proguard.cfg
-dontwarn com.unity3d.player.**
-keep class com.sessionm.ui.** {*;}
ndurell / AndroidManifest.xml
Last active Jan 4, 2016
The sample manifest shows what to include in your manifest for a SessionM integration.
View AndroidManifest.xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android=""
android:versionName="1.0.0" >
android:targetSdkVersion="19" />
<!-- SessionM NOTE: These permissions are required for SessionM -->
<uses-permission android:name="android.permission.INTERNET" />
ndurell / MyViewController.m
Last active Jan 3, 2016
This demonstrates how to instantiate and add a portal button to your a view. This uses the SMPortalButton convenience class.
View MyViewController.m
#import "SMPortalButton.h"
@implementation MyViewController
- (void)viewDidLoad
[super viewDidLoad];
SMPortalButton *portalButton=[SMPortalButton buttonWithType:UIButtonTypeSystem];
[portalButton.button setTitle:@"Portal Button" forState:UIControlStateNormal];
portalButton.frame = CGRectMake(40, 40, 100, 30);