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
# Patch Merb text_area Helper for escaping content | |
require 'merb-helpers' | |
module Merb::Helpers::Form::Builder | |
class Base | |
def unbound_text_area(contents, attrs) | |
update_unbound_controls(attrs, "text_area") | |
tag(:textarea, Merb::Parse.escape_xml(contents.to_s), attrs) | |
end | |
end |
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
#!/opt/local/bin/ruby | |
require 'rubygems' | |
require 'dm-core' | |
require 'dm-sweatshop' | |
require 'dm-aggregates' | |
require 'pp' | |
include DataMapper::Sweatshop::Unique |
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
# Fix ParanoidDateTime doesn't respect Resource.with_deleted | |
# Ticket: http://datamapper.lighthouseapp.com/projects/20609/tickets/883-paranoiddatetime-doesnt-respect-resourcewith_deleted | |
# Patch: http://github.com/kaichen/dm-core/commit/5117be5ebcc261225b0aae8c9c0fd45568c7eb3d | |
# setup load path | |
extlib = File.expand_path("~/Git/extlib/lib") | |
dm_core = File.expand_path("~/workspace/dm-core/lib") | |
data_objects = File.expand_path("~/Git/do/data_objects/lib") | |
$LOAD_PATH.unshift(extlib, dm_core, data_objects) |
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
# config/init.rb | |
DataObjects::Mysql.logger = DataObjects::Logger.new($stdout, :debug) if Merb.env?(:development) | |
DataObjects::Logger.class_eval do | |
def push_opened(string) | |
message = String.new(" ") | |
if(match = string.match(/FROM\s+[`'"](\w+)[`'"]\s+[WHERE|INNER]/)) | |
model_name = Extlib::Inflection.classify(match[1]) | |
color_sql = string.gsub(/debug\s?#{delimiter}/, ' ').gsub(/(SELECT.+)$/, "\e[36m\\1\e[0m") | |
message << "\e[4;32m[SELECT #{model_name}]\e[0m#{color_sql}" |
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
#!/bin/bash | |
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config | |
sudo env ARCHFLAGS="-arch x86_64" gem install do_mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config |
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
#!/bin/sh | |
# install last version of dm, do, extlib... | |
sudo gem install do_mysql data_objects extlib | |
sudo gem install dm-core dm-aggregates dm-migrations dm-timestamps dm-types dm-validations dm-serializer dm-sweatshop dm-is-tree --no-ri --no-rdoc |
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
# hack formtastic to add this feature: | |
# let form.inputs method could render the accessible attributes | |
# code in http://github.com/kaichen/formtastic | |
# rails_app_root/app/models/user.rb | |
class User < ActiveRecord::Base | |
... | |
attr_accessible :name, :email, :password, :password_confirmation | |
... | |
end |
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 'dm-core' # DM v0.10.2 | |
DataMapper.logger = DataMapper::Logger.new($stderr, :debug) | |
DataMapper.setup(:default, 'mysql://localhost/for_testing') | |
class Comment | |
include DataMapper::Resource | |
property :id, Serial | |
property :content, String |
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
#!/bin/sh | |
# count Kang's commits | |
git shortlog -s|egrep -i "(ysorigin|Kang)"|awk '{ SUM += $1} END { print SUM }' |
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
<html> | |
<head></head> | |
<body> | |
<table border="0" cellspacing="5" cellpadding="5"> | |
<tr><th>Header</th></tr> | |
<tr> | |
<form action="#" method="get" accept-charset="utf-8"> | |
<td><input type="submit" value="Continue →"></td> | |
</form> | |
</tr> |