Skip to content

Instantly share code, notes, and snippets.

View steveclarke's full-sized avatar

Steve Clarke steveclarke

View GitHub Profile
@alameenkhader
alameenkhader / rails-rpush.md
Last active August 28, 2020 09:10
Rpush/Rails Integration

###rpush - https://github.com/rpush/rpush

Follow the steps in rpush to add the gem to your rails project

####PushNotificationDevice

rails g model PushNotificationDevice device_type:integer:index device_token:string
class CreatePushNotificationDevices < ActiveRecord::Migration
@mrmartineau
mrmartineau / stimulus.md
Last active May 12, 2024 04:35
Stimulus cheatsheet
@porras
porras / triple_dots.rb
Created January 10, 2020 17:40
Example of a usecase of Ruby 2.7 triple dot notation for writing method wrappers
def original_method(a, b)
puts "Called with #{a} and #{b}"
if block_given?
puts "Calling the block"
yield
end
end
def wrapper1(*args) # WRONG: doesn't pass the block
puts "Hi I'm wrapper1"
{% comment %}
Place at bottom of DOM, before </body>
{% endcomment %}
{% comment %}
Article structured data
https://developers.google.com/search/docs/data-types/articles
{% endcomment %}
{% if template contains 'article' %}
@BrianSigafoos
BrianSigafoos / application_component.rb
Created December 21, 2020 15:38
Fetch or fallback for Rails ViewComponent
# frozen_string_literal: true
class ApplicationComponent < ViewComponent::Base
private
# Reference: https://www.youtube.com/watch?v=YVYRus_2KZM&t=302s
def fetch_or_fallback(allowed_values, given_value, fallback)
if allowed_values.include?(given_value)
given_value
else
" https://gist.github.com/steveclarke/ba73c6b2e198f14f1b729ad6825c04ca
" Leader is <space>
let mapleader = ' '
nnoremap <Space> <Nop>
" nobody wants that bell!
set visualbell
set incsearch