Skip to content

Instantly share code, notes, and snippets.

View geewiz's full-sized avatar

Jochen Lillich geewiz

View GitHub Profile
@mars
mars / set_default_host.rb
Created August 17, 2023 20:10
Rails unified host override for use with apps behind a CDN (Rack middleware, supports OmniAuth)
# Rack middleware that reads environment variable HOST (value such as: app.example.com)
# to override request Host headers, forcing the app to use this value for URLs & redirects.
#
# If env var HOST is unset, then this middleware does nothing.
#
# Useful for when a Rails app is the origin behind a CDN/proxy, so that all generated
# URLs point to the canonical hostname of the CDN, and not the origin itself.
#
# For a Rails app,
# - save this file in config/initializers/set_default_host.rb
@llimllib
llimllib / install.sh
Last active January 2, 2025 10:40
The script I use to set up a new mac just the way I like it
#!/usr/bin/env bash
# many settings from https://raw.githubusercontent.com/mathiasbynens/dotfiles/master/.macos
# many settings from https://raw.githubusercontent.com/thoughtbot/laptop/master/mac
# instructions on finding the default you've changed: https://pawelgrzybek.com/change-macos-user-preferences-via-command-line/
# previous install notes at:
# https://gist.github.com/llimllib/ee591266e05bd880629a4e7511a61bb3
# https://gist.github.com/llimllib/e864a92da94ceb1ef0da2e06fd1f8d70
# https://gist.github.com/llimllib/3fc4fefcfc0152dad8c58201246d8802
#
# this script's URL is: https://gist.github.com/llimllib/c4dd0a98a426022b0365d4c0a9090460
@bashbunni
bashbunni / .zshrc
Created January 4, 2023 16:28
CLI Pomodoro for Linux
# study stream aliases
# Requires https://github.com/caarlos0/timer to be installed. spd-say should ship with your distro
declare -A pomo_options
pomo_options["work"]="45"
pomo_options["break"]="10"
pomodoro () {
if [ -n "$1" -a -n "${pomo_options["$1"]}" ]; then
val=$1
@caksoylar
caksoylar / zen-display-improvements.md
Last active December 10, 2024 07:25
Corne-ish Zen display improvements

Display improvements for the Corne-ish Zen keyboard

This note details the changes made to the Zen and ZMK codebase to improve the experience of e-ink displays.

Getting the changes

You can test out below changes using your Zen config repo by modifying your config/west.yml file, following ZMK instructions:

manifest:
  remotes:
 - name: caksoylar
@alvincrespo
alvincrespo / application_helper.rb
Created July 21, 2022 11:02
TailwindUI + will_paginate renderer
module ApplicationHelper
def will_paginate(coll_or_options = nil, options = {})
if coll_or_options.is_a? Hash
options = coll_or_options
coll_or_options = nil
end
options = options.merge renderer: TailwindUIPaginationRenderer unless options[:renderer]
super(*[coll_or_options, options].compact)
end
end
@kepano
kepano / obsidian-web-clipper.js
Last active April 28, 2025 07:22
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/[email protected]?module'), import('https://unpkg.com/@tehshrike/[email protected]'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
@dcuadraq
dcuadraq / ch_01.md
Last active March 25, 2025 18:05
Rails Antipatterns: Best practice Ruby on Rails Refactoring notes

Chapter 1. Models

The Model layer should also contain the business logic of your application.

ANTIPATTERN: VOYEURISTIC MODELS

Class: A class defines the characteristics of an object, including the details of what it is (its attributes) and what it can do (its methods).

Method: A method exists on a class and defines what the class can do.

Encapsulation: Ideally, the code for a class should be relatively self-contained through encapsulation, which is the concealment of functional details of a class from the other objects that call its methods. This is typically done by limiting the methods other objects are allowed to call and exposing a public interface through which an object is exposed to the world. In Ruby, this is done with the public, protected, and private keywords.

anonymous
anonymous / slack.rb
Created August 8, 2014 11:06
require 'knife-spork/plugins/plugin'
module KnifeSpork
module Plugins
class Slack < Plugin
name :slack
def perform; end
def after_upload
@gmcmillan
gmcmillan / chef.rb
Created July 26, 2012 22:25
Simple Ruby class for manually querying the Chef REST API (using Net::HTTP instead of Chef's REST resources)
require 'base64'
require 'time'
require 'digest/sha1'
require 'openssl'
require 'net/https'
require 'json'
class ChefAPI
# Public: Gets/Sets the http object.