Skip to content

Instantly share code, notes, and snippets.


Dino Reić dux

  • JRNI
  • London, Zagreb, Munich
View GitHub Profile
dux / _
Last active May 3, 2021
Capistrano replacement via common rake tasks
View _
you will need
* hash_wia gem
# to fully deploy application
rake remote:deploy
dux / paginate.rb
Last active Jan 28, 2021
Trivial and fast (does not execute count or any other unneeded requests) Ruby / Rails / Sinatra / Lux pagination
View paginate.rb
# @list = Paginate.set User, size: 40, name: :upage
# Paginate.render @list
# using:
module Paginate
extend self
def set rset, opts={}
opts[:size] ||= 20
opts[:name] ||= :page
dux / myapp.service
Created Jan 18, 2021
systemd sample script to start puma/rails app
View myapp.service
Description=Puma HTTP Server
# Foreground process (do not use --daemon in ExecStart or config.rb)
# Preferably configure a non-privileged user
dux / asmodeus.rb
Created Jul 4, 2019
check if process pid is running and exit
View asmodeus.rb
class Asmodeus
attr_accessor :pid_file
def info text
puts 'Asmodeus: %s' % text
def pid_check no_check=false
return unless @pid_file
dux / _usage.js
Last active May 20, 2019
DOM create customElement or polyfil for older browsers. passes node + attributes
View _usage.js
// for svelte js, or any othe widget provider
let bindSvelteToDOM = function(name, klass) {
DOMCustomElement.define(name, function(node, opts) {
new klass({ target: node, props: opts })
import SvelteCheckbox from './svelte/checkbox.svelte'
bindSvelteToDOM('s-checkbox', SvelteCheckbox)
dux / rollup.config.js
Last active May 23, 2019
multi file rollup config with coffeescript, svelte, react and livereload
View rollup.config.js
import babel from 'rollup-plugin-babel'
import svelte from 'rollup-plugin-svelte'
import { scss } from '@kazzkiq/svelte-preprocess-scss';
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import { terser } from 'rollup-plugin-terser'
import coffee from 'rollup-plugin-coffee-script'
import livereload from 'rollup-plugin-livereload'
const production = !process.env.ROLLUP_WATCH;
dux / _threaded.rb
Last active Jul 31, 2021
Simple threaded/promisse-like runner for Ruby
View _threaded.rb
class Thread::Simple
attr_accessor :que, :size, :named
def initialize size: 5, sleep: 0.01
@sync =
@sleep = sleep
@size = size
@que = []
@threds = []
@named = {}
dux / demo.bash
Last active Nov 4, 2018
CLI demo builder, useful for - demo >
View demo.bash
# asciinema rec --overwrite tmp/
# bash demo.bash
type_and_run () {
printf '\033[01;37m@app $\033[0m '
for ((i=0; i<${#1}; i++)); do echo "after `jot -r 1 20 60`" | tclsh; printf "${1:$i:1}"; done;
View class_attributes.rb
# Defines class variable
def Object.class_attribute name, default=nil, &block
raise'name must be symbol') unless name.class == Symbol
ivar = "@cattr_#{name}"
instance_variable_set ivar, block || default
define_singleton_method(name) do |arg=:_undefined|
# define and set if argument given
dux / folder_model.rb
Last active Oct 28, 2018
Foder and Generic models
View folder_model.rb
# frozen_string_literal: true
class FolderModel
class << self
def find(key)
def all