Skip to content

Instantly share code, notes, and snippets.


Stefan Wienert zealot128

View GitHub Profile
zealot128 / inertia.ts
Created Dec 21, 2021
Vite-rails + Inertia base setup
View inertia.ts
import { createApp, h } from 'vue'
import { createInertiaApp } from '@inertiajs/inertia-vue3'
import i18n from '~/utils/i18n'
resolve: name => import(`/pages/${name}.vue`),
setup({ el, app, props, plugin }) {
createApp({ render: () => h(app, props) })
zealot128 / rails-models-to-typescript-schema.rb
Last active Sep 29, 2021
Simple ruby script to generate Active Record Typescript information with enums + associations
View rails-models-to-typescript-schema.rb
# rails runner rails-models-to-typescript-schema.rb > app/javascript/types/schema.d.ts
models = ActiveRecord::Base.descendants.reject { |i| i.abstract_class? }
belongs_to = true
has_many = true
View AutocompleteInput.vue
<template lang="pug">
.form-autocomplete(@blur.native='blur' @unfocus='blur')
type="text" name="query" v-model.sync="query" placeholder="搜索查询" autocomplete="off" autofocus @blur='blur'
View d3-sankey-circular.js
import { min, ascending, max, mean, sum } from 'd3-array';
import { map, nest } from 'd3-collection';
import { linkHorizontal } from 'd3-shape';
import findCircuits from 'elementary-circuits-directed-graph';
// For a given link, return the target node's depth
function targetDepth(d) {
zealot128 /
Last active Jun 14, 2021
Migrate off

Migrate Gem-assets by vendoring


This script + initializer can help you to migrate of the "" hosted assets. If you can not immediately move to Webpack/NPM, you can just copy the asset content into your vendor directory.

Add to your config/initializers/assets.rb:

Rails.application.configure do
zealot128 / d3-sankey-circular.d.ts
Created Dec 11, 2020
d3-sankey-circular typescript types
View d3-sankey-circular.d.ts
type SankeyInputNode = {
name: string
column?: number,
type SankeyInputLink = {
source: string,
target: string,
value: number,
optimal: string
zealot128 / PageWithSelectableText.vue
Last active Nov 24, 2020
vue-pdf page with selectable text: Usage: <pdf-viewer :pdf-url="pdfUrl" />
View PageWithSelectableText.vue
<template lang="pug">
.pdf-page--wrapper(:class='{"text-selection": textSelectionEnabled }')
.col-sm-6.pdf-page--headline {{$t('', { page: page })}}
button.btn.btn-secondary.btn-sm(type="button" @click="print" data-toggle="tooltip" data-placement="top" :title="$t('js.attachment_viewer.print')")
zealot128 /
Created Nov 13, 2020
Quick Postgresql (Ubuntu) upgrade script
# hint: Run via ssh:
# ssh root@somehost 'bash -s' <
psql --version
apt update
zealot128 / Dockerfile
Last active Jan 18, 2022
Basis Docker setup for Rails app (Postgres)
View Dockerfile
FROM ruby:2.7.1-alpine
RUN apk add --update --no-cache \
binutils-gold \
build-base \
curl \
file \
g++ \
zealot128 /
Created Oct 23, 2020
MacOS Automator: Convert file with Handbrake CLI Quick Action
# I use this script to quickly convert Screencasts with HandbrakeCLI to Gmail Large 3 minutes,
# which has an OK quality for a screencast but is very small -
# Perfect for quickly showing collegues/customers some new features/Worflows.
# Create Automator -> New -> Quick Action
# Add Run Shell Script
# Select "Receive input as argument"
# paste script