Skip to content

Instantly share code, notes, and snippets.

View vitobotta's full-sized avatar

Vito Botta vitobotta

View GitHub Profile
class ChutesGLMTransformer {
constructor(options = {}) {
this.name = "chutes-glm";
this.endPoint = "/v1/chat/completions";
this.enable = options.enable ?? true;
}
async auth(request, provider) {
return {
body: request,
@vitobotta
vitobotta / script.sh
Created March 8, 2025 15:44
htzner-k3s dedicated server as agent
touch /etc/initialized
HOSTNAME=$(hostname -f)
PUBLIC_IP=$(hostname -I | awk '{print $1}')
if [ "true" = "true" ]; then
echo "Using private network " >/var/log/hetzner-k3s.log
SUBNET="10.0.1.0/24"
MAX_ATTEMPTS=30
DELAY=10
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: cluster-autoscaler-temp-fix
rules:
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattachments"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
// 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