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
// Implement a firestore data provider for react-admin | |
import { | |
GET_LIST, | |
GET_ONE, | |
CREATE, | |
UPDATE, | |
UPDATE_MANY, | |
DELETE, | |
DELETE_MANY, |
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
class FriendViewModel { | |
_personalId; | |
_friend; | |
constructor(personalId, friend) { | |
this._personalId = personalId; | |
this._friend = friend; | |
} | |
delete() { |
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
import {useFriend} from '../model/useFriend' | |
export function FriendLine ({friend}) { | |
const {fullname, deleteFriend} = useFriend(friend) | |
return (<tr> | |
<td>{fullname}</td> | |
<td><button onclick={deleteFriend} /></td> | |
</tr>); | |
} |
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
// Avec readux toolkit : | |
import { createSlice } from '@reduxjs/toolkit' | |
export const counterSlice = createSlice({ | |
name: 'counter', | |
initialState: { | |
value: 0, | |
}, | |
reducers: { | |
increment: (state) => { |
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
import { useEffect, useState } from "react"; | |
class EventBus<T> { | |
_handlers: Set<(t: T) => void> = new Set(); | |
subscribe(handler: (t: T) => void) { | |
this._handlers.add(handler); | |
} | |
unsubscribe(handler: (t: T) => void) { | |
this._handlers.delete(handler); | |
} |
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
import { makeAutoObservable } from "mobx"; | |
type Choice = { | |
id: number; | |
text: string; | |
}; | |
type Question = { | |
id: number; | |
text: string; |
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
import torch | |
import torch.nn as nn | |
class SelfAttention(nn.Module): | |
def __init__(self, embed_size, heads): | |
super(SelfAttention, self).__init__() | |
self.embed_size = embed_size | |
self.heads = heads | |
self.head_dim = embed_size // heads | |
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
import { match, P } from "ts-pattern"; | |
const headerBlocType = { | |
Header: "header", | |
Paragraph: "paragraph", | |
Image: "image", | |
} as const; | |
interface HeadBlockData { | |
text: string; |