Skip to content

Instantly share code, notes, and snippets.

View kalupa's full-sized avatar

Paul Kalupnieks kalupa

View GitHub Profile
def cleanup_variants
self.variants.each do |variant|
variant.variant_values.delete(self)
variant.destroy if variant.variant_values.count == 0
end
end
def update_cousin_variants_by_variant_value(variant_value)
first_sibling_value = variant_value.category.variant_values.first
existing_variants_with_this_value = self.variants.includes(:variant_values).where('variant_value_id = ?', first_sibling_value.id)
new_variants = []
existing_variants_with_this_value.each do |variant|
new_variant = product.variant.create(price: self.price)
variant.variant_values.each do |old_variant_value|
if old_variant_value.variant_category != variant_value.variant_category
new_variant.variant_values << old_variant_value
.blink {
-webkit-animation-duration: 1s;
-webkit-animation-name: blinky;
-webkit-animation-iteration-count: infinite;
}
@-webkit-keyframes blinky {
from {
opacity: 100%;
}
to {
var tileMap = [
['grass', 'dirty', 'dirty', 'dirty', 'dirty', 'dirty', 'grass'],
['grass', 'dirty', 'grass', 'stone', 'grass', 'dirty', 'grass'],
['grass', 'dirty', 'stone', 'stone', 'stone', 'dirty', 'grass'],
['grass', 'dirty', 'dirty', 'dirty', 'dirty', 'dirty', 'grass'],
['grass', 'grass', 'grass', 'grass', 'grass', 'grass', 'grass']
];
var loadBookmarkletDetail = function() {
var urlItem = $('#mox-url');
if (urlItem.length > 0) {
var saveURL = decodeURIComponent(window.location.toString().split("mox-box=")[1]);
urlItem.val(saveURL);
}
};
loadBookmarkletDetail();
subject.should.equal('div class="object-wrapper"><iframe width="100%" height="450" scrolling="no" frameborder="no" ' +
'src="//w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F723408&show_artwork=true">' +
'</iframe></div>');
sql = "SELECT courses.id as 'course_id',
courses.name as 'name',
courses.likes as 'likes',
courses.duration as 'time_total',
completions.finished as 'completed',
completions.finished_at as 'completed_on',
COALESCE(completions.duration,0) as 'time_remaining',
essentials.id as 'essential_id',
electives.id as 'elective_id',
electives.points as 'total_points',
@kalupa
kalupa / gist:3995969
Created November 1, 2012 19:44 — forked from awd/gist:3994607
how to determine one name vs another..
def make_selection
selections = []
1000.times { selections << ["manage", "settings"].sample }
selections.select { |s| s == "manage" }.size > selections.select { |s| s == "settings" }.size ? "manage" : "settings"
end
@kalupa
kalupa / Chrome
Created October 5, 2012 18:15
Error
info - socket.io started
GET / 200 52ms - 1.63kb
GET /socket.io/socket.io.js 404 20ms - 819
GET /my/feed?since_id=&before_id=&_=1349460841661 500 1403ms - 52
class Presenter
def remaining(items = section.essentials_remaining)
collection = ThemePresentation.wrap_collection(items, ContentItemPresenter)
render partial: 'woople-theme/content_item', collection: collection
end
end