Skip to content

Instantly share code, notes, and snippets.

View robvitaro's full-sized avatar

Rob Vitaro robvitaro

  • Lehigh Valley, PA
View GitHub Profile
@exocode
exocode / application_helper.rb
Last active November 2, 2021 15:01 — forked from juggy/call_template.rb
Render with ``render_to_string`` a complete page within a sidekiq worker including current_user
module ApplicationHelper
def current_user
@current_user ||= warden.authenticate(:scope => :user)
end
end
@mlanett
mlanett / rails http status codes
Last active June 14, 2024 06:07
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@L8D
L8D / median.rb
Last active February 21, 2018 21:41
Median of array in ruby
def median_of a
return nil if a.empty?
sorted = a.sort
len = sorted.length
(sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0
end