Skip to content

Instantly share code, notes, and snippets.

# frozen_string_literal: true
require 'sshkit'
require 'sshkit/dsl'
require 'sshkit/sudo'
include SSHKit::DSL
DOKKU_VERSION = 'v0.35.15'
HOST = ENV.fetch('DOKKU_HOST')
@KhaosT
KhaosT / HDMI on Apple Vision Pro.md
Last active April 19, 2025 05:01
Guide for using Apple Vision Pro as HDMI display

Displaying HDMI sources on Apple Vision Pro

While it's possible to stream most content to Apple Vision Pro directly over the internet, having the ability to use Apple Vision Pro as an HDMI display can still be useful.

Since Apple Vision Pro does not support connecting to an HDMI input directly or using an HDMI capture card, we have to be a little creative to make this work. NDI provides the ability to stream HDMI content over a local network with really low latency, and it works great with Apple Vision Pro.

This page shows the setup I’m using.

@varyform
varyform / multiple_importmaps.rb
Last active April 3, 2024 21:58
Multiple importmaps
# config/initializers/public_importmap.rb
Rails.application.config.public_importmap = Importmap::Map.new
Rails.application.config.public_importmap.draw(Rails.root.join("config/public_importmap.rb"))
# app/helpers/application_helper.rb
# copied from importmaps replacing javascript_inline_importmap_tag
#
# !!! No longer needed after this change https://github.com/rails/importmap-rails/pull/187
#
# def javascript_public_importmap_tags(entry_point = "application", shim: true)
@jesster2k10
jesster2k10 / README.md
Last active February 11, 2025 17:25
JWT Auth + Refresh Tokens in Rails

JWT Auth + Refresh Tokens in Rails

This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.

I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)

Before trying it out DIY, I considered using:

@tobiashm
tobiashm / node_modules.rb
Last active October 26, 2023 22:26
Add node modules to Rails assets paths
# Allow Rails to use assets from Node packages
package_json = Rails.root.join("package.json")
Rails.configuration.watchable_files << package_json
Rails.configuration.to_prepare do
node_config = JSON.parse(package_json.read)
paths = Rails.configuration.assets.paths
node_modules = Rails.root.join("node_modules")
paths.reject! { |p| p.to_s.start_with?(node_modules.to_s) }
node_config["dependencies"].keys.each do |node_module|
module_dir = node_modules.join(node_module)
require 'nokogiri'
require 'open-uri'
# Get a Nokogiri::HTML:Document for the page we're interested in...
doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))
# Do funky things with it using Nokogiri::XML::Node methods...
####
@rpheath
rpheath / authlogic-to-devise.md
Last active December 22, 2024 04:36
Steps and troubleshooting tips when moving Authlogic to Devise.

How To: Authlogic to Devise

Step 1: Migration

  1. bin/rails g migration AuthlogicToDevise
  2. (see the file below for the actual migration, authlogic_to_devise.rb)
  3. bin/rake db:migrate

Step 2: Update Gemfile

  1. gem "devise", "~> 2.2.0"
  2. bundle install
@mkarliner
mkarliner / aes_crypt.rb
Created March 22, 2013 11:17
Using OpenSSL with Ruby to do AES encryption
# This module for using AES encryption with ruby from
# http://www.brentsowers.com/2007/12/aes-encryption-and-decryption-in-ruby.html
require 'openssl'
require "base64"
module AESCrypt
# Decrypts a block of data (encrypted_data) given an encryption key
# and an initialization vector (iv). Keys, iv's, and the data
# returned are all binary strings. Cipher_type should be
# "AES-256-CBC", "AES-256-ECB", or any of the cipher types
/* The Grid ---------------------- */
.lt-ie9 .row { width: 940px; max-width: 100%; min-width: 768px; margin: 0 auto; }
.lt-ie9 .row .row { width: auto; max-width: none; min-width: 0; margin: 0 -15px; }
.lt-ie9 .row.large-collapse .column,
.lt-ie9 .row.large-collapse .columns { padding: 0; }
.lt-ie9 .row .row { width: auto; max-width: none; min-width: 0; margin: 0 -15px; }
.lt-ie9 .row .row.large-collapse { margin: 0; }
.lt-ie9 .column, .lt-ie9 .columns { float: left; min-height: 1px; padding: 0 15px; position: relative; }
.lt-ie9 .column.large-centered, .columns.large-centered { float: none; margin: 0 auto; }