Skip to content

Instantly share code, notes, and snippets.

@mudge
mudge / production.rb
Last active November 21, 2023 14:06
How to configure Rails and Rack::Attack to use the real client IP when running behind Cloudflare
Rails.application.configure do
# Add Cloudflare's IPs to the trusted proxy list so they are ignored when
# determining the true client IP.
#
# See https://www.cloudflare.com/ips-v4/ and https://www.cloudflare.com/ips-v6/
config.action_dispatch.trusted_proxies = ActionDispatch::RemoteIp::TRUSTED_PROXIES + %w[
173.245.48.0/20
103.21.244.0/22
103.22.200.0/22
103.31.4.0/22
@mateuszbialowas
mateuszbialowas / scratch.rb
Created May 25, 2022 17:36
ar-mapping-custom-pk-fk
# frozen_string_literal: true
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'pry'
gem "sqlite3"
gem 'activerecord'
end
@huytd
huytd / markdown.vim
Created June 15, 2020 08:14
Checkbox for markdown in Vim
syntax match todoCheckbox '\v\s*(-? \[[ x\.!\*]\])' contains=finishedCheckbox,unfinishexCheckbox,flaggedCheckbox,starredCheckbox
syntax match finishedCheckbox '\v(-? \[[ \.]\])' conceal cchar=
syntax match unfinishexCheckbox '\v(-? \[x\])' conceal cchar=
syntax match flaggedCheckbox '\v(-? \[!\])' conceal cchar=
syntax match starredCheckbox '\v(-? \[\*\])' conceal cchar=
hi link todoCheckbox Todo
hi clear Conceal
@huytd
huytd / todo.vim
Created June 14, 2020 07:34
A Todo list syntax in Vim, with an actual checkbox
" Vim syntax file
" Language: Todo
" Maintainer: Huy Tran
" Latest Revision: 14 June 2020
if exists("b:current_syntax")
finish
endif
" Custom conceal
@andersevenrud
andersevenrud / alacritty-tmux-vim_truecolor.md
Last active April 14, 2024 20:05
True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

True Color (24-bit) and italics with alacritty + tmux + vim (neovim)

This should make True Color (24-bit) and italics work in your tmux session and vim/neovim when using Alacritty (and should be compatible with any other terminal emulator, including Kitty).

Testing colors

Running this script should look the same in tmux as without.

curl -s https://gist.githubusercontent.com/lifepillar/09a44b8cf0f9397465614e622979107f/raw/24-bit-color.sh >24-bit-color.sh
@janklimo
janklimo / benchmark.rb
Last active February 22, 2024 08:59
Comparison of memory usage: AXLSX vs. rubyXL
# frozen_string_literal: true
require 'axlsx'
require 'rubyXL'
require 'rubyXL/convenience_methods/worksheet'
require 'memory_profiler'
rows = 1_000
columns = 20
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active April 16, 2024 08:50
set -e, -u, -o, -x pipefail explanation
@Aaronmacaron
Aaronmacaron / install-alacritty-ubuntu.sh
Last active October 10, 2022 11:26
Install Alacritty on Ubuntu
#!/bin/bash
# This installs alacritty terminal on ubuntu (https://github.com/jwilm/alacritty)
# You have to have rust/cargo installed for this to work
# Install required tools
sudo apt-get install -y cmake libfreetype6-dev libfontconfig1-dev xclip
# Download, compile and install Alacritty
git clone https://github.com/jwilm/alacritty
@sgmonda
sgmonda / code-print.tex
Last active April 3, 2021 00:29
Simple LaTeX template to print beautiful black&white Javascript source code
\documentclass[a4paper, 12pt]{article}
\usepackage[letterpaper, margin=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{beramono}
\usepackage{listings}
\usepackage{xcolor}
\newcommand\realnumberstyle[1]{}
@rrcobb
rrcobb / negated_change_matcher.rb
Created January 23, 2018 00:09
Rspec negated change matcher
# This should be in rspec core, but add it here so we can chain negative change expectations, like
# expect { do_thing }.to change {a}.and not_change {b}.and change {b}
RSpec::Matchers.define_negated_matcher :not_change, :change