Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Lan Qingyong lanqy

🎯
Focusing
Block or report user

Report or block lanqy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jdh30
jdh30 / JsonParser.fs
Last active Aug 20, 2019
Simple JSON parser written in F# using active patterns
View JsonParser.fs
type Json =
| Null
| Bool of bool
| Number of float
| String of string
| Array of Json list
| Object of (string * Json) list
type Bracket = Open | Close
@sarthology
sarthology / regexCheatsheet.js
Created Jan 10, 2019
A regex cheatsheet 👩🏻‍💻 (by Catherine)
View regexCheatsheet.js
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
@lpalmes
lpalmes / react.md
Last active Jan 9, 2019
React and Reconcilers in Reason
View react.md

React

This is the base of all projects and it will include the foundation for all potential react-based projects in Reason.

This base package should include a ReasonReact api to promote collaboration and familiarity with people using a ReasonReact, and for the modern world of React this should also include a Hooks api that currently revery uses.

React module

All blocks in Jsx are of type React.reactElement. This reactElement should represent:

@busypeoples
busypeoples / FormExample.re
Created Apr 23, 2018
Form Example in ReasonML
View FormExample.re
type validation('a) =
| NotEmpty
| Custom('a);
type t = string;
let validate = (rule, value, values) =>
switch (rule) {
| NotEmpty => String.length(value) > 0
| Custom(fn) => fn(value, values)
@broerjuang
broerjuang / thinkingInReact.re
Created Feb 9, 2018
This is the implementation of thinking in react using reason
View thinkingInReact.re
type product = {
category: string,
price: string,
stocked: bool,
name: string
};
type products = list(product);
let products = [
View StoreAndRouterExample.re
module Store = {
type action =
| Increase
| Decrease
| SetUsername(string);
type state = {
count: int,
username: string,
};
type storeBag = {
@jaredly
jaredly / BasicServer.re
Created Jan 2, 2018
Simple Static File Server in Reason/OCaml
View BasicServer.re
let recv = (client, maxlen) => {
let bytes = Bytes.create(maxlen);
let len = Unix.recv(client, bytes, 0, maxlen, []);
Bytes.sub_string(bytes, 0, len)
};
let parse_top = top => {
let parts = Str.split(Str.regexp("[ \t]+"), top);
switch (parts) {
@Zerim
Zerim / SignupForm.re
Last active Feb 19, 2018
A simple SignupForm written in ReasonML
View SignupForm.re
/* `action` and `state` types must be defined before the `let component` statement for type inference to work */
type action =
| UpdateEmail string
| UpdatePassword string;
type state = {
email: string,
password: string
};
@Lokeh
Lokeh / promises.re
Last active Jul 24, 2019
Notes on using JavaScript Promises in ReasonML/BuckleScript
View promises.re
/**
* Making promises
*/
let okPromise = Js.Promise.make((~resolve, ~reject as _) => [@bs] resolve("ok"));
/* Simpler promise creation for static values */
Js.Promise.resolve("easy");
Js.Promise.reject(Invalid_argument("too easy"));
@alexfedoseev
alexfedoseev / 1-styles.css
Created Apr 18, 2017
CSS Modules + PostCSS + Webpack
View 1-styles.css
:root {
--my-width: 400px;
}
:export {
myWidth: var(--my-width);
}
.myClass {
width: var(--my-width);
You can’t perform that action at this time.