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 generatePicker from "antd/lib/date-picker/generatePicker"; | |
import { | |
addDays, | |
addMonths, | |
addYears, | |
format, | |
getWeek, | |
isAfter, | |
isValid, | |
parse, |
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
// service worker | |
self.addEventListener("install", (event) => { | |
event.waitUntil( | |
caches.open("{{ cache_key }}").then((cache) => | |
cache.addAll([ | |
// {% for asset in assets %} | |
"{{ asset }}", | |
// {% endfor %} | |
]) | |
) |
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
const LatencyIcon = ({ latency }) => { | |
return ( | |
<svg | |
xmlns="http://www.w3.org/2000/svg" | |
className="inline-block h-5 w-5 text-gray-800" | |
viewBox="0 0 20 20" | |
fill="currentColor" | |
> | |
<path | |
className={ |
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 React, { useCallback, useRef, useState } from "react"; | |
function clampHeight(height) { | |
const minHeight = 200; | |
const maxHeight = document.body.clientHeight - 300; | |
return Math.min(Math.max(height, minHeight), maxHeight); | |
} | |
export default function Element() { | |
const [height, setHeight] = useState(null); |
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
/** | |
* License: WTFPL - http://www.wtfpl.net/ | |
* | |
* Usage: element.addEventListener('keydown', inputHistory()); | |
*/ | |
function inputHistory(max_history) { | |
var PREV = 38, NEXT = 40, ENTER = 13, | |
history = [''], current = 0; | |
if (!max_history) { |
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
FROM node:12-alpine AS build | |
WORKDIR /app | |
RUN apk --no-cache add git | |
ARG REACT_APP_SENTRY_DSN | |
COPY web/package.json web/package-lock.json /app/web/ | |
RUN cd /app/web && npm install |
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
FROM node:13 AS build | |
WORKDIR /app | |
COPY package.json package-lock.json /app/ | |
RUN npm install | |
FROM build as dev | |
COPY . /app | |
CMD BROWSER=none npm start | |
FROM build as prod |
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
const MyForm: React.FC<any> = observer(({match, store}) => { | |
const obj = store.get(match.params.id); | |
if (obj === null) { | |
return <MyLoadingForm />; | |
} | |
// Invariant violation: Rendered more hooks than during the previous render. | |
const [data, setData] = useState(obj.data); | |
return <MyLoadedForm data={data} onSubmit={setData} /> | |
}); |
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
export abstract class BaseStore<T> { | |
@observable | |
objects: T[] = []; | |
constructor(private dao: BaseDAO<T>) {} | |
} |
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
<%= form_for @changeset, @action, [multipart: true], fn f -> %> | |
<!-- ... other fields ... --> | |
<!-- `selected` accepts only a list of IDs --> | |
<div class="form-group"> | |
<%= label f, :categories, class: "control-label" %> | |
<%= multiple_select f, :categories, @categories, selected: Enum.map(@changeset.data.categories, &(&1.id)), class: "form-control" %> | |
</div> |
NewerOlder