Skip to content

Instantly share code, notes, and snippets.

Avatar

R.J. (Steinert) Corwin rjsteinert

View GitHub Profile
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
}
View tangerine-generator--yes_no.js
const yes_no = function() {
const possibilities = [
[
{
"label": "yes",
"name": "1",
"value": ""
},
{
"label": "no",
View autostop.js
shouldGridAutoStop() {
const firstXButtons = tangyToggleButtons.slice(0, this.autoStop)
const hasAtLeastOneUnpressedButton = firstXButtons
.reduce((hasAtLeastOne, button) => hasAtLeastOne || button.pressed === false ? true : false, false)
return hasAtLeastOneUnpressedButton ? false : true
}
@rjsteinert
rjsteinert / debugger-statement-in-a-template-literal.js
Created Apr 16, 2020
How to put a debugger statement in a Javascript template literal.
View debugger-statement-in-a-template-literal.js
var foo = `
Here is a debugger statment in a template...
${(()=>{ debugger })()}
`