Skip to content

Instantly share code, notes, and snippets.

View vitobotta's full-sized avatar

Vito Botta vitobotta

View GitHub Profile
// This code is to be used with https://turbo.hotwire.dev. By default Turbo keeps visited pages in its cache
// so that when you visit one of those pages again, Turbo will fetch the copy from cache first and present that to the user, then
// it will fetch the updated page from the server and replace the preview. This makes for a much more responsive navigation
// between pages. We can improve this further with the code in this file. It enables automatic prefetching of a page when you
// hover with the mouse on a link or touch it on a mobile device. There is a delay between the mouseover event and the click
// event, so with this trick the page is already being fetched before the click happens, speeding up also the first
// view of a page not yet in cache. When the page has been prefetched it is then added to Turbo's cache so it's available for
// the next visit during the same session. Turbo's default behavior plus this trick make for much more responsive UIs (non SPA).
@vitobotta
vitobotta / gist:45f62ca44bfa19196bc2e44c9ec42b8b
Created April 14, 2019 10:15
Install Rook/Ceph with Rancher deployed cluster
- In Rancher, edit cluster, then edit Cluster Options as yaml and change the kubelet section as follows if needed:
```
kubelet:
extra_args:
volume-plugin-dir: "/usr/libexec/kubernetes/kubelet-plugins/volume/exec"
extra_binds:
- "/usr/libexec/kubernetes/kubelet-plugins/volume/exec:/usr/libexec/kubernetes/kubelet-plugins/volume/exec"
fail_swap_on: false
```
@vitobotta
vitobotta / Importing posts from Wordpress into Jekyll.rb
Created March 26, 2011 22:50
The script I used to import posts from my Wordpress blog into a new Jekyll one.
%w(rubygems sequel fileutils yaml active_support/inflector).each{|g| require g}
require File.join(File.dirname(__FILE__), "downmark_it")
module WordPress
def self.import(database, user, password, table_prefix = "wp", host = 'localhost')
db = Sequel.mysql(database, :user => user, :password => password, :host => host, :encoding => 'utf8')
%w(_posts _drafts images/posts/featured).each{|folder| FileUtils.mkdir_p folder}
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XML Sitemap</title>
@vitobotta
vitobotta / ttfb.sh
Created January 31, 2021 17:56
ttfb
#!/usr/bin/env bash
#
# Shows time in seconds to first byte of a url or urls
#
# Based on a gist https://gist.github.com/sandeepraju/1f5fbdbdd89551ba7925abe2645f92b5
# by https://github.com/sandeepraju
#
# Modified by jay@gooby.org, @jaygooby
#
# Usage: ttfb [options] url [url...]
@vitobotta
vitobotta / gitea-restore.sh
Created March 14, 2019 14:54
Gitea docker restore
#!/bin/bash
export LC_ALL=C
archive="$1"
container_name="root_gitea_1"
now=$(date +"%Y%m%d-%H%M%S")
# gitea_dir: it's the directory in the volume attached to the container which contains gitesa' data directory
gitea_dir="/data/containers/gitea"
gitea_data_dir="${gitea_dir}/data"
restore_dir="/tmp/gitea-restore-${now}"
@vitobotta
vitobotta / gist:dd90f094fabc20fc25decb02bdfbdace
Created November 24, 2021 10:20
HostCram KVM-8G - server3 - nench
-------------------------------------------------
nench.sh v2019.07.20 -- https://git.io/nench.sh
benchmark timestamp: 2021-11-24 10:17:04 UTC
-------------------------------------------------
Processor: 11th Gen Intel(R) Core(TM) i9-11900K @ 3.50GHz
CPU cores: 4
Frequency: 3504.000 MHz
RAM: 7.8Gi
Swap: 4.0Gi
@vitobotta
vitobotta / gist:0ab7a299731af798acaedcb9bab11839
Created November 24, 2021 10:19
HostCram KVM-8G - server2 - nench
-------------------------------------------------
nench.sh v2019.07.20 -- https://git.io/nench.sh
benchmark timestamp: 2021-11-24 10:17:02 UTC
-------------------------------------------------
Processor: 11th Gen Intel(R) Core(TM) i9-11900K @ 3.50GHz
CPU cores: 4
Frequency: 3504.000 MHz
RAM: 7.8Gi
Swap: 4.0Gi
@vitobotta
vitobotta / gist:be4cc376c2208f37001ed80e0fbd4216
Created November 24, 2021 10:19
HostCram KVM-8G - server1 - nench
-------------------------------------------------
nench.sh v2019.07.20 -- https://git.io/nench.sh
benchmark timestamp: 2021-11-24 10:17:00 UTC
-------------------------------------------------
Processor: 11th Gen Intel(R) Core(TM) i9-11900K @ 3.50GHz
CPU cores: 4
Frequency: 3504.000 MHz
RAM: 7.8Gi
Swap: 4.0Gi
@vitobotta
vitobotta / gist:967e806a3df07e9166e59d11adea6ed0
Created November 24, 2021 10:15
HostCram KVM-8G - server3 - yabs
# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #
# Yet-Another-Bench-Script #
# v2021-10-09 #
# https://github.com/masonr/yet-another-bench-script #
# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #
Wed 24 Nov 2021 10:09:56 AM UTC
Basic System Information:
---------------------------------