Skip to content

Instantly share code, notes, and snippets.

View jmoglesby's full-sized avatar

Jeremy Oglesby jmoglesby

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jmoglesby on github.
  • I am joglesby (https://keybase.io/joglesby) on keybase.
  • I have a public key ASCXeUUx0iGIz-1mr8admDT8dO1G0JiMvBKgI74YIpWxHQo

To claim this, I am signing this object:

@jmoglesby
jmoglesby / airtable_schedule_conflict_script
Last active June 22, 2023 01:59
This is a script written to aid in detecting scheduling conflicts in Airtable's "Event planning" template base, and with a Script Block
/*
Script: Check for Speaker Schedule Conflicts
Author: Jeremy Oglesby
License: MIT
This script was written to be used with the "Event planning"
Airtable template, and can be adapted to any similarly
structured base where the requirement to detect overlapping
start and end times is pressing.
@jmoglesby
jmoglesby / cloudSettings
Last active February 4, 2021 20:22
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-02-04T20:22:22.194Z","extensionVersion":"v3.4.3"}
class Box
attr_accessor :length, :width, :height, :volume
def initialize length, width, height
fail "Please give positive, non-zero numbers for all 3 values" unless
length.class == Integer &&
length > 0 &&
width.class == Integer &&
width > 0 &&
height.class == Integer &&
@jmoglesby
jmoglesby / index.html.erb
Created August 13, 2018 16:42
Example code: The main items index view from www.speedie.equipment
<!-- Search bar and filter dropdown -->
<div class="top-element mb-3">
<div class="search-form">
<%= form_for :items, method: :get do |f| %>
<div class="input-group input-group mb-2">
<%= label_tag :keywords, nil, class: "sr-only" %>
<%= search_field_tag :q, params[:q], placeholder: "Search", class: "form-control input" %>
<%= button_tag type: "submit", class: "btn btn-primary btn px-3" do %>
<%= fa_icon "search" %>
<% end %>
@jmoglesby
jmoglesby / items_helper.rb
Created August 9, 2018 17:30
Example code: Helper methods used in `items/index.html.erb` and `items/show.html.erb` from www.speedie.equipment
module ItemsHelper
def current_status_display_for_item(item)
case item.service_events.order(:service_date, :created_at).last&.status
when 'In Service'
'<span class="badge badge-success">In Service</span>'.html_safe
when 'Repair'
'<span class="badge badge-warning">
Repair
@jmoglesby
jmoglesby / item.rb
Created July 31, 2018 00:56
Example code: The "Item" model from www.speedie.equipment
class Item < ApplicationRecord
belongs_to :item_type
belongs_to :location
delegate :campus, to: :location
has_many :item_comments, dependent: :destroy
has_many :service_events, dependent: :destroy
has_one :last_service_event, -> { order(service_date: :desc, created_at: :desc) }, class_name: "ServiceEvent"
has_many :calibration_events, dependent: :destroy
has_one :last_calibration_event, -> { order(date_performed: :desc, created_at: :desc) }, class_name: "CalibrationEvent"
has_many :location_changes, dependent: :destroy
@jmoglesby
jmoglesby / calibration_forms_controller.rb
Created July 31, 2018 00:09
Example code: Controller I am working on for forms that post to an external API (Airtable) when submitted.
class CalibrationFormsController < ApplicationController
# Need not be a registered user to submit a calibration form
skip_before_action :authenticate_user!
def form
# limit current forms available for testing
valid_forms = ['','straight_edge', 'oven']
raise ActionController::UnknownAction unless valid_forms.include?(params[:id])
@title = params[:id].gsub('_',' ').titlecase