Skip to content

Instantly share code, notes, and snippets.


Stefan Wienert zealot128

View GitHub Profile
zealot128 / simple_form.rb
Created Aug 13, 2022
Rails simple_form Tailwind Daisy UI config
View simple_form.rb
# frozen_string_literal: true
# Uncomment this and change the path if necessary to include your own
# components.
# See to know
# more about custom components.
# Dir[Rails.root.join('lib/components/**/*.rb')].each { |f| require f }
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
zealot128 / baudit.rb
Last active Jul 22, 2022
Batch Bundler-audit a whole directory and bundle update all the affected Gems conservatively
View baudit.rb
require 'bundler/inline'
# TODO: Skip Auto udpate when not on master or main branch
gemfile do
source ''
gem 'bundler-audit', "~> 0.9"
gem 'pry'
gem 'tty-prompt'
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 Aug 8, 2022
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 May 2, 2022
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