Skip to content

Instantly share code, notes, and snippets.

View steveclarke's full-sized avatar

Steve Clarke steveclarke

View GitHub Profile
" https://gist.github.com/steveclarke/ba73c6b2e198f14f1b729ad6825c04ca
" Leader is <space>
let mapleader = ' '
nnoremap <Space> <Nop>
" nobody wants that bell!
set visualbell
set incsearch
@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
{% 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' %}
@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"
@mrmartineau
mrmartineau / stimulus.md
Last active April 19, 2024 09:41
Stimulus cheatsheet
@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
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 4.0"
gem "railties", "~> 4.0"
gem "tzinfo"
# Let's use thin
@malarkey
malarkey / Contract Killer 3.md
Last active May 8, 2024 16:02
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………

@steveclarke
steveclarke / capybara.md
Created April 10, 2012 17:32
RSpec Matchers

Capybara

save_and_open_page

Matchers

have_button(locator)