Skip to content

Instantly share code, notes, and snippets.

View radar's full-sized avatar

Ryan Bigg radar

View GitHub Profile
@radar
radar / _form.html.erb
Created November 30, 2015 02:24
trying to use jquery to change the starting bid field to readonly if fixed price is selected from the drop down menu
<script>
$("format").change(function () {
if(document.getElementById('format').selected=='Fixed price')
{
// do something
}
});
</script>
@radar
radar / application_controller.rb
Last active November 17, 2015 21:36 — forked from brunoalano/application_controller.rb
Path: app/controllers/company/api/application_controller.rb
module Company
module Api
class ApplicationController < Company::ApplicationController
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :null_session
# Disable Layout
layout false
end
def mode(array)
hash = Hash.new(0)
array.each do |i|
hash[i]+=1
end
return hash.max.select{|x, y| x }
end
require 'open-uri'
require 'nokogiri'
require 'rails'
url = "http://eveboard.com/pilot/Livid_Retreat"
data = Nokogiri::HTML(open(url))
skill = data.at_css('.dotted')
def create
begin
params[:referral][:dob] = Date.strptime(params[:referral][:dob], '%m/%d/%Y')
rescue ArgumentError
# error goes here
end
@referral = Referral.new(referral_params)
def current_user
begin
@current_user ||= User.find(session[:user_id]) if session[:user_id]
rescue ActiveRecord::RecordNotFound
reset_session
end
end
helper_method :current_user
@radar
radar / route.rb
Last active August 29, 2015 14:10 — forked from 1dolinski/route.rb
controller "posts" do
scope path: "/posts/:id" do
post "one"
delete "two"
end
end
# same as
post "/posts/:id/one", to: "posts#one"
class Player
def initialize(name, health = 100, rank = 1)
@name = name.capitalize
@health = health
@rank = rank
end
def say_hello
puts "#{@name} has #{@health} health and #{@rank} rank."

NoMethodError at /coders
undefined method `time_counter' for #<Coder:0x007f8d5def4a88>

views/coders/index.html.erb

<% @coders.each do |coder| %>
  <div class="post_item">
    <%= image_tag coder.cover_image, class:"cover_image_index" %>
    <div class="index_title"><%= sanitize coder.title %></div>
    <div class="index_description"><%= sanitize coder.description %></div>
class EventController < ApplicationController
def edit
event
end
private
def event
@event ||= Event.find(params[:id])
end