This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// user/store.ts | |
import * as Redux from 'redux' | |
import { anonymous, authenticated, User, UserData } from './User' | |
/* State */ | |
export interface State { | |
readonly user: User | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Let's assume we're writing our own Option type (in practice, you should probably use fp-ts or something). | |
export abstract class Option<T> { | |
public abstract map<U>(f: (t: T) => U): Option<U> | |
} | |
// Some needs a type parameter so we know what value it has. | |
export class Some<T> extends Option<T> { | |
constructor(public readonly value: T) { | |
super() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First the solution as provided, using UniRx. | |
public class ObservablesExample { | |
// The CatalogInfo, this is non-null immediately after calling LoadCatalog(). | |
public IObservable<CatalogInfo> CatalogInfo; | |
// Helper methods, where the work of loading is done. | |
// UniRx makes it painless to execute these off the main thread. | |
// Errors are handled by Observable.OnError | |
private IObservable<CatalogInfo> LoadFromPlayFab() { /* ... */ } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Login { | |
public static partial class Login { | |
// Call this from the outside to log in | |
public static void LogIn() { | |
DoLogIn(); | |
} | |
// Implementation delegate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os, subprocess, json | |
# Get all bookmarks matching the given name(s) | |
def get_bookmarks(profile_dir, names): | |
with open(os.path.join(profile_dir, 'Bookmarks')) as f: | |
j = json.load(f) | |
results = [] | |
# There are two root-level bookmark folders: one for the bookmark bar and one for all others. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def details(since: Option[LocalDate], until: Option[LocalDate], page: Int): Future[NumberedDetailsPage] = { ... } | |
details(since, until, 1).flatMap { page1 => | |
val pagesFuture = Future.sequence( | |
for { | |
n <- (2 to page1.details.totalPages).toList | |
} yield { | |
details(since, until, n) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reflection; | |
using UnityEditor; | |
using UnityEngine; | |
// I recommend dropping this script in an Editor folder. | |
// You should have two audio clips somewhere in the project. | |
// You'll need to edit-in the paths of those clips (from your project root folder) in the static initializer below. | |
// Example path: "Assets/Editor/CompileIndicator/start.mp3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UniRx; | |
using UniRx.Triggers; | |
namespace Assets.Scripts.v3 { | |
public class InputsV3 : MonoBehaviour { | |
// Singleton. | |
public static InputsV3 Instance { get; private set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UniRx; | |
using UniRx.Triggers; | |
// NOTE: Unity won't actually let you put two MonoBehaviours in one file. | |
// They're both listed here just for convenience. | |
namespace Assets.Scripts.v2 { | |
public class InputsV2 : MonoBehaviour { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UniRx; | |
using UniRx.Triggers; | |
// NOTE: Unity won't actually let you put two MonoBehaviours in one file. | |
// They're both listed here just for convenience. | |
namespace Assets.Scripts.v1 { | |
public class InputsV1 : MonoBehaviour { |