This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://nodejs.org/api.html#_child_processes | |
var sys = require('sys') | |
var exec = require('child_process').exec; | |
var child; | |
// executes `pwd` | |
child = exec("pwd", function (error, stdout, stderr) { | |
sys.print('stdout: ' + stdout); | |
sys.print('stderr: ' + stderr); | |
if (error !== null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# parse ruby log message | |
# customize as needed | |
LOG_EXPRESSION = /([\w]+),\s+\[([^\]\s]+)\s+#([^\]]+)]\s+(\w+)\s+--\s+(\w+)?:\s+(.+)/ | |
# sample log output from this call: | |
# logger.info("Ubiquitously") { "[dequeud] #{JSON.generate(params)}"} | |
string = 'I, [2010-08-15T16:16:46.142801 #81977] INFO -- Ubiquitously: {"title":"Google","url":"google.com","tags":"search, google, api","services":["meta_filter","mixx"],"description":"a search engine!"}' | |
sample_output.gsub(LOG_EXPRESSION) do |match| | |
severity = $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'uri' | |
require 'mechanize' | |
require 'rack/utils' | |
# so you can do `params.inspect` throughout Mechanize | |
class NilClass; def search(*args); []; end; end | |
Mechanize::Chain::PostConnectHook.class_eval do | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<article> | |
<header> | |
<h1>Where is the "content" HTML5 tag?!?</h1> | |
<h2>We Need Better HTML Tags for better markup!</h2> | |
<meta> | |
<time class='published'></time> | |
<meter>4.7 stars</meter> | |
<keywords>html, standards</keywords> | |
</meta> | |
</header> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Example "ARTICLE" in "semantically ideal" and "optimized" versions | |
--> | |
<!-- ideal semantic version --> | |
<article> | |
<header> | |
<hgroup> | |
<h1></h1> | |
<h2></h2> | |
</hgroup> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
site do | |
# menu | |
menu "main" do | |
link "/", "Home" | |
link "/blog", "Blog" | |
# link "/portfolio", "Portfolio" | |
link "http://lancepollard.info/", "Resume" | |
end | |
# javascripts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"site.feed.formats"=> | |
#<Cockpit::Definition:0x2510034 | |
@key="formats", | |
@nested=false, | |
@value=["rss", "atom"]>, | |
"site.time_zone"=> | |
#<Cockpit::Definition:0x2510494 | |
@key="time_zone", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
module Associations | |
class HasManyThroughAssociation < HasManyAssociation | |
protected | |
# added support for STI with polymorphism | |
def construct_conditions | |
table_name = @reflection.through_reflection.quoted_table_name | |
conditions = construct_quoted_owner_attributes(@reflection.through_reflection).map do |attr, value| | |
if attr =~ /_type$/ | |
construct_polymorphic_sql(table_name, attr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def select_attributes(*names) | |
return nil if names.blank? | |
conditions = names.extract_options! | |
as = conditions.delete(:as) | |
if self.column_names.include?("type") | |
conditions[:type] = (Array(conditions[:type]) + [self.name, self.base_class.name]).compact.uniq | |
end | |
conditions = conditions.keys.map do |key| | |
value = Array(conditions[key]).map { |v| Array(v.to_s).map { |i| self.quote_value(i) } }.uniq.join(",") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FormatAttribute | |
unloadable | |
def self.included(base) | |
base.class_eval do | |
class << self | |
# format :cash, :except => "$" | |
# format :date do |value| | |
# Date.parse(value) | |
# end |