Skip to content

Instantly share code, notes, and snippets.

@n-studio
n-studio / DEPLOY_WITH_KAMAL_ON_DEDICATED_SERVER.md
Last active June 1, 2025 10:51
Deploy a web app on a dedicated server with Kamal

Notes

This guide uses Kamal 2.5.3

Motivation

Kamal was designed with 1 service = 1 droplet/VPS in mind.
But I'm cheap and I want to be able to deploy multiple demo/poc apps apps on my $20/month dedicated server.
What the hell, I'll even host my private container registry on it.

@thestrabusiness
thestrabusiness / backend_usage.rb
Created March 4, 2023 15:04
React + ActionCable Example
class GameChannel < ApplicationCable::Channel
def subscribed
game = Game.find(params[:id])
stream_for game
end
end
## When the game state changes
GameChannel.broadcast_to(game, GameSerializer.render(game))
@JustSteveKing
JustSteveKing / pint.json
Last active March 24, 2026 12:55
Laravel Pint configuration
{
"preset": "per",
"rules": {
"align_multiline_comment": true,
"array_indentation": true,
"array_syntax": true,
"blank_line_after_namespace": true,
"blank_line_after_opening_tag": true,
"combine_consecutive_issets": true,
"combine_consecutive_unsets": true,
@brunow
brunow / gist:69763de7793d1d01e2f1f124cec55d4c
Created April 14, 2021 05:41
SwiftUI os specific modifier
/// After reading an article from Antoine v.d. SwiftLee  @twannl about conditional view modifier, I had an idea to improve my code I write for specific OS.
/// https://www.avanderlee.com/swiftui/conditional-view-modifier
extension Bool {
static var iOS: Bool {
#if os(iOS)
return true
#else
return false
#endif
@pLavrenov
pLavrenov / forge.sh
Created July 29, 2020 23:29
Laravel Forge Setup Script (July 2020) - NGINX + MySQL
# Replace!
# [!server!] (the forge server instance)
# [!sudo_password!] (random password for sudo)
# [!db_password!] (random password for database user)
# [!user.name!] (git user name)
# [!user.email!] (git user email)
# [!server_ip!] (git user email)
#
# REQUIRES:
@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@ingeniousgenius
ingeniousgenius / README.md
Last active December 15, 2025 22:37
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:

@777777miSSU7777777
777777miSSU7777777 / mp3_to_hls.sh
Last active October 9, 2025 04:23
Transcode mp3 to hls stream via ffmpeg.
ffmpeg \
-i audio_name.mp3 \
-vn -ac 2 -acodec aac \
-f segment -segment_format mpegts -segment_time 10 \
-segment_list audio_pl.m3u8 \
audio_segment%05d.ts
@vades
vades / angular-expression-changed.md
Last active January 7, 2026 09:55
Fixing "Expression has changed after it was checked" in Angular

Fixing "Expression has changed after it was checked" in Angular

The exception appears (in the development mode) at the moment the value is checked and value is different of the updated value.

Error message example

AppComponent.html:1 ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ngIf: true'. Current value: 'ngIf: false'.
    at viewDebugError (core.js:20440)
    at expressionChangedAfterItHasBeenCheckedError (core.js:20428)
    at checkBindingNoChanges (core.js:20530)
<template lang='pug'>
div.drop-zone(:class='{dragging: isDragging }'
@dragover.prevent='dragover'
@dragenter.prevent='dragover'
@drop.prevent.stop='onDrop'
@dragleave.prevent='dragleave')
div(:class='{ hidden: uploadInProgress }' @click='openFileBrowser')
slot
i {{label}}
input(type='file' :multiple='multiple' ref='input' style='display: none')