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
// has to be exported - triggers should be stored in the same folder as table schemas | |
export const insertTrigger = new Trigger({ | |
name: "update_product_meta_on_new_review", | |
type: "INSERT", | |
on: review, | |
when: ({ newRow }) => eq(newRow.isPrivate, false), | |
do: ({ newRow }) => | |
db | |
.insert(productMeta) | |
.values({ |
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 type { UploadHandlerPart } from "@remix-run/cloudflare"; | |
export class MaxPartSizeExceededError extends Error { | |
constructor(public field: string, public maxBytes: number) { | |
super(`Field "${field}" exceeded upload size of ${maxBytes} bytes.`); | |
} | |
} | |
export function createR2UploadHandler({ | |
bucket, |
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 type { V2_HtmlMetaDescriptor, V2_MetaFunction } from "@remix-run/node"; | |
export const mergeMeta = ( | |
overrideFn: V2_MetaFunction, | |
appendFn?: V2_MetaFunction, | |
): V2_MetaFunction => { | |
return arg => { | |
// get meta from parent routes | |
let mergedMeta = arg.matches.reduce((acc, match) => { | |
return acc.concat(match.meta || []); |
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 text = `<table cellspacing=1 bordercolordark=#666666 cellpadding=0 width=100% align=center bgcolor=#D9D9D9 bordercolorlight=#ffffff border=0><tr class='chinese blue_t2'><td height=20>球队</td><td>球员</td><td>位置</td><td>原因</td><td>日期</td><td>备注</td></tr><tr bgcolor=#FFF0DF align=center><td height=20>波特兰拓荒者</td><td> 纽基</td><td>中锋</td><td>脚部</td><td>2019/03/26</td><td>赛季报销</td></tr><tr bgcolor=#FFF0DF align=center><td height=20>波特兰拓荒者</td><td> 麦高林</td><td>后卫</td><td>膝部</td><td>2019/03/17</td><td>预计缺阵</td></tr><tr bgcolor=#FFF0DF align=center><td height=20>芝加哥公牛</td><td> 赞达拿赫捷臣</td><td>前锋</td><td>膝部</td><td>2019/01/26</td><td>赛季报销</td></tr><tr bgcolor=#FFF0DF align=center><td height=20>芝加哥公牛</td><td> 奥图波达</td><td>前锋</td><td>肩部</td><td>2019/03/26</td><td>预计缺阵</td></tr><tr bgcolor=#FFF0DF align=center><td height=20>芝加哥公牛</td><td> 云度卡达</td><td>中锋</td><td>拇指</td><td>2019/01/16</td><td>预计缺阵</td></tr><tr bgcolor=#FFF0DF align=center><td height=20>芝加哥公牛</td><td> D.华伦天尼</td><td>前锋</td><td>足踝</td><td>2018/10/19</td><td |
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 from "react"; | |
import PropTypes from "prop-types"; | |
import * as MapboxGl from "mapbox-gl"; | |
export default class DraggableMarker extends React.Component { | |
marker = null; | |
componentDidMount() { | |
const { map } = this.context; |
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
// ⚠ IMPORTANT: this is old and doesn't work for many different edge cases but I'll keep it as-is for any of you want it | |
// ⚠ IMPORTANT: you can find more robust versions in the comments or use a library implementation such as lodash's `merge` | |
// Merge a `source` object to a `target` recursively | |
const merge = (target, source) => { | |
// Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties | |
for (const key of Object.keys(source)) { | |
if (source[key] instanceof Object) Object.assign(source[key], merge(target[key], source[key])) | |
} |
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
#!/bin/sh | |
# Redirect output to stderr. | |
exec 1>&2 | |
# enable user input | |
exec < /dev/tty | |
consoleregexp='console.log' | |
# CHECK | |
if test $(git diff --cached | grep $consoleregexp | wc -l) != 0 | |
then |