Skip to content

Instantly share code, notes, and snippets.

View jaredcwhite's full-sized avatar
🌲

Jared White jaredcwhite

🌲
View GitHub Profile
@jaredcwhite
jaredcwhite / funky.config.js
Last active May 20, 2021 03:40
Personal configuration of Funky class-less utility CSS. https://native-elements.dev/#/docs/funky/introduction
module.exports = {
minify: false,
outputPath: "frontend/styles/funky-utilities.css",
breakpoints: {
xs: { max: "575px" },
sm: { min: "576px", max: "767px" },
md: { min: "768px", max: "991px" },
lg: { min: "992px", max: "1199px" },
xl: { min: "1200px", max: "1399px" },
xxl: "1400px"
@jaredcwhite
jaredcwhite / semantics.html
Last active March 23, 2023 23:10
Example of how I write HTML markup in 2021
<timeline-post post-id="54235" source-id="13" >
<sl-card style="margin-bottom: var(--sl-spacing-large)">
<a href="https://appleinsider.com/articles/21/05/11/jamf-acquires-zero-trust-cloud-security-startup-wandera-in-400m-deal?utm_medium=rss" target="_blank" slot="image"><img
src="https://photos5.appleinsider.com/gallery/41951-81380-34258-61556-jamf-pro-head-xl-xl.jpg"
alt="article thumbnail"
class="post-thumbnail"
/></a>
<h3><a target="_blank" class="link" href="https://appleinsider.com/articles/21/05/11/jamf-acquires-zero-trust-cloud-security-startup-wandera-in-400m-deal?utm_medium=rss">Jamf acquires 'zero trust' cloud security startup Wandera in $400M deal</a></h3>
@jaredcwhite
jaredcwhite / hello.rb
Last active May 17, 2021 22:00
Hello I am Ruby
class Ruby
end
def am(input)
"am #{input}"
end
def I(input)
"I #{input}"
end
@jaredcwhite
jaredcwhite / string_voodoo.rb
Last active June 23, 2021 18:14
JS in Ruby?!
### The Setup
Kernel.define_method(:"`") do |val|
val
end
def const(val)
val
end
@jaredcwhite
jaredcwhite / cable_car_example.html
Last active June 9, 2021 17:31
CableCar + web component
<cable-car href="/cc/cable_car" csrf-token="94IkWdvagUHWPGVkD+VeBFVjGoM0zXAf6tgm6BPU+kEpOj2BTtI6bXJQzEDXGAF+R6Dc1ek7oNouatTMrbUy">
<button
onclick="this.closest('cable-car').post(this, {extra: 123})"
data-x="1"
output="#show-the-things"
>
Do a thing!
</button>
<section id="show-the-things"></section>
@jaredcwhite
jaredcwhite / .zshrc
Created June 17, 2021 23:22
Switch RAILS_ENV based on the presence of a dot file
load-rails-env() {
if [ -f ".rails_env" ]; then
export RAILS_ENV=$(cat .rails_env)
else
export RAILS_ENV=production
fi
}
add-zsh-hook chpwd load-rails-env
@jaredcwhite
jaredcwhite / ruby_3_kwargs_error.rb
Created November 5, 2021 19:08
Ruby 2.7.2 vs. 3.0.2 discrepancy
# This file runs fine in Ruby 2.7.2 and errors out in Ruby 3.0.2 with:
# testkwargs.rb:15:in `method_missing': no implicit conversion of Foo into Hash (TypeError)
# from testkwargs.rb:31:in `<main>'
class Helpers
end
class Foo
def wee(a=1, b:2)
puts a
@jaredcwhite
jaredcwhite / object_assign.rb
Created December 31, 2021 00:02
A Ruby equivalent to JavaScript's Object.assign
Object.class_eval do
def self.assign(obj, options={})
options.each do |k, v|
obj.send("#{k}=", v)
end
obj
end
end
@jaredcwhite
jaredcwhite / class soup.html
Created April 6, 2022 15:49
Utility classes suuuuuuck
<div class="bg-gradient-to-b from-pink-100 to-purple-200">
<div class="container m-auto px-6 py-20 md:px-12 lg:px-20">
<div class="m-auto text-center lg:w-8/12 xl:w-7/12">
<h2 class="text-2xl text-pink-900 font-bold md:text-4xl">…</h2>
</div>
<div class="mt-12 m-auto -space-y-4 items-center justify-center md:flex md:space-y-0 md:-space-x-4 xl:w-10/12">
<div class="relative z-10 -mx-4 group md:w-6/12 md:mx-0 lg:w-5/12">
<div aria-hidden="true" class="absolute top-0 w-full h-full rounded-2xl bg-white shadow-xl transition duration-500 group-hover:scale-105 lg:group-hover:scale-110"></div>
<div class="relative p-6 space-y-6 lg:p-8">
<h3 class="text-3xl text-gray-700 font-semibold text-center">…</h3>
@jaredcwhite
jaredcwhite / string.rb
Last active April 18, 2024 00:37
Truncating in the middle of a Ruby string
class String
def middle_truncate(truncate_length = 30)
return self if length <= truncate_length + 2
"#{self[..(truncate_length / 2)]}…#{self[-(truncate_length / 2)..]}"
end
end
puts "Well, this is a very long string and I hope I can see if it will truncate!".middle_truncate