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
use std::fs::File; | |
use std::io::ErrorKind; | |
fn main() { | |
let f = File::open("hello.txt"); | |
let _f = match f { | |
Ok(file) => file, | |
Err(error) => match error.kind() { | |
ErrorKind::NotFound => match File::create("hello.txt") { |
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
import React from 'react' | |
import { PostCard } from './PostCard' | |
interface Post { | |
abstract: any | |
authors: any | |
body: string | |
created_at: string | |
deleted_at: string | |
id: number |
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
(defn connect! [url receive-handler] | |
(if-let [chan (js/WebSocket. url)] | |
(do | |
(set! (.-onmessage chan) (receive-message! receive-handler)) | |
(reset! ws-chan chan)) | |
(throw (js/Error. "WebSocket connection failed!")))) |
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
(defn save-message! [{:keys [params]}] | |
(if-let [errors (validate-message params)] | |
(response/bad-request {:errors errors}) | |
(try | |
(db/save-message! | |
(assoc params :timestamp (java.util.Date.))) | |
(response/ok {:status :ok}) | |
(catch Exception e | |
(response/internal-server-error | |
{:errors {:server-error ["Failed to save message!"]}}))))) |
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
import refractor from "refractor/core"; | |
import { flattenDeep } from "lodash"; | |
import { Plugin, PluginKey } from "prosemirror-state"; | |
import { Decoration, DecorationSet } from "prosemirror-view"; | |
import { findBlockNodes } from "prosemirror-utils"; | |
export const LANGUAGES = { | |
none: "None", // additional entry to disable highlighting | |
bash: "Bash", | |
css: "CSS", |
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
let printName = name => { | |
console.log(name) | |
} | |
let sumArrow = (a, b) => a + b | |
let printName = name => console.log(name) | |
// nope | |
// let printHi = name => console.log("Hi " + name) |
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
function printVariable(variable) { | |
console.log(variable) | |
} | |
function newfunc(name, callback) { | |
callback(name) | |
} | |
/* function callback(x) { | |
console.log("Hello " + x) |
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
function useForceUpdate() { | |
const [, setValue] = useState(0) | |
return () => setValue((value) => ++value) | |
} | |
export default function Editor(props) { | |
const { | |
post, | |
options, | |
onChange, |
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
/* eslint-disable jsx-a11y/no-autofocus */ | |
import React from 'react' | |
import { formatDistanceToNow } from 'date-fns' | |
interface Props { | |
isLoading: boolean | |
hasUnsavedChanges: boolean | |
isNewPost: boolean | |
lastSavedAtDate: any | |
} |
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
import React, { Component, createRef, useRef, useEffect, useState } from 'react' | |
import { EditorState } from 'prosemirror-state' | |
import { EditorView } from 'prosemirror-view' | |
import { commentPluginKey } from './editor-config/comments' | |
// import applyDevTools from 'prosemirror-dev-tools' | |
export default function Editor(props) { | |
const { | |
post, | |
options, |