Skip to content

Instantly share code, notes, and snippets.

View yzgan's full-sized avatar

Gan Yi Zhong yzgan

View GitHub Profile
@carlosramireziii
carlosramireziii / allow_content_type.rb
Last active August 19, 2025 21:47
A validator and RSpec matcher for restricting an attachment’s content type using Active Storage
require "rspec/expectations"
RSpec::Matchers.define :allow_content_type do |*content_types|
match do |record|
matcher.matches?(record, content_types)
end
chain :for do |attr_name|
matcher.for(attr_name)
end
@heiswayi
heiswayi / repo-reset.md
Created February 5, 2017 01:32
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A
@thegitfather
thegitfather / vanilla-js-cheatsheet.md
Last active November 21, 2025 07:55
Vanilla JavaScript Quick Reference / Cheatsheet
@joyrexus
joyrexus / README.md
Last active December 21, 2025 15:33 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})