Skip to content

Instantly share code, notes, and snippets.

Avatar

R.J. (Steinert) Corwin rjsteinert

View GitHub Profile
View how-pouchdb-pushes-to-couchdb.md

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
View lit-element-bar-chart.js
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
@rjsteinert
rjsteinert / plotly-styles.js
Created Oct 6, 2021
Plotly styles for use with LitElement components that use Plotly.js.
View plotly-styles.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;
}
View cloneThisCase.js
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()
View gist:e93208a2902992004c93b9d10dc6f20a
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
View tangerine-logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View case-definition--village.json
{
"id": "village",
"formId": "village-manifest",
"name": "Village",
"caseRoles": [
{
"id": "village",
"label": "Village",
"templateListItem": "Village ${participant.data.id}"
},
@rjsteinert
rjsteinert / my-counter.js
Created Jul 17, 2020
Basic web component example
View my-counter.js
class MyCounter extends HTMLElement {
constructor() {
super();
this.count = 0;
}
render() {
this.innerHTML = `
<style>
View spread-operator.js
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
View setter-getter-example.js
const language = {
_numberOfTimesCalled: 0,
set foo(name) {
this._numberOfTimesCalled++
this._foo = name
},
get foo() {
return this._foo
}