This file contains hidden or 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
| open ReactDOM | |
| module MyComponent = struct | |
| (* Component Properties *) | |
| type props = {count: int} | |
| (* Hey, state can be any type! *) | |
| type state = string | |
| (* Initializer *) |
This file contains hidden or 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
| const lockfileSpecs = [ | |
| { | |
| checkfile: ".yarnrc.yml", | |
| lockfile: "yarn.lock", | |
| command: "yarn", | |
| version: "2", | |
| arguments: ["install", "--immutable"] | |
| }, | |
| { | |
| checkfile: "yarn.lock", |
This file contains hidden or 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
| box( | |
| { | |
| padding: 5, | |
| width: "320px", | |
| border: "sm", | |
| onClick: onClick, | |
| onMouseLeave: onMouseLeave, | |
| }, | |
| [ | |
| stack({ gap: 2, align: "center" }, [ |
This file contains hidden or 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
| npx bsc -dparsetree wat.res | |
| npx bsc -dparsetree wat.ml | |
| npx bsc -format wat.ml |
This file contains hidden or 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
| open Ppxlib | |
| module Builder = Ast_builder.Default | |
| type target = Native | Js | |
| let mode = ref Native | |
| module Effect = struct | |
| (* TODO: [%effect] is a little incomplete, only works with useEffect0 (not other useEffectX, neither useLayoutEffects) *) | |
| let extractor = Ast_pattern.(__') |
This file contains hidden or 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
| dev: | |
| npx http-server -o . |
This file contains hidden or 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 type defines a value that 'depends' on the screen size, and changes based on `window.matchMedia` */ | |
| type dependant('value) = { | |
| default: 'value, | |
| mobile: option('value), /* 800px */ | |
| desktop: option('value), /* 1200px */ | |
| huge: option('value) /* 1900px */ | |
| }; | |
| type t('value) = | |
| | Fixed('value) |
This file contains hidden or 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
| (* | |
| TODO: If we want to remove the dependency on of_json, we need to implement the json decoder manually. | |
| TODO: Maybe use a custom deriving called "rsc" or similar where it handles the JSON/Promise/React.element. *) | |
| let rec make_of_json ~loc (type_ : core_type) value = | |
| match type_.ptyp_desc with | |
| | Ptyp_constr ({ txt = Lident "int"; _ }, _) -> value | |
| | Ptyp_constr ({ txt = Lident "string"; _ }, _) -> value | |
| | Ptyp_constr ({ txt = Lident "bool"; _ }, _) -> value | |
| | Ptyp_constr ({ txt = Lident "float"; _ }, _) -> value |
This file contains hidden or 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
| [@@@warning "-27"] | |
| let get_memory_info () = | |
| let ic = open_in "/proc/self/status" in | |
| let rec read_lines rss vmsize = | |
| try | |
| let line = input_line ic in | |
| if String.starts_with ~prefix:"VmRSS:" line then | |
| let rss_kb = String.sub line 6 (String.length line - 9) |> String.trim |> int_of_string in | |
| read_lines (Some rss_kb) vmsize |
This file contains hidden or 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
| .PHONY: help # Set default action to be help! | |
| help: | |
| @echo "List of available make commands"; | |
| @echo ""; | |
| @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'; | |
| @echo ""; | |
| # Add double ## comments on the same line as the dependencies and will be printed out when running help | |
| # Don't add them if you don't want to appear on help! |
OlderNewer