Skip to content

Instantly share code, notes, and snippets.

View hayesr's full-sized avatar

Eric Hayes hayesr

View GitHub Profile
@dhh
dhh / linux-setup.sh
Last active July 24, 2024 13:05
linux-setup.sh
# THIS LINUX SETUP SCRIPT HAS MORPHED INTO A WHOLE PROJECT: HTTPS://OMAKUB.ORG
# PLEASE CHECKOUT THAT PROJECT INSTEAD OF THIS OUTDATED SETUP SCRIPT.
#
#
# Libraries and infrastructure
sudo apt update -y
sudo apt install -y \
docker.io docker-buildx \
build-essential pkg-config autoconf bison rustc cargo clang \
@bradgessler
bradgessler / oauth_google_controller.rb
Last active September 14, 2023 13:57
OAuth Google controller
class OAuth::GoogleAuthorizationsController < ApplicationController
CLIENT_ID = Rails.application.credentials.google.client_id
CLIENT_SECRET = Rails.application.credentials.google.client_secret
SCOPE = "openid email profile"
AUTHORIZATION_URL = URI("https://accounts.google.com/o/oauth2/v2/auth")
TOKEN_URL = URI("https://www.googleapis.com/oauth2/v4/token")
USER_INFO_URL = URI("https://www.googleapis.com/oauth2/v3/userinfo")
before_action :validate_state_token, only: :show
@oleksis
oleksis / Fedora-WSL2.md
Last active March 21, 2024 18:12
Fedora 38 on WSL2 using PowerShell

Fedora 38 x86_64 on WSL2 using PowerShell

Download and import the Fedora base container (Powershell)

$DownloadURL = "https://kojipkgs.fedoraproject.org//packages/Fedora-Container-Base/38/20230801.0/images/Fedora-Container-Base-38-20230801.0.x86_64.tar.xz"
$OutputFile = "$env:USERPROFILE\Downloads\Fedora-Container-Base-38-20230801.0.x86_64.tar.xz"
Invoke-WebRequest -Uri $DownloadURL -OutFile $OutputFile

# Extract the downloaded tarball and move the root file system to the appropriate location
# winget install --id 7zip.7zip
#!/Users/aaron/.rubies/arm64/ruby-trunk/bin/ruby
# This is a demo language server for Ruby, written in Ruby. It just checks
# the syntax of Ruby programs when you save them.
#
# Configure this in Vim by adding the vim-lsp plugin, then doing this
# in your vimrc:
#
# au User lsp_setup
# \ lsp#register_server({
@siresorose
siresorose / currency-format-input-field.markdown
Created March 29, 2023 22:43
Currency Format Input Field

Currency Format Input Field

Auto format currency input field with commas and decimals if needed. This is how I would personally expect one to work. Works left to right without forcing user to enter 00 cents if there is none. Text is automatically formatted with commas and cursor is placed back where user left off after formatting vs cursor moving to the end of the input. Validation is on KeyUp and a final validation is done on blur.

A Pen by Wade Williams on CodePen.

License.

@adrienpoly
adrienpoly / upgrade.md
Created September 24, 2021 09:32
Upgrade to Stimulus 3 recommandations

To upgrade to Stimulus 3.0 and minimize the side effects of the npm package name change here is my suggestion

# add the proxy package
yarn add stimulus

# add the new @hotwired/stimulus package
yarn add @hotwired/stimulus

# add the dedicated package for the Webpack helpers
@dhh
dhh / pagination_controller.js
Last active July 18, 2024 01:07
HEY's Stimulus Pagination Controller
/*
ERB template chunk from The Feed's display of emails:
<section class="postings postings--feed-style" id="postings"
data-controller="pagination" data-pagination-root-margin-value="40px">
<%= render partial: "postings/snippet", collection: @page.records, as: :posting, cached: true %>
<%= link_to(spinner_tag, url_for(page: @page.next_param),
class: "pagination-link", data: { pagination_target: "nextPageLink", preload: @page.first? }) unless @page.last? %>
</section>
@prologic
prologic / LearnGoIn5mins.md
Last active July 3, 2024 04:05
Learn Go in ~5mins
@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@nicksherron
nicksherron / disable-transparent-huge-pages.service
Last active January 22, 2024 21:32
systemd service for disabling Transparent Huge Pages (THP) for dbs like mongodb and redis
[Unit]
Description=Disable Transparent Huge Pages (THP)
DefaultDependencies=no
After=sysinit.target local-fs.target
Before=mongod.service
[Service]
Type=oneshot
ExecStart=/bin/sh -c 'echo never | tee /sys/kernel/mm/transparent_hugepage/enabled > /dev/null'