Skip to content

Instantly share code, notes, and snippets.

View markburns's full-sized avatar
💭
👋

Mark Burns markburns

💭
👋
View GitHub Profile
@markburns
markburns / markov
Created September 13, 2012 19:25
generate slightly more human friendly UUID
#!/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
@markburns
markburns / gist:3466090
Created August 25, 2012 13:58
jruby_psych_error
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
@markburns
markburns / Gemfile
Created August 21, 2012 12:04
rspec OutOfMemoryError
source :rubygems
gem 'rack'
gem 'rack-test'
gem 'rspec', '2.11'
@markburns
markburns / failed_attempt_batch_import.rb
Created August 7, 2012 15:49
Problem with neo4j-core-java-2.0.1
#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'
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,
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
@markburns
markburns / gist:3058973
Created July 6, 2012 08:37
neo4j lucene index issue
#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:
"(" ...
"*" ...
class SomeController
def some_action
context = SomeContext.new params
if context.condition?
flash[:notice] = "Hooray!"
render :this
else
flash[:alert] = "On no!"
render :that
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'
class Array
alias_method :old_first, :first
def first &block
if block_given?
detect &block
else
old_first
end
end