Linked List

A personal knowledge base

Style Guide

#Pages Start with a H1 Title in Titlecase

Each page has at least one tag in the frontmatter.

#Heading Level 2

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

#Heading Level 3

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

#Heading Level 4

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

#Heading Level 5

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

#Heading Level 6

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

#Code

Here is a code sample:

def sync_from(document)
  # Loop over items, find which ones are new and insert them,
  # update items that have been updated
  # attr_accessor :title, :author, :link, :description, :guid, :published_at, :enclosures
  has_new_items = false

  Feed.transaction do
    # Testing showed that update_attributes will only run an update query if
    # the new atttribute values are different
    update_attributes!(title: document.title, description: document.description)

    Artwork.find_or_create_by!(:url => document.artwork_url) if document.artwork_url.present?

    document.each_entry do |item|
      feed_item = items.find_or_initialize_by(guid: item.guid) do
        has_new_items = true
      end

      if feed_item.published_at != item.published_at # TODO: Need to ensure these are compatible types
        feed_item.update_from(item)
        feed_item.save! # TODO: Handle failure to save by reporting error somewhere
      end
    end
  end

  has_new_items
end

#Quote

Anyone who thinks, like this fella does, that garbage collected virtual machines are always a good idea has never done serious numerics, data acquisition or real time work, which is half of what makes the world go around. Most people who consider themselves programmers are employed effectively selling underpants on the internet using LAMP. Therefore most people think that’s what programming is.

http://scottlocklin.wordpress.com/2012/09/12/not-all-programmers-alike/

#Links & Lists

Last modified: 28 Jan 2016