Skip to content

Instantly share code, notes, and snippets.

@clausti
clausti / pageable.rb
Last active September 24, 2020 18:37
# app/controllers/concerns/pageable.rb
module Pageable
extend ActiveSupport::Concern
@@page_size = 20
def page
@page ||= (params[:page].to_i > 1) ? params[:page].to_i : 1
end
<%# app/views/pageable/_widget.erb %>
<nav class='pageable-widget' aria-label="pagination widget">
<%= if prev_page
link_to "prev", {controller: controller_name, action: action_name, page: prev_page}.merge(pageable_params), aria: { label: 'previous page'}
end %>
<%= if total_pages > 0
"Page #{page} of #{total_pages}"
end %>
@media (hover: hover) {
.masked-container:hover {
.mask {
/* needs to be able to take clicks while it's beneath .masked, to gain focus */
pointer-events: auto;
/* once focused, clicks should fall through to .masked */
&:focus {
pointer-events: none;
/* when focused, .mask and siblings not intended to be covered need to come above .masked */
z-index: 1;
/* -> If a card is EVER a .masked-container, it MUST ALWAYS be a .masked-container,
because this fucks w the z-indexes.
-> The styling of .masked MUST be predicated upon the presence of a .mask
-> .mask is assumed to have a saturated background-color to be legible under white text */
.masked-container {
/* positioned above the container so that children w a negative z-index are also above the container */
z-index: 1;
/* don't take clicks, so that negative z-index child can be clicked */
pointer-events: none;
/* all descendants */
.a-post-card {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto 1fr auto;
.cn-body {
grid-column: 1 / -1;
grid-row: 1 / -1;
color: white;
.a-post-card {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto 1fr auto;
.cn-body {
grid-column: 1 / -1;
grid-row: 1 / -1;
color: white;
<article class='a-post-card masked-container'>
<section class='cn-body mask' tabindex=0>
I'm a content note!
</section>
<section class='post-inner masked' tabindex=0>
<span class='post-body'>I'm the text of the post!</span>
</section>
<header class='post-header'>
@clausti
clausti / minimal_hack.html
Last active January 18, 2020 02:34
css grid align-items bug??
<div class='a-post-card-hack'>
<div class='cn-body'>I'm pretending to be a content note</div>
<div class='post-inner'>I'm pretending to be a post</div>
</div>
@clausti
clausti / gitup.sh
Last active July 16, 2019 18:37
something for your .bashrc to make updating forks easier
function gitbranch() {
git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,'
}
function gitup() {
local git_branch=$(gitbranch)
local stash_out=$(git stash)
echo $stash_out
git checkout master
git fetch upstream
@clausti
clausti / 0_vegetables.rb
Last active August 4, 2018 00:00
vegetables
#apparently the gist 'title' is just the name of the lexicographically first filename