Skip to content

Instantly share code, notes, and snippets.

View leastbad's full-sized avatar
🤠
Keeping it real for the rest of us.

leastbad leastbad

🤠
Keeping it real for the rest of us.
View GitHub Profile
@rickychilcott
rickychilcott / slim_select_controller.js
Last active February 28, 2025 12:43
Slim-select stimulus controller
import { Controller } from "stimulus"
import SlimSelect from "slim-select"
import "slim-select/dist/slimselect.min.css"
import "../style/slimselect-customized.css"
export default class extends Controller {
connect() {
const limit = this.data.get("limit")
const placeholder = this.data.get("placeholder")
const searchText = this.data.get("no-results")
<div class="card">
<div class="card-header">
<h3 class="card-title">
<%= notification.to_notification.in_app_subject %>
</h3>
</div>
<div class="card-body">
<%= notification.to_notification.in_app_body %>
</div>
</div>
@fractaledmind
fractaledmind / jobbable_concern.rb
Created March 1, 2021 09:09
This concern allows model instances to run async jobs that depend on them. Calling #async_method_name will trigger the MethodNameJob
module Jobbable
extend ActiveSupport::Concern
# This concern allows model instances to run async jobs that depend on them.
# Calling #async_method_name will trigger the MethodNameJob
PREFIX = "async_"
included do
def method_missing(method_name)
@KonnorRogers
KonnorRogers / postcss.config.js
Created March 10, 2021 02:50
purgecss for rails
const purgecss = require('@fullhuman/postcss-purgecss')({
content: [
'./app/**/*.html.erb',
'./app/helpers/**/*.rb',
'./app/javascript/**/*.js',
],
defaultExtractor: content => {
const broadMatches = content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || []
const innerMatches = content.match(/[^<>"'`\s.()]*[^<>"'`\s.():]/g) || []
return broadMatches.concat(innerMatches)
URI.open(url) do |uri|
base_uri = uri.base_uri
listable_type = case base_uri.to_s
when /soundcloud.com\/(?<artist>.+)\/tracks/
raise UnparsableTrackUrlError
when /soundcloud.com\/(?<artist>.+)\/sets\/(?<title>.+)/
SoundCloudPlaylist
when /soundcloud.com\/(?<artist>.+)\/(?<title>.+)/
SoundCloudTrack