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
public class GameModel : MonoBehaviour { | |
public FloatReactiveProperty Score { get; private set; } | |
void Awake() { | |
Score = new FloatReactiveProperty(0f).AddTo(this); | |
} | |
} | |
public class ScoreUI : 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
// Define our shapes. | |
trait Shape | |
class Rectangle extends Shape | |
class Ellipse extends Shape | |
class Triangle extends Shape | |
object Shape { | |
// The method we'll call to perform an intersection. | |
def intersect[A <: Shape, B <: Shape](a: A, b: B)(implicit ev: Intersection[A,B]): Unit = { |
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
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
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | |
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntelliSenseCompletingCharacters/CSharpCompletingCharacters/UpgradedFromVSSettings/@EntryValue">True</s:Boolean> | |
<s:Boolean x:Key="/Default/CodeInspection/Highlighting/IdentifierHighlightingEnabled/@EntryValue">True</s:Boolean> | |
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestVarOrType_005FSimpleTypes/@EntryIndexedValue">DO_NOT_SHOW</s:String> | |
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UnassignedField_002ECompiler/@EntryIndexedValue">DO_NOT_SHOW</s:String> | |
<s:String x:Key="/Default/CodeStyle/CodeCleanup/RecentlyUsedProfile/@EntryValue">Default: Reformat Code</s:String> | |
<s:String x:Key="/Defaul |
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
// 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
// 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
// Without optional chaining. | |
export const getInstance = async (instanceId: string): Promise<Instance> => { | |
const result = await ec2Client | |
.describeInstances({ InstanceIds: [instanceId] }) | |
.promise() | |
if (!result.Reservations) { | |
throw new Error(`Could not find instance ${instanceId}`) | |
} | |
if (result.Reservations.length > 1) { |
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
// This file would go in your source path, e.g.: src/window.d.ts | |
declare interface Window { | |
foo: string | |
} |