Skip to content

Instantly share code, notes, and snippets.

View ebrett's full-sized avatar

Brett McHargue ebrett

View GitHub Profile
@ebrett
ebrett / index.html
Created July 24, 2023 16:32
UK clickable map
<div class="cta-map-container">
<!-- REMOVE THIS SECTION BELOW?-->
<a id="img_map" href="/ADD-HYPERLINK-HERE"><img src="http://news.cliniccompare.co.uk/sites/default/files/filemanager/UK%20Taboola%20Map%204.png" alt="UK map"></a>
<!-- REMOVE THIS SECTION ABOVE?-->
<svg version="1.1" id="svg_map" xmlns="http://www.w3.org/2000/svg" xmlns:x="&amp;ns_extend;" xmlns:i="&amp;ns_ai;" xmlns:graph="&amp;ns_graphs;" x="0px" y="0px" viewBox="125 -1112 1450.9 2375" xml:space="preserve" width="305px" height="500px">
<metadata id="metadata211">
<sfw xmlns="&amp;ns_sfw;">
<slices></slices>
@baweaver
baweaver / deep_group.rb
Created August 2, 2022 05:53
Deep grouping, because I keep doing something like this by hand and it gets hard to keep track of.
module DeepGroup
class Grouping
IDENTITY = -> v { v }
def initialize(state)
@state = state
@groupings = []
@mapping = IDENTITY
end

⚠️ this is now stupidly out of date

Computers

  • 13" Macbook Pro 3.3 GHz i7 (late 2016)
  • Microsoft Surface Book (2016)

Peripherals

@landovsky
landovsky / add_signature_fields_to_delayed_jobs.rb
Last active November 21, 2023 08:47 — forked from synth/add_signature_fields_to_delayed_jobs.rb
Prevent Duplicates with Delayed Jobs
class AddFieldsToDelayedJobs < ActiveRecord::Migration
def change
add_column :delayed_jobs, :signature, :string, index: true
add_column :delayed_jobs, :args, :text
end
end
@iscott
iscott / simple_authentication_rails_5_bcrypt_and_has_secure_password.md
Last active May 22, 2024 08:00
Cheat Sheet: Simple Authentication in Rails 5 with has_secure_password

Cheat Sheet: Simple Authentication in Rails 6 with has_secure_password

The goal of this cheatsheet is to make it easy to add hand-rolled authentication to any rails app in a series of layers.

First the simplest/core layers, then optional layers depending on which features/functionality you want.

Specs
AUTHOR Ira Herman
LANGUAGE/STACK Ruby on Rails Version 4, 5, or 6
@jarednorman
jarednorman / webpack-rails-1.markdown
Last active May 13, 2020 18:24
Webpack with Rails Part 1

Webpack with Rails Part 1

I don't like Sprockets, but it's the easiest and best choice for lots of Ruby on Rails projects. When looking for a better way to manage my JavaScript assets and an improved developer story, my current tool of choice is webpack. While I wish Rails supported drop-in asset pipelines the way that Phoenix does, it's not hard to use webpack with Rails.

@ryan0x44
ryan0x44 / Terraform-Blue-Green-AWS.md
Created November 19, 2015 21:57
Blue-Green AWS Auto Scaling Deployments with Terraform

A quick note on how I'm currently handling Blue/Green or A/B deployments with Terraform and AWS EC2 Auto Scaling.

In my particular use case, I want to be able to inspect an AMI deployment manually before disabling the previous deployment.

Hopefully someone finds this useful, and if you have and feedback please leave a comment or email me.

Overview

I build my AMI's using Packer and Ansible.

@OlegIlyenko
OlegIlyenko / Event-stream based GraphQL subscriptions.md
Last active May 16, 2024 02:05
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

@jcieslar
jcieslar / selectize_spec.rb
Created March 19, 2015 16:33
Capybara and selectize
page.execute_script("$('.selectize-input input').val('ber')")
sleep 0.5
page.execute_script("$('.selectize-input input').keyup()")
sleep 0.5
page.execute_script("$('.full-name').mousedown()")
# https://github.com/brianreavis/selectize.js/blob/master/src/selectize.js
@andywenk
andywenk / email_address_validator.rb
Created September 3, 2014 10:34
simple email adress validator; checks if the server responds and has an MX or A record
require 'mail'
require 'resolv'
require 'net/telnet'
class EmailAddressValidator < ActiveModel::EachValidator
attr_reader :mail
def validate_each(record, attribute, value)
return if options[:allow_nil] && value.nil?