Skip to content

Instantly share code, notes, and snippets.

View erikpukinskis's full-sized avatar

Erik Pukinskis erikpukinskis

View GitHub Profile
class Order
has_many :foods, :through => :line_items
has_many :merchandise_items, :through => :line_items
has_many :line_items
def total
line_items.map(&:price).sum
end
end
# in ApplicationController:
unless Rails.application.config.consider_all_requests_local
rescue_from Exception, NoMethodError, :with => :render_500
rescue_from ActiveRecord::RecordNotFound,
ActionController::RoutingError,
ActionController::UnknownController,
ActionController::UnknownAction, :with => :render_404
end
# In app/models/user.rb
acts_as_authentic do |c|
c.merge_validates_length_of_email_field_options({:unless => :inactive?})
c.merge_validates_format_of_email_field_options({:unless => :inactive?})
c.merge_validates_uniqueness_of_email_field_options({:unless => :inactive?})
c.require_password_confirmation = false
c.merge_validates_length_of_password_field_options({:unless => :inactive?, :minimum => 3})
c.merge_validates_length_of_login_field_options({:within => 2..40, :unless => :inactive?})
c.merge_validates_format_of_login_field_options({:unless => :inactive?})
@erikpukinskis
erikpukinskis / exceptional_bulk_select.js
Created May 23, 2013 18:48
Javascripts for doing bulk closing of Exceptional exceptions.
grab = function(regex) { return $(".error h2 a").filter(function(i,a) { return $(a).attr("title").match(regex)}) }
cb = function(regex) { return grab(regex).parent().parent().parent().find("input[type=checkbox]")}
ids = function(regex) { return grab(regex).map(function(i,a) { return $(a).attr('href').split('/')[2]}).toArray().join(',') }
// This will load all of your items onto the page:
timer = setInterval(function() { $("#more-link-technology").trigger("more-me") }, 500)
// Wait for the last page (if you have 1000 exceptions, the last page will be around 100).
// Put a breakpoint at javascripts/application.js:911 at the $.post
@erikpukinskis
erikpukinskis / gist:6259136
Created August 17, 2013 23:18
Pinboard.in bookmarklet to copy/paste in iOS
javascript:if(document.getSelection){s=document.getSelection();}else{s='';};document.location='https://pinboard.in/add?next=same&url='+encodeURIComponent(location.href)+'&description='+encodeURIComponent(s)+'&title='+encodeURIComponent(document.title)
www.livefyre.com
@erikpukinskis
erikpukinskis / licks.tab
Last active December 30, 2015 13:49
Licks
E|--7--5--5--7--5--
B|--8--0--5--5--5--
G|--0--7--5--------
D|-----------------
A|-----------------
E|-----------------
GBEB GBEB GBEB EB EB
# These are the coefficients that R gives me from my logistic regression:
intercept = 0.2700309
coefficients = {
high: 1.0136028,
low: 1.0016712,
germ_mean: 1.0233327,
gdds: 0.9990283,
early_gdds: 0.9986464,
mid_gdds: 1.0002979,
def translate(english)
english.gsub(/[A-Za-z]+/) do |word|
translate_word(word)
end
end
def translate_word(english)
first = english[0]
remainder = english[1, english.length]
pig = remainder + first.downcase + 'ay'
<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<style>
.slides {
overflow: hidden;
white-space: nowrap;
}