Skip to content

Instantly share code, notes, and snippets.

View wrburgess's full-sized avatar
:shipit:
Shippin'

Randy Burgess wrburgess

:shipit:
Shippin'
View GitHub Profile
@wrburgess
wrburgess / import_and_parse_remote_csv_rails.md
Created November 3, 2014 14:24
Import and parse remote csv with Rails
require 'csv'
require 'open-uri'

csv_text = open('http://www.vvv.hh.yyy.ggg/~hhhh/uuuu.csv')
csv = CSV.parse(csv_text, :headers=>true)
csv.each do |row|
  puts row
end
@wrburgess
wrburgess / gist:3778949
Created September 24, 2012 22:54
Setup wicked_pdf and wkhtmltopdf with Rails 3 and Heroku
@wrburgess
wrburgess / active_admin_model.rb
Created March 10, 2014 21:04
active admin, ransack, filter, select, array
filter :roles_contains, as: :select, multiple: true, collection: Roles.all_roles
@wrburgess
wrburgess / example.js
Created January 9, 2022 21:44
Rails erb view embed json in html and retrieve with JS dom
const widgetsData = document.querySelector('.widgets-data');
const widgets = JSON.parse(widgetsData.value);
@wrburgess
wrburgess / dynamic_div_wrapper.html.erb
Created January 9, 2022 21:41
Rails stimulus per-page or per-view controller actions. keywords: javascript, ruby, rails, stimulus, esbuild
<div
class="container-fluid admin <%= params[:controller] %> <%= params[:action] %>"
data-controller="<%= obj.model_name.plural.downcase %>"
data-<%= obj.model_name.plural.downcase %>-action="<%= params[:action] %>"
>
</div>
@wrburgess
wrburgess / date_filter_stacked.html.erb
Last active January 7, 2022 23:07
Form Templates - erb ruby rails html form input select textarea text number checkbox bootstrap5
<label class="label">License Period Start Date</label><br/>
<div class="input-group mb-3">
<div>
<span class="input-group-text label-from">From</span>
<input placeholder="From" type="date" name="q[license_period_start_date_gteq_datetime]" id="license_period_start_date_gteq_datetime" value="<%= params.dig(:q, :license_period_start_date_gteq_datetime) %>">
</div>
<div>
<span class="input-group-text label-to">To</span>
<input placeholder="To" type="date" name="q[license_period_start_date_lteq_datetime]" id="license_period_start_date_lteq_datetime" value="<%= params.dig(:q, :license_period_start_date_lteq_datetime) %>">
</div>
@wrburgess
wrburgess / gist:1944532
Last active September 26, 2021 03:13
Ruby and Date/Time random date in range
date_of_last_entry = Date.parse(Time.at(last_entry).strftime('%Y/%m/%d')) #2011-02-29
Date.today - date_of_last_entry == 0
# get random DateTime in last 3 weeks
DateTime.now - (rand * 21)
@wrburgess
wrburgess / gist:2004212
Created March 8, 2012 23:53
Excel Formulas
="http://example.com/" & SUBSTITUTE(R12, "#", "")
@wrburgess
wrburgess / example_job.rb
Last active April 6, 2020 20:17
ActiveJob on Rails 5 with RSpec
# app/jobs/example_job.rb
class ExampleJob < ActiveJob::Base
queue_as :default
rescue_from(ActiveRecord::RecordNotFound) do
retry_job wait: 1.minute, queue: :default
end
def perform(param_1, param_2)
@wrburgess
wrburgess / conferences.md
Created February 4, 2020 21:44
Conference Options

Thinking

With a large chunk of the team aiming for GopherCon, I wanted to see if you all thought there was value in my going to something completely different, but I'm game to head to GopherCon due to the team-learning aspect, too.

Subjects

As I took a look at the various things I might learn for the new team, these subjects came to mind:

  • Front-end (JS)
  • Security