Skip to content

Instantly share code, notes, and snippets.

View ogirginc's full-sized avatar

Oğulcan Girginç ogirginc

View GitHub Profile
@stefanvermaas
stefanvermaas / separator.rb
Created March 10, 2026 18:55
Automatically detect the column separator in a CSV file
require "csv"
class CSV
class Separator
DEFAULT_SEPARATOR = ","
class Error < StandardError; end
class DetectionError < Error
def message
@Shpigford
Shpigford / favicon
Created January 11, 2026 17:24
/favicon command for Claude Code — Generates all necessary favicon files, HTML and webmanifest, including updating your layout files with the necessary code.
---
argument-hint: [path to source image]
description: Generate favicons from a source image
---
Generate a complete set of favicons from the source image at `$1` and update the project's HTML with the appropriate link tags.
## Prerequisites
First, verify ImageMagick v7+ is installed by running:

🆕 Update: See more extensive repo here: https://github.com/marckohlbrugge/unofficial-37signals-coding-style-guide

The Unofficial 37signals/DHH Rails Style Guide

About This Document

This style guide was generated by Claude Code through deep analysis of the Fizzy codebase - 37signals' open-source project management tool.

Why Fizzy matters: While 37signals has long advocated for "vanilla Rails" and opinionated software design, their production codebases (Basecamp, HEY, etc.) have historically been closed source. Fizzy changes that. For the first time, developers can study a real 37signals/DHH-style Rails application - not just blog posts and conference talks, but actual production code with all its patterns, trade-offs, and deliberate omissions.

@bradgessler
bradgessler / route_format.rb
Created December 8, 2025 18:20
Dasherized Rails routes
# config/initializers/route_format.rb
#
# Global route formatting override for Rails routing.
#
# This hooks into ActionDispatch::Routing::Mapper::Mapping and mutates the
# Journey AST in place so that underscored literal path segments are
# dasherized. It affects *all* routes (get, resources, scope, etc.)
# because they all end up as a Journey AST passed into Mapping.
#
# IMPORTANT:
@andynu
andynu / filters_concern.rb
Created October 9, 2025 16:20
example concerns
require 'active_support/concern'
# The {FiltersConcern} provides a <tt>filter_params</tt> scope which takes a hash <tt>{ col1: term, col2: term }</tt>
#
# see app/assets/javascripts/filterable.js
#
# == type sensitive filtering
# * strings - fuzzy search of %term%
# * dates -
# * July - => month
@pcreux
pcreux / turboframe_missing_handler.js
Created July 21, 2025 07:42
A developer friendly turboframe error handler
// Display a developer-friendly error message when Turbo Frame fails to load.
if (process.env.NODE_ENV === 'development') {
document.addEventListener('turbo:frame-missing', async function (event) {
event.preventDefault();
const frame = event.target;
const response = event.detail.response;
const frameId = frame.id;
const url = response?.url || frame.src;
import {Controller} from "@hotwired/stimulus"
// Warns if form fields have unsaved changes before leaving the page.
// Changes are stored in Session Storage to restore un-warnable events
// like using the back button
//
// To use:
// <form data-controller="unsaved-changes">
// <input type="text" name="name" data-unsaved-changes-target="field">
export default class extends Controller {
@henrik
henrik / 0_example.erb
Last active May 25, 2025 01:17
Rails ViewComponent convenience, e.g. `c.heading("Hi")`
Before:
<%= render Admin::HeadingComponent.new("Hi") %>
After:
<%= c.heading "Hi" %>

Namespaces 101

Introduction

Ruby has recently merged namespaces as an experimental feature that is disabled by default, as of this writing.

This is a non-trivial development driven by @matz himself, and mainly implemented by @tagomoris, who just became a Ruby committer (🎉).

The feature has been cooking for a long time, with a first ticket opened a couple of years ago (#19744) and a revised one opened just last week (#21311).

# frozen_string_literal: true
require "bundler/inline"
# Inline Gemfile for dependencies
gemfile(true) do
source "https://rubygems.org"
gem "benchmark-ips"
end