Skip to content

Instantly share code, notes, and snippets.

Bill Turner billturner

Block or report user

Report or block billturner

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:50765
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
View post.rb
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
View gist:195479
%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}"
View harmony.rb
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
View simple_db_conn.rb
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')
View _post_form.haml
%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 Jan 25, 2010 — forked from bak/reset.sass
A local copy of the handy sass version of reset.css - thanks bak!
View reset.sass
// 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,
View MongoDB
#!/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.
View gist:293799
basedir = "/media_drop/xml_video/"
Dir.chdir(basedir)
@ready_videos = Dir.glob("*.xml")
View gemspec
#!/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:
#
You can’t perform that action at this time.