Skip to content

Instantly share code, notes, and snippets.

@BretFisher
BretFisher / Docker Model Runner Reference.excalidraw.png
Last active May 22, 2025 23:52
Use Open WebUI with Docker Model Runner and Compose
Docker Model Runner Reference.excalidraw.png
@rameerez
rameerez / kamal-production-server-setup.sh
Last active June 12, 2025 10:31
Set up a Ubuntu server to deploy Kamal 2.x Docker containers to, hardened security and production ready
#!/bin/bash
# Production Docker Host Hardening Script v2
# For Ubuntu Server 24.04 LTS (Noble)
# Suitable for both Kamal deployment and builder hosts
set -euo pipefail
IFS=$'\n\t'
# --- Constants ---
@brianjbayer
brianjbayer / gist-unlocking-the-secrets-of-rails-secrets-and-credentials.md
Last active April 30, 2025 09:31
A comprehensive examination of Rails Secrets, Credentials, and Secret Key Base

Unlocking the Secrets of Rails Secrets and Credentials

Interurban Tunnel at Blackhand Gorge- Brian J Bayer


If you are like many (most?) of us, you have encountered Rails Credentials/Secrets and secret_key_base and may have been left a bit (or more) confused.

This post is an attempt to remove some of that confusion by

@hakunin
hakunin / approach_01_random_ids.rb
Last active November 16, 2016 11:01
Prevent different records with matching IDs from falsely passing tests
# put this inside spec/support/random_ids.rb
# NOTE: this works, but will break tests whee something like Article.last is used
# a more clever approach is used in 02 below
# Some tests may pass when they should have failed
# due to Rails using sequential ids. This allows us
# to fix that by having random ids.
class ActiveRecord::Base
before_create :generate_random_id
@vitskvara
vitskvara / analyza.r
Created November 28, 2015 19:25
datafestak2015_R_workshop
library(stats)
library(forecast)
### DATALOAD ###
# nemocnice
pripady<-read.csv('fnhk_pripady.csv',header=T)
vykony<-read.csv('fnhk_vykony.csv',header=T)
zup<-read.csv('fnhk_zup.csv',header=T)
data_length<-nrow(pripady)
# PSC po okresech
@pixeltrix
pixeltrix / time_vs_datatime.md
Last active April 23, 2025 13:36
When should you use DateTime and when should you use Time?

When should you use DateTime and when should you use Time?

It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime steps in:

>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000
@leighhalliday
leighhalliday / config.ru
Created February 17, 2015 16:15
Rack Example
# Use:
# This is in file config.ru
# 1) gem install rack
# 2) rackup
# 3) visit http://localhost:9292 in browser
# 4) Timer info will be in console
# 5) when changing code, will have to restart rackup
# Include rack
require 'rack'
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
@Integralist
Integralist / Ruby Lambdas.md
Last active August 8, 2023 05:10
Ruby lambdas

Lambda: standard

# Creating a lambda
l = lambda { |name| "Hi #{name}!" }

# Executing the lambda
l.call("foo") # => Hi foo!
class GroupersController < ApplicationController::Base
def create
@grouper = Grouper.new(leader: current_member)
if @grouper.save
ConfirmedGrouperEmails.new(@grouper).deliver
AssignBarForGrouper.enqueue(@grouper.id)
redirect_to home_path
else