This file contains hidden or 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
| #!/usr/bin/env ruby | |
| #usage file is optional, caches output in markov.yaml for subsequent runs | |
| #./markov [<file>] | |
| require './markov' | |
| yaml = "markov.yaml" | |
| m = Markov.new |
This file contains hidden or 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
| jruby --1.9 -r yaml -e 'YAML.load ["日本語"].to_yaml' | |
| Psych::SyntaxError: special characters are not allowed | |
| parse at org/jruby/ext/psych/PsychParser.java:282 | |
| parse_stream at /Users/markburns/.rvm/rubies/jruby-1.6.7.2/lib/ruby/1.9/psych.rb:148 | |
| parse at /Users/markburns/.rvm/rubies/jruby-1.6.7.2/lib/ruby/1.9/psych.rb:119 | |
| load at /Users/markburns/.rvm/rubies/jruby-1.6.7.2/lib/ruby/1.9/psych.rb:106 | |
| (root) at -e:1 | |
This file contains hidden or 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
| source :rubygems | |
| gem 'rack' | |
| gem 'rack-test' | |
| gem 'rspec', '2.11' |
This file contains hidden or 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
| #Alternative work around during tests | |
| Neo4j::Transaction.run do | |
| Neo4j.db.each_node do |n| | |
| n.del unless n.neo_id == 0 | |
| end | |
| end | |
| #VehicleType.all.count #but without this line all VehicleType.count calls are 0 after 'successful import' |
This file contains hidden or 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 'csv' | |
| def each_encoding | |
| encodings = ["utf-8", "ascii-8bit"] | |
| encodings.map do |src_encoding| | |
| encodings.map do |internal_encoding| | |
| encodings.map do |external_encoding| | |
| encodings.map do |file_encoding| | |
| encodings.map do |forced_encoding| | |
| yield src_encoding, | |
| internal_encoding, external_encoding, |
This file contains hidden or 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
| Kanji.create kanji: "abc" | |
| Starting local Neo4j using db /Users/markburns/code/kanji/db/neo4j-development using Java::OrgNeo4jKernel::EmbeddedGraphDatabase | |
| => #<Kanji:0xdfb596 @errors=#<ActiveModel::Errors:0x1257498 @base=#<Kanji:0xdfb596 ...>, @messages={}>, @_relationships={}, @_properties={"kanji"=>"abc", "heisig"=>nil, "heisig_number"=>nil, "_classname"=>"Kanji"}, @changed_attributes={}, @_create_or_updating=nil, @_java_node=#<Java::OrgNeo4jKernelImplCore::NodeProxy:0x559e4f>, @previously_changed={"kanji"=>[nil, "abc"], "_classname"=>["Kanji", "Kanji"]}, @_properties_before_type_cast={:kanji=>"abc"}, @validation_context=nil> | |
| jruby-1.6.7.2 :006 > Kanji.all.count | |
| => 0 | |
| jruby-1.6.7.2 :007 > k =Kanji.create kanji: "abc" | |
| => #<Kanji:0x136dabd @errors=#<ActiveModel::Errors:0x52c36e @base=#<Kanji:0x136dabd ...>, @messages={}>, @_relationships={}, @_properties={"kanji"=>"abc", "_classname"=>"Kanji"}, @changed_attributes={}, @_create_or_updating=nil, @_java_node=#<Java::OrgNeo4jKernelImplCore::NodeProxy:0x16ed8 |
This file contains hidden or 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
| #rails new my_app -m http://andreasronge.github.com/neo4j/rails.rb | |
| #...did some scaffolding | |
| #add index for a column I want UTF-8 text in | |
| #following stack trace on save: | |
| NativeException (java.lang.RuntimeException: org.apache.lucene.queryParser.ParseException: Cannot parse 'field_name: ': Encountered "<EOF>" at line 1, column 7. | |
| Was expecting one of: | |
| "(" ... | |
| "*" ... |
This file contains hidden or 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
| class SomeController | |
| def some_action | |
| context = SomeContext.new params | |
| if context.condition? | |
| flash[:notice] = "Hooray!" | |
| render :this | |
| else | |
| flash[:alert] = "On no!" | |
| render :that |
This file contains hidden or 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 'rbconfig' | |
| HOST_OS = RbConfig::CONFIG['host_os'] | |
| source 'http://rubygems.org' | |
| gem 'split', :require => 'split/dashboard' | |
| gem "rake" | |
| gem 'mysql2', '~> 0.3' | |
| gem 'rails', '3.2.2' | |
| gem 'sqlite3' |
This file contains hidden or 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
| class Array | |
| alias_method :old_first, :first | |
| def first &block | |
| if block_given? | |
| detect &block | |
| else | |
| old_first | |
| end | |
| end |