Skip to content

Instantly share code, notes, and snippets.

View billturner's full-sized avatar

Bill Turner billturner

View GitHub Profile
def assign_tags(tags)
tags.split(',').collect {|t| t.strip}.uniq.each do |tag|
thistag = Tag.first_or_create(:name => tag.downcase)
PostTagging.create(:post_id => self.id, :tag_id => thistag.id)
end
end
def update_tags(tags)
self.post_taggings.each { |tagging| tagging.destroy }
self.post_taggings.reload
class Post
attr_accessor :taglist
include DataMapper::Resource
property :id, Serial
property :title, String, :length => 255
property :slug, String, :length => 255
property :body, Text
property :published, Boolean, :default => false
%div.post
%h3
%a{ :href => permalink_url(post), :rel => 'bookmark', :title => "Permanent link for this post" }= post.title
%div.postbody
=find_and_preserve do
=markdown(post.body)
%div.meta
-if post.tags.count > 0
-post.tags.each do |tag|
%a{ :href => tag_url(tag), :rel => 'category tag', :title => "View other posts tagged with '#{tag.name}'" }= "##{tag.name}"
module Harmony
# Allows accessing config variables from harmony.yml like so:
# Harmony[:domain] => harmonyapp.com
def self.[](key)
unless @config
raw_config = File.read(RAILS_ROOT + "/config/harmony.yml")
@config = YAML.load(raw_config)[RAILS_ENV].symbolize_keys
end
@config[key]
end
require 'rubygems'
require 'active_record'
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.establish_connection(
:adapter => 'mysql',
:database => 'jasons_db',
:username => 'root',
:password => 'password',
:host => 'localhost')
%dl
%dt
=f.label :title, :caption => "Post Title"
%dd
=f.text_field :title, :value => @post.title, :size => 50
%dt
=f.label :body, :caption => "Post Body"
%dd
=find_and_preserve do
=f.text_area :body
@billturner
billturner / reset.sass
Created January 25, 2010 17:54 — forked from bak/reset.sass
A local copy of the handy sass version of reset.css - thanks bak!
// http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded
// Copyright 1995-2007 Eric A. and Kathryn S. Meyer
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
#!/bin/sh
#
# init.d script with LSB support.
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.
basedir = "/media_drop/xml_video/"
Dir.chdir(basedir)
@ready_videos = Dir.glob("*.xml")
#!/usr/bin/env ruby
# Usage: gemspec [-s] GEMNAME
#
# Prints a basic gemspec for GEMNAME based on your git-config info.
# If -s is passed, saves it as a GEMNAME.gemspec in the current
# directory. Otherwise prints to standard output.
#
# Once you check this gemspec into your project, releasing a new gem
# is dead simple:
#