Skip to content

Instantly share code, notes, and snippets.

View awesome's full-sized avatar

So Awesome Man awesome

View GitHub Profile
@cvkmohan
cvkmohan / application.html.erb
Created July 27, 2021 04:11
Rails Flash Messages using Tailwind, Stimulus and ViewComponents
<% flash.each do |type, title| %>
<%= render FlashComponent.new(type: type, title: title) %>
<% end %>
@basti
basti / README.md
Last active April 7, 2023 16:25
AWS S3 CORS configuration for Rails ActiveStorage

AWS S3 now uses JSON for CORS configuration and cors.json is minimal configuration for Rails 7 direct uploads.

@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"
@evanwinter
evanwinter / addReporterAsParticipant.groovy
Last active April 2, 2019 17:02
Adds initial Reporter as a Participant, and sets the user in custom field "Primary User" as the new Reporter. For use in JIRA Service Desk.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
import java.util.ArrayList
import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Logger
def log = Logger.getLogger("com.acme.XXX")
@mihow
mihow / load_dotenv.sh
Last active April 23, 2024 22:07
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
@Filirom1
Filirom1 / custom-logger.rb
Created January 12, 2017 14:41
How to customize a logger in ruby
require 'logger'
module Dim
class Logger < ::Logger
def initialize(*)
super
@formatter = NoTimestampFormatter.new
end
end
@ajaxray
ajaxray / firebase-online-user-count-example.md
Last active July 18, 2022 09:57
Keep list (and count) of online users in a Firebase web app - by isolated rooms or globally

Gathering.js - How to use

Keep list (and count) of online users in a Firebase web app - by isolated rooms or globally.

Live Demo

Firebase Shared Checklist is a demo application that shows the number of users joined a checklist using gathering.js. Here is a 1 minute screencast of using this application.

@nepsilon
nepsilon / git-change-commit-messages.md
Last active April 24, 2024 06:30
How to change your commit messages in Git? — First published in fullweb.io issue #55

How to change your commit messages in Git?

At some point you’ll find yourself in a situation where you need edit a commit message. That commit might already be pushed or not, be the most recent or burried below 10 other commits, but fear not, git has your back 🙂.

Not pushed + most recent commit:

git commit --amend

This will open your $EDITOR and let you change the message. Continue with your usual git push origin master.

@aaronpdennis
aaronpdennis / congressional-district-maps.md
Last active October 2, 2016 16:08
Blog post for GovTrack.us about creating congressional district maps.

Every ten years, after the decennial census and as mandated by the U.S. Constitution, states are subdivided into sets of congressional districts for representation in the U.S. House of Representatives. GovTrack provides maps of these congressional boundaries for your reference and makes the maps available for embedding on other sites. Beyond looking up the district for a specific address, maps introduce a geographic context that tells us about the demographics and rural/urban nature of a district, as well as whether that district's boundaries show signs of gerrymandering.

Recently, we redesigned GovTrack's map of congressional districts to be more responsive, more legible, and easier to reproduce. To create these maps, we used data from the U.S. Census Bureau, a few cartographic tricks and tools, and web map hosting from Mapbox. I'll explain the process here, and you can reference the exact workflow [on GitHub](https://github.com/aaron

@alltom
alltom / trix-sanitize-html.js
Last active January 27, 2022 03:47
"Tested" with Trix 0.9.4
var sanitizeHtml = require('sanitize-html');
function localSanitizeHtml(html) {
let allowedAttributes = JSON.parse(JSON.stringify(sanitizeHtml.defaults.allowedAttributes));
allowedAttributes.a = (allowedAttributes.a || []).concat(['data-trix-attachment', 'rel']);
allowedAttributes.figure = (allowedAttributes.figure || []).concat(['class']);
allowedAttributes.figcaption = (allowedAttributes.figcaption || []).concat(['class']);
allowedAttributes.img = (allowedAttributes.img || []).concat(['width', 'height']);
allowedAttributes.span = (allowedAttributes.span || []).concat(['class']);