Skip to content

Instantly share code, notes, and snippets.

@cschulte22
cschulte22 / _flash_notifications.html.erb
Created July 29, 2020 22:16
Rails flash with tailwind / alpinejs
<% if flash.any? %>
<div class="fixed inset-0 flex items-end justify-center px-4 py-6 pointer-events-none sm:p-6 sm:items-start sm:justify-end z-50" data-flash-notifications='true'>
<% flash.each do |msg_type, msg| %>
<div x-data="{flashVisible: false, flashType: '<%= msg_type %>'}" x-show='flashVisible' x-init="() => {flashVisible=true; setTimeout(() => {flashVisible=false}, 5000)}" class="max-w-sm w-full bg-white shadow-lg rounded-lg pointer-events-auto"
x-transition:enter="transition ease-out duration-300"
x-transition:enter-start="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"
x-transition:enter-end="translate-y-0 opacity-100 sm:translate-x-0"
x-transition:leave="transition ease-out duration-100"
@stettix
stettix / things-i-believe.md
Last active March 20, 2024 17:45
Things I believe

Things I believe

This is a collection of the things I believe about software development. I have worked for years building backend and data processing systems, so read the below within that context.

Agree? Disagree? Feel free to let me know at @JanStette. See also my blog at www.janvsmachine.net.

Fundamentals

Keep it simple, stupid. You ain't gonna need it.

@IanColdwater
IanColdwater / twittermute.txt
Last active April 22, 2024 17:26
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@lazaronixon
lazaronixon / dropzone_controller.js
Last active March 9, 2024 05:14
Dropzone.js + Stimulus + Active Storage
import { Controller } from "stimulus"
import { DirectUpload } from "@rails/activestorage"
import Dropzone from "dropzone"
import { getMetaValue, findElement, removeElement, insertAfter } from "helpers"
Dropzone.autoDiscover = false
export default class extends Controller {
static targets = [ "input" ]
@lisawolderiksen
lisawolderiksen / git-commit-template.md
Last active April 22, 2024 13:01
Use a Git commit message template to write better commit messages

Using Git Commit Message Templates to Write Better Commit Messages

The always enthusiastic and knowledgeable mr. @jasaltvik shared with our team an article on writing (good) Git commit messages: How to Write a Git Commit Message. This excellent article explains why good Git commit messages are important, and explains what constitutes a good commit message. I wholeheartedly agree with what @cbeams writes in his article. (Have you read it yet? If not, go read it now. I'll wait.) It's sensible stuff. So I decided to start following the

@armchairlinguist
armchairlinguist / oneline_detailed_logging.rb
Last active January 3, 2020 13:45 — forked from troy/oneline_detailed_logging.rb
One-line detailed logging for Rails 3 (ActiveSupport::Notifications) and later
# Outputs this at warn log level:
# 1.2.3.4 GET /path 200 OK BlahController#action HTML 938.2 (DB 11.8, View 719.7) {params} {optional params from flash[:log]}
#
# Save as config/initializers/oneline_detailed_logging.rb. Consider
# decreasing the log level from "info" to "warn" (in production.rb) so
# the one-line log message replaces the standard request logs.
# override process_action to add 2 things to the payload:
# - remote IP
@imjasonh
imjasonh / markdown.css
Last active February 12, 2024 17:18
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@prakhar1989
prakhar1989 / richhickey.md
Last active November 8, 2023 17:19 — forked from stijlist/gist:bb932fb93e22fe6260b2
richhickey.md

Rich Hickey on becoming a better developer

Rich Hickey • 3 years ago

Sorry, I have to disagree with the entire premise here.

A wide variety of experiences might lead to well-roundedness, but not to greatness, nor even goodness. By constantly switching from one thing to another you are always reaching above your comfort zone, yes, but doing so by resetting your skill and knowledge level to zero.

Mastery comes from a combination of at least several of the following:

@pcreux
pcreux / Gemfile
Last active December 11, 2023 20:24
Fast Rails + Heroku Configuration
group :production do
gem 'unicorn'
# Enable gzip compression on heroku, but don't compress images.
gem 'heroku-deflater'
# Heroku injects it if it's not in there already
gem 'rails_12factor'
end
@komasaru
komasaru / rmagick_available_fonts.rb
Last active October 29, 2019 08:37
Ruby script to generate a image of available fonts on RMagick.
require 'RMagick'
F_SIZE = 24 # フォントサイズ (pt)
FILE = "font_list.png" # 出力ファイル名
class RmagickAvailableFonts
# フォント一覧画像作成
def make_image
fonts = Magick.fonts # フォント一覧
image = Magick::Image.new(600, (F_SIZE + 20) * fonts.size + 10) { # 画像オブジェクト