Skip to content

Instantly share code, notes, and snippets.

View rjcorwin's full-sized avatar

R.J. (Steinert) Corwin rjcorwin

  • Khan Academy
  • Burlington, VT
View GitHub Profile
@rjcorwin
rjcorwin / comments.md
Created March 27, 2023 13:48 — forked from maddy531/comments.md
Mark pull request comments with a purpose

This is a set of ‘statuses’ that pull request comments must be marked with to help explain intent.

  • Praise: Highlighting positive practice/action
  • Nitpick: Trivial non-blocking preference-based requests
  • Suggested Change: Propose improvements to the current subject
  • Issue: Highlights specific problems with the subject under review
  • Todo: Are small, trivial, but necessary changes
  • Question: Questions are appropriate if you have a potential concern but are not quite sure if it's relevant or not
  • Required: This must be fixed before merge
  • Thought: Represent an idea that popped up from reviewing
  • Chore: Simple tasks that must be done before the subject can be “officially” accepted

How PouchDB Determines that Changes were successfully pushed to CouchDB

  1. During a replication, after PouchDB determines which docs should be pushed up and their contents, replicate's writeDocs function is called which in turn calls to bulkDocs function.
  2. When the target database is a CouchDB, the bulkDocs function is aliased to the pouchdb-adapter-http's _bulkDocs function.
  3. _bulkDocs then passes the request to fetchJSON function which then passes it to ourFetch. If response.ok is not truthy, an error is thrown [here](https://github.com/pouc
import { Plotly } from 'plotly'
// Copy plotly-styles.js to your project from this gist: https://gist.github.com/rjsteinert/751901de6aca5804b1024c6737e9dc97
import { plotlyStyles } from './plotly-styles.js'
import { LitElement, html } from 'lit-element'
class LitElementBarChart extends LitElement {
static get styles() {
return [
plotlyStyles
@rjcorwin
rjcorwin / plotly-styles.js
Created October 6, 2021 14:15
Plotly styles for use with LitElement components that use Plotly.js.
import { css } from 'lit-element';
export const plotlyStyles = css`
.js-plotly-plot .plotly, .js-plotly-plot .plotly div {
direction: ltr;
font-family: "Open Sans", verdana, arial, sans-serif;
margin: 0;
padding: 0;
}
async function cloneThisCase(toGen = 0) {
const db = await T.user.getUserDatabase()
let i = 0
while (i < toGen) {
const doc = JSON.parse(JSON.stringify(T.case.case))
const newCaseId = uuid()
doc._id = newCaseId
delete doc._rev
for (let event of doc.events) {
let newEventId = uuid()
T.case.setLocation = async function setLocation() {
// Get a Device to set the location
const device = await this.deviceService.getDevice()
if (device) {
let syncLocation = device.syncLocations[0]
let locationSetting = syncLocation.value.slice(-1).pop()
let location = {
[`${locationSetting.level}`]: locationSetting.value
}
return location
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"id": "village",
"formId": "village-manifest",
"name": "Village",
"caseRoles": [
{
"id": "village",
"label": "Village",
"templateListItem": "Village ${participant.data.id}"
},
@rjcorwin
rjcorwin / my-counter.js
Created July 17, 2020 18:32
Basic web component example
class MyCounter extends HTMLElement {
constructor() {
super();
this.count = 0;
}
render() {
this.innerHTML = `
<style>
const first = {
foo: 1,
bar: 1
}
// Copy the first object into a new one and override the bar property. This is useful when you
// want to make a copy of a complex object and want to override just one particular part of it.
const second = {
...first,
bar: 2