Skip to content

Instantly share code, notes, and snippets.

View tubbo's full-sized avatar
😎
losing my sight, losing my mind, go to the general to save some time

Tom Scott tubbo

😎
losing my sight, losing my mind, go to the general to save some time
View GitHub Profile
<div class='main-content'>
<h2 class='greeting'>Free hi-res stock images for both personal & commercial use.</h2>
<ul class='optionsnavi'>
<li class='dropdown'>
<button class='dropbtn'>
Sort By <i class="fa fa-sort-desc" aria-hidden="true"></i>
</button>
<div id='myDropdown' class='dropdown-content'>
<%= link_to "Latest", :sort => "created_at asc" %>
@tubbo
tubbo / model.rb
Last active October 5, 2016 14:54 — forked from wolfravenous/model.rb
Need to move Logic From the View into The Model, Rails v. 4.2, The current entry in the model for setting the gender in comments, works correctly because comment is an attribute of report. Would like to move the logic currently in the view to the model, however I am unsure of how to because content is an attribute of intro, which is a nested res…
def genderized_comment
comment.gsub(/HESHE/, gender_pronoun.capitalize)
end
def gender_pronoun
gender == 'female' ? 'she' : 'he'
end
@tubbo
tubbo / test.rb
Last active August 5, 2016 17:32
params = {}
room = { wall:"red", size:4 }
params[:house] = room
puts params[:house][:wall] # => 'red'
@tubbo
tubbo / model.rb
Created June 28, 2016 19:21
Rails model query
Content::LibraryPage.each { |c| puts c.live.title if c.live.title.in?(months) }
# The error message
undefined method `comments_path' for #<#<Class:0x007f01f0513be8>:0x00000003b43928>
Did you mean? font_path
Extracted source (around line #1):
1
2
3
4
@tubbo
tubbo / log_extender.rb
Last active March 22, 2016 17:48 — forked from anonymous/log_extender.rb
Example of what I'd like to have happen with logging
class LoggerKhan < Logger
def add(severity, message = nil, progname = nil)
return super unless severity == 'info' && "#{message}" =~ /some_tag/
redis_logger.add(severity, message, progname)
end
private
def redis_logger
@redis_logger ||= Logger.new Rails.root.join('log', "redis_#{Rails.env}.log")
puts 'holy shit it worked'
class ApprovedStep < ActiveRecord::Base
# you'd probably want to put your structured data here
end
@tubbo
tubbo / login.rb
Last active December 2, 2015 19:55
class Login < ActiveRecord::Base
def self.average_seconds_to_login
average :time
end
end
@tubbo
tubbo / new.html
Last active November 12, 2015 18:22
<a data-role="collapsible" data-theme="f" data-iconpos="right" data-collapsed-icon="arrow-d" data-expanded-icon="arrow-u" class="inline-collapsible dark-border">
<h3>Categories</h3>
<fieldset data-role="controlgroup">
</fieldset>
</a>