Skip to content

Instantly share code, notes, and snippets.

View mackato's full-sized avatar

Masakuni Kato mackato

View GitHub Profile
@mackato
mackato / as3-commons-maven-repository.xml
Created March 17, 2010 10:20
as3-commons maven repository
<!--
as3-commons repository
@see http://code.google.com/p/as3-commons/source/browse/trunk/pom.xml
-->
<repository>
<id>yoolab.org-releases</id>
<url>http://dev.yoolab.org/maven/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
require 'rubygems'
require 'sinatra'
use Rack::Static, :urls => ["/images"], :root => "src/public"
@mackato
mackato / closure_singleton.as
Created March 26, 2010 01:19
ActionScript Singleton pattern
public class Singleton {
public static var getInstance:Function = function():Singleton {
var instance:Singleton = new Singleton();
getInstance = function():Singleton {
return instance;
};
return getInstance();
@mackato
mackato / rails_3.0.0.beta3_rspec_2.patch
Created May 24, 2010 18:22
Fix controller spec errors
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/te
index 34499fa..aed493a 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -18,6 +18,7 @@ module ActionController
ActiveSupport::Notifications.subscribe("render_template.action_view") do |name, start, fi
path = payload[:layout]
+ @layouts ||= Hash.new(0)
@layouts[path] += 1
Person.order_by([[:_id, Mongo::DESCENDING]])
@mackato
mackato / docrails_guides_epub.diff
Created June 4, 2010 02:57
Ruby on Rails Guides ePub diff
diff --git a/railties/guides/assets/stylesheets/main.css b/railties/guides/assets/stylesheets/main.css
index bab0b7a..5889d24 100644
--- a/railties/guides/assets/stylesheets/main.css
+++ b/railties/guides/assets/stylesheets/main.css
@@ -72,20 +72,20 @@ table th {
--------------------------------------- */
body {
- text-align: center;
- font-family: Helvetica, Arial, sans-serif;
@mackato
mackato / eeepub_maker_assets_subdir.diff
Created June 4, 2010 03:19
EeePub maker.rb assets subdir diff
78c78,79
< FileUtils.cp(file, dir)
---
> FileUtils.mkdir_p(File.join(dir, file[:dir])) if file[:dir]
> FileUtils.cp(file[:path], File.join(dir, (file[:dir] || '')))
98c99,101
< :manifest => @files.map{|i| File.basename(i)},
---
> :manifest => @files.map{|i|
> i[:dir] ? File.join(i[:dir], File.basename(i[:path])) : File.basename(i[:path])
@mackato
mackato / rails_guides_to_epub.rb
Created June 4, 2010 03:24
Ruby on Rails Guides ePub convert ruby script
require 'rubygems'
require 'nokogiri'
require 'eeepub'
DOC_TITLE = 'Ruby on Rails Guides'
def get_pages(src_dir)
index_file = File.join(src_dir, 'index.html')
section = nil
pages = [{ :section => section, :title => DOC_TITLE, :path => index_file }]
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
if (newSectionIndex != nil)
[self.tableView insertSections:newSectionIndex
withRowAnimation:UITableViewRowAnimationFade];
else
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade];
@mackato
mackato / coredata.rb
Created September 20, 2010 07:24
ruby coredata access class
require 'rubygems'
require 'sqlite3'
class Coredata
attr_accessor :db
def initialize(app_name)
pattern = File.join("#{ENV['HOME']}",
"/Library/Application Support/iPhone Simulator/*",
"/Applications/*/Documents/#{app_name}.sqlite")