Skip to content

Instantly share code, notes, and snippets.


Sean C Davis seancdavis

View GitHub Profile
View cb--LiveCountdownHeader.html
<!-- ID: 881 -->
<div class="container-fluid sticky-top">
<div class="row">
<a href="javascript:void(0)" class="btn btn-live-schedule-trigger hidden-xs" data-smooth-scroll-to="live-stream-schedule"
data-smooth-scroll-offset="92" data-track-click="liveSeeScheduleClicked">
<span>See Schedule</span>
<svg class="icon icon-1" viewbox="0 0 256 256">
<use xmlns:xlink="" xlink:href="/assets/svgs/icons.svg#chevron-down"></use>
seancdavis / script.rb
Last active Jan 6, 2023
Move files up one directory in Ruby
View script.rb
require 'fileutils'
path = File.expand_path('../', __FILE__)
Dir.glob("#{path}/**/*.*").each do |file|
new_path = "#{path}/#{file.split('/')[-1]}", new_path)
seancdavis / base.rb
Created Jun 24, 2017
Load all modules within a namespaced directory
View base.rb
module Utils::All
# I wrote this originally for model concerns, in which case I needed
# the following line to be included:
# extend ActiveSupport::Concern
Dir.glob(File.expand_path('../', __FILE__) + '/*.rb').each do |util|
next if File.basename(util) == 'base.rb'
include "Utils::#{File.basename(util, '.rb').camelize}".constantize
seancdavis / head-link.html
Last active May 30, 2017
Multiple CSS Imports
View head-link.html
seancdavis / index.html
Created Mar 3, 2016
Full-Size, Looping Background Video with YouTube Video
View index.html
.bg-video {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
overflow: hidden;
z-index: -1;
seancdavis / notify_slack.rb
Created Dec 7, 2015
Post incoming webhook to Slack using Ruby
View notify_slack.rb
# Assumes:
# - curl is installed
# - you have a slack channel with an incoming webhook configured
require 'json'
def notify_slack(webhook_url, channel, username, text, image)
payload = {
:channel => channel,
:username => username,
seancdavis / download_image.rb
Created Dec 7, 2015
Download a collection of images from URLs using Ruby
View download_image.rb
require 'open-uri'
def download_image(url, dest)
open(url) do |u|, 'wb') { |f| f.write( }
urls = [
seancdavis / dragonfly_import.rake
Last active Aug 29, 2015
Transition from CarrierWave to Dragonfly in Rails
View dragonfly_import.rake
require 'csv'
desc 'Import local files (with csv references) using Dragonfly'
task :dragonfly_import => :environment do
config = [
{:model => Attachment, :attr => :document}
storage_dir = "#{Rails.root}/lib/cw_refs"
seancdavis / project
Created Nov 17, 2014
Simple command line script using Ruby (
View project
#!/usr/bin/env ruby
# Include libraries
require 'fileutils'
# Make sure we have our argument
if ARGV.size < 1
puts "Usage: project [DIR]"
seancdavis / image.rb
Last active Jan 12, 2022
Rails has_many :through Polymorphic Association (
View image.rb
# app/models/image.rb
class Image < ActiveRecord::Base
has_many :taggings, :as => :taggable
has_many :tags, :through => :taggings