Skip to content

Instantly share code, notes, and snippets.

View xanderificnl's full-sized avatar
💭
Rest In Piece Xander 13-09-2023

Xander xanderificnl

💭
Rest In Piece Xander 13-09-2023
View GitHub Profile
@xanderificnl
xanderificnl / create-do-dns-zones.py
Last active September 11, 2015 12:31
Create multiple DNS zones with records on DigitalOcean.
# noinspection PyPackageRequirements
import digitalocean
"""
Create multiple DNS zones with records on DigitalOcean.
This Gist allows you to easily insert several dozens of domain names with the same records (it's possible to
use some variables). It's rather simple to adjust to your use-case, i.e. adding new variables, etc.
Note: Requires python-digitalocean - don't forget to update the script with your token, default IP, your domain
@xanderificnl
xanderificnl / setup.sh
Last active January 27, 2021 15:29
Setup a new SmartOS zone.
#!/usr/bin/env bash -q
#
# curl -s https://gist.githubusercontent.com/web-refinery/7ae5c21c84974f7370016f8808ffbddc/raw/setup.sh | bash
#
curl -s https://github.com/web-refinery.keys -o $HOME/.ssh/authorized_keys
sed -i.bak 's|https://pkgsrc.joyent.com|http://pkgsrc.web-refinery.com/smartos|g' /opt/local/etc/pkgin/repositories.conf
pkg_admin rebuild
pkgin -y up
pkgin -y in mosh
@xanderificnl
xanderificnl / set-tmux-title.sh
Created March 28, 2021 01:47 — forked from nevesnunes/set-tmux-title.sh
Set tmux pane title to short hostname on ssh connections
ssh() {
# grep -w: match command names such as "tmux-2.1" or "tmux: server"
if ps -p $$ -o ppid= \
| xargs -i ps -p {} -o comm= \
| grep -qw tmux; then
# Note: Options without parameter were hardcoded,
# in order to distinguish an option's parameter from the destination.
#
# s/[[:space:]]*\(\( | spaces before options
# \(-[46AaCfGgKkMNnqsTtVvXxYy]\)\| | option without parameter
@xanderificnl
xanderificnl / fix-vga-1.sh
Created November 16, 2021 11:02
Fix VGA-1 output @ Script
#!/bin/sh
xrandr --newmode "1920x1080_59.00" 169.00 1920 2040 2240 2560 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode VGA-1 "1920x1080_59.00"
@xanderificnl
xanderificnl / Rails 7 with browser-sync (live-reloading).md
Last active December 17, 2021 02:13
Rails 7 w/ browser-sync (live reloading)

Rails 7 w/ browser-sync.

You'll need nodejs, npm or yarn and browser-sync. I use Yarn:

yarn add --dev browser-sync

Create bs-config.js in the root folder of your project and modify it to suite your needs.

module.exports = {
--asset-pipeline=propshaft
--css=tailwind
--database=postgresql
--edge
--javascript=importmap
--minimal
--no-skip-action-cable
--no-skip-action-mailer
--no-skip-action-text
--no-skip-active-job
@xanderificnl
xanderificnl / config application.rb
Last active February 5, 2022 02:19
(Postgres) Rails with ulid primary keys
module SomeApp
class Application < Rails::Application
config.active_record.schema_format = :sql
config.generators do |generator|
generator.orm :active_record, primary_key_type: :ulid
end
end
end
@xanderificnl
xanderificnl / slim2haml.sh
Created January 23, 2022 00:26
Convert slim files to haml without Temple functions
# 0. Make a backup first.
# 1. Install slim2haml
gem install slim2haml
# 2. Use the line below to remove offending lines.
for i in $(find . -name '*.haml'); do sed -E 's/::Temple::Utils\.escape_html((.*))/\1/; s/\(\(//g; s/\)\)//g; s/(-|=) _slim_controls[[:digit:]] ?//g' -i "$i"; done
@xanderificnl
xanderificnl / config initializers middleware.rb
Created February 3, 2022 00:14
Convenient helper to load application middleware into Rails
# frozen_string_literal: true
# Convenient helper to load application middleware into Rails.
#
# @example app/middleware/health_middleware.rb
# class HealthMiddleware; end
#
Pathname.glob(Rails.root.join("app/middleware/*.rb")).each do |path|
require path
@xanderificnl
xanderificnl / install-apple-fonts.sh
Created February 10, 2022 15:19
Install apple fonts
#!/usr/bin/env bash
#
# Easily install apple fonts
#
CACHE_DIR=/tmp/apple-fonts-cache
ZIP_BIN="7z -y"
mkdir ~/.fonts/
# Install dependencies on debian systems