Skip to content

Instantly share code, notes, and snippets.

View colinfwren's full-sized avatar

Colin Wren colinfwren

View GitHub Profile
@colinfwren
colinfwren / retool-posthog-referring-domain.js
Created May 8, 2022 19:42
Retool PostHog Referring Domain
return data.results[0].result.map((result) => {
return {
key: result.breakdown_value,
value: result.aggregated_value
}
})
@colinfwren
colinfwren / retool-posthog-insight-timeline.js
Created May 8, 2022 19:41
Retool PostHog Insight Timeline
return data.results[0].result[0].data.map((value, index) => {
const label = data.results[0].result[0].labels[index];
return {
label,
value
}
})
@colinfwren
colinfwren / retool-mailchimp-to-table.js
Last active May 8, 2022 19:39
convert list stats to a table
const keys = ['member_count', 'total_contacts', 'unsubscribe_count', 'open_rate']
return Object.keys(data.stats).filter((key) => keys.includes(key)).map((key) => {
const value = data.stats[key]
return {
key,
value
}
})
@colinfwren
colinfwren / retool-portainer-docker-compose.yml
Created May 8, 2022 19:37
Deploying REtool via Portainer
version: '2'
services:
api:
image: tryretool/backend:latest
env_file: ./stack.env
environment:
- SERVICE_TYPE=MAIN_BACKEND
- DB_CONNECTOR_HOST=http://db-connector
- DB_CONNECTOR_PORT=3002
- DB_SSH_CONNECTOR_HOST=http://db-ssh-connector
@colinfwren
colinfwren / UpdatingRectangleFill.js
Created April 24, 2022 16:37
Updating fill for rectangle
import { convertHexColorToRgbColor } from '@create-figma-plugin/utilities'
function setFillColourForNodes(colourHex) {
const nodes = figma.currentPage.children.slice()
const fillRgb = convertHexColorToRgbColor(colourHex)
nodes.map(node => {
if ('fill' in node) {
const clonedFill = JSON.parse(JSON.stringify(node.fills))
clonedFill.map(fill => fill.color = fillRgb)
node.fills = clonedFill
@colinfwren
colinfwren / figmaPluginMessages.js
Created April 24, 2022 16:28
Sending and Receiving messages in Figma Plugins
// main.ts
import { emit, on, showUI } from '@create-figma-plugin/utilities'
export default function () {
on('RESET_SELECTION', () => {
figma.currentPage.selection = []
})
figma.on('selectionchange', () => {
const nodes = figma.currentPage.selection.map(node => ({ id: node.id, name: node.name }))
emit('UPDATE_SELECTION', nodes)
@colinfwren
colinfwren / deleteNode.graphql
Created April 17, 2022 22:18
Delete a node
"""
Input looks like
{
"where": {
"id": "ID of the node to delete"
}
}
"""
mutation Mutation($where: TestWhere) {
deleteTests(where: $where) {
"""
Arguments look like
{
"where": {
"id": "ID of the node to update"
},
"update": {
"userStories": [
{
"disconnect": [
@colinfwren
colinfwren / connectNodes.graphql
Created April 17, 2022 22:10
Connect a node to another node
"""
Arguments look like
{
"where": {
"id": "ID of the node to update"
},
"update": {
"userStories": [
{
"""
Arguments look like
{
"where": {
"id": "ID of the node to update"
},
"update": {
"name": "Updated test"
}
}