Skip to content

Instantly share code, notes, and snippets.

@FractalWire
FractalWire / nvrp
Last active September 5, 2020 03:32
preview file with fzf and nvr
#!/bin/bash
# simple script to preview files with the help of fzf
cwd=$(pwd)
# set up
nvr --nostart -cc 'let nvrp_buffer=""'
set_variables='mime_list=( "application/json" "text/" ); mime=$(file --mime-type {} | cut -d " " -f 2)'
f_is_text='for m in ${mime_list[@]}; do test "${mime#$m}" != "$mime" && break || false; done'
@RobertAudi
RobertAudi / example.rb
Last active March 23, 2020 14:53 — forked from redconfetti/example.rb
Custom Rspec matcher for checking class for constant, with optional class type.
# frozen_string_literal: true
class ExampleClass
PI = 3.14159265359
end
@leopirolo
leopirolo / devise.fr.yml
Last active July 3, 2024 13:45
French traduction for gem Devise 4.6.2
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
fr:
devise:
confirmations:
confirmed: "Votre compte a été validé."
send_instructions: "Vous allez recevoir les instructions nécessaires à la confirmation de votre compte dans quelques minutes."
send_paranoid_instructions: "Si votre e-mail existe dans notre base de données, vous allez bientôt recevoir un e-mail contenant les instructions de confirmation de votre compte."
failure:
already_authenticated: "Vous êtes déjà connecté."
@psprint
psprint / deploy-message.zsh
Last active April 1, 2023 07:46
Zsh function to display a message under prompt
# The Zshell function will display the given message under-prompt (as a kind of notification).
# It has an optional delay first argument: "@sleep:<secnods with fractions>". If given, then
# the message will wait in background before showing for the specified time.
#
# Usage:
# deploy-message @msg "Hello world"
# deploy-message "Hello world"
# deploy-message @msg 1234 # I.e. the "@msg" is needed for number-only messages, otherwise optional
# deploy-message @sleep:5.5 "Hello world"
@castwide
castwide / rails.rb
Last active October 24, 2024 16:26
Enhance Rails Intellisense in Solargraph
# The following comments fill some of the gaps in Solargraph's understanding of
# Rails apps. Since they're all in YARD, they get mapped in Solargraph but
# ignored at runtime.
#
# You can put this file anywhere in the project, as long as it gets included in
# the workspace maps. It's recommended that you keep it in a standalone file
# instead of pasting it into an existing one.
#
# @!parse
# class ActionController::Base
# frozen_string_literal: true
RSpec::Matchers.alias_matcher :increment, :change do |desc|
desc.gsub("changed", "incremented").gsub("change", "increment")
end
RSpec::Matchers.alias_matcher :decrement, :change do |desc|
desc.gsub("changed", "decremented").gsub("change", "decrement").gsub("-", "")
end
@RobertAudi
RobertAudi / attribute_spec_helper.rb
Last active May 6, 2019 08:38 — forked from PareshGupta/attribute_spec_helper.rb
Rspec matcher for attr_accessor, attr_reader and attr_writer
# frozen_string_literal: true
# `have_attr_reader` matcher for attr_reader
RSpec::Matchers.define :have_attr_reader do |field|
match do |object_instance|
object_instance.respond_to?(field)
end
failure_message do |object_instance|
"expected attr_reader for #{field} on #{object_instance}"
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active April 8, 2025 14:18
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@ttscoff
ttscoff / sizes.rb
Last active July 12, 2021 03:33
sizes: Calculate and sort all filesizes for current folder
#!/usr/bin/env ruby
# Sizes - Calculate and sort all filesizes for current folder Includes
# directory sizes, colorized output Brett Terpstra 2019 WTF License
VERSION = "1.0.1"
require 'shellwords'
# Just including term-ansicolor by @flori and avoiding all the
# rigamarole of requiring multiple files when it's not a gem... - Brett
#
@jeromedalbert
jeromedalbert / .gitattributes
Last active March 14, 2025 14:16
Automatically resolve Git merge conflicts in Rails schema.rb by picking the most recent date in the conflict (now works with Rails 5 and recent versions of Git). The following files should be in your home ~ directory. Inspired by https://tbaggery.com/2010/10/24/reduce-your-rails-schema-conflicts.html
db/schema.rb merge=railsschema