Skip to content

Instantly share code, notes, and snippets.

const fs = require("fs")
const path = require("path")
const files = fs.readdirSync(process.env.CALL_DIR)
const outputs = `${process.env.CALL_DIR}/../outputs`
if (!fs.existsSync(outputs)) {
console.log(process.cwd())
console.log("outputs directory does not exist - use UPDATE_SNAPSHOTS=1 to create")
process.exit(1)
}
@dorner
dorner / web_component.html
Last active September 15, 2020 18:54
Web component filtered table
<ws-filter-table perpage="20" data-table="{some_json_structure}">
<ws-row-template>
<ws-topic-row></ws-topic-row>
</ws-row-template>
<ws-filters>
<div class="filters">
<input type="text" name="topicName"/>
<input type="checkbox" name="myTopics"/>
</div>
</ws-filters>
@dorner
dorner / FilteredTable.jsx
Last active September 15, 2020 19:51
Filtered table suggestion in React
<FilteredTableController perPage="20" data={data} renderRowFunc={(data) => ...}>
<TopicFilters>
<TextFilter field="topicName" placeholder="Enter the topic name"/>
<CheckboxFilter field="myTopic" label="Show Only My Topics"/>
</TopicFilters>
<FilteredTable>
<Headers>...</Headers>
</FilteredTable>
</FilteredTableController>
@dorner
dorner / stimulus_table_controller.html
Last active September 15, 2020 18:49
Table controller HTML
<div data-controller="table" data-table-per-page="20" data-table-page="1">
<div class="filters">
<input type="text" name="topicName" data-target="table.filter"/>
<input type="checkbox" name="myTopics" data-target="table.filter"/>
</div>
<table>
<thead>...</thead>
<tbody data-target="table.table">
<tr data-topicName="myTopic" data-myTopics="true">...</tr>
<tr data-topicName="yourTopic" data-myTopics="false">...</tr>
@dorner
dorner / table_controller.js
Last active February 22, 2024 10:03
Stimulus table controller
import { Controller } from "stimulus"
import $ from "jquery"
export default class extends Controller {
static targets = ["filter", "table", "pagination", "row"]
connect() {
this.page = Number(this.data.get("page")) || 1;
this.perPage = Number(this.data.get("per-page")) || 20;
@dorner
dorner / avro_sample1.avsc
Last active March 31, 2020 20:40
Avro sample 1
{
"type": "record",
"name": "Widgets",
"namespace": "com.my-app",
"fields": [
{
"name": "widget_id",
"type": "long",
},
{
@dorner
dorner / cron.yaml
Last active July 13, 2023 07:50
How to execute code in Elastic Beanstalk only if you're the leader
# We are not using this file to run actual cron jobs. This is because the
# built-in Elastic Beanstalk cron feature actually puts the jobs at the end
# of the SQS queue. Instead we will run them manually. However, we need to
# have a non-empty cron.yaml or the SQS daemon won't even run and leader
# election won't work.
version: 1
cron:
- name: "DoNothingJob"
url: "/periodic_tasks"
schedule: "0 0 31 2 *"