Octopress Chokes on Blogger-Imported HTML - ruby

everyone. I'm using this ruby script to import my Blogger XML file into Octopress. The initial import works fine, the XML is parsed and HTML files are generate in ./_posts/ (with the proper naming convention). I moved these to ./source/_posts/ so Jekyll could parse them for use in the site. When I try to use rake -t generate, I get this error:
samurailink3#Manacotti:~/Dropbox/Important Backups/Git Repos/samurailink3.com$ rake -t generate
** Invoke generate (first_time)
** Execute generate
## Generating Site with Jekyll
unchanged sass/screen.scss
Configuration from /home/samurailink3/Dropbox/Important Backups/Git Repos/samurailink3.com/_config.yml
Building site: source -> public
/usr/lib/ruby/1.9.1/uri/common.rb:304:in `escape': undefined method `gsub' for 3:Fixnum (NoMethodError)
from /usr/lib/ruby/1.9.1/uri/common.rb:623:in `escape'
from /var/lib/gems/1.9.1/gems/jekyll-0.12.0/lib/jekyll/post.rb:140:in `block in url'
from /var/lib/gems/1.9.1/gems/jekyll-0.12.0/lib/jekyll/post.rb:140:in `map'
from /var/lib/gems/1.9.1/gems/jekyll-0.12.0/lib/jekyll/post.rb:140:in `url'
from /home/samurailink3/Dropbox/Important Backups/Git Repos/samurailink3.com/plugins/sitemap_generator.rb:69:in `location_on_server'
from /home/samurailink3/Dropbox/Important Backups/Git Repos/samurailink3.com/plugins/sitemap_generator.rb:219:in `fill_location'
from /home/samurailink3/Dropbox/Important Backups/Git Repos/samurailink3.com/plugins/sitemap_generator.rb:181:in `fill_url'
from /home/samurailink3/Dropbox/Important Backups/Git Repos/samurailink3.com/plugins/sitemap_generator.rb:146:in `block in fill_posts'
from /home/samurailink3/Dropbox/Important Backups/Git Repos/samurailink3.com/plugins/sitemap_generator.rb:144:in `each'
from /home/samurailink3/Dropbox/Important Backups/Git Repos/samurailink3.com/plugins/sitemap_generator.rb:144:in `fill_posts'
from /home/samurailink3/Dropbox/Important Backups/Git Repos/samurailink3.com/plugins/sitemap_generator.rb:120:in `generate'
from /var/lib/gems/1.9.1/gems/jekyll-0.12.0/lib/jekyll/site.rb:190:in `block in generate'
from /var/lib/gems/1.9.1/gems/jekyll-0.12.0/lib/jekyll/site.rb:189:in `each'
from /var/lib/gems/1.9.1/gems/jekyll-0.12.0/lib/jekyll/site.rb:189:in `generate'
from /var/lib/gems/1.9.1/gems/jekyll-0.12.0/lib/jekyll/site.rb:40:in `process'
from /var/lib/gems/1.9.1/gems/jekyll-0.12.0/bin/jekyll:264:in `<top (required)>'
from /usr/local/bin/jekyll:23:in `load'
from /usr/local/bin/jekyll:23:in `<main>'
Any ideas? Everything was working perfectly until I attempted the import.
Also, here is the code if you want to have a look. I'm working off of the source branch.

I expect that these types of errors are pretty common when doing an automatic translation and that each time has its own tricks and turns. When I did an import into jekyll, it choked on iframe HTML tags (for embedded videos) that weren't closed. Even though they were valid, the parser didn't like them. You may have something similar going on.
This line:
/usr/lib/ruby/1.9.1/uri/common.rb:304:in `escape': undefined method `gsub' for 3:Fixnum (NoMethodError)
gives you the first clue of where to start. Something is trying to call 'gsub'. My first step would be to search for that string in your output files. If you find one, temporarily remove all the other files in your ./source/_posts/ directory except for it. This will reduce the size of your problem set and let you experiment more to figure out exactly what's going on. Start hacking on that file until you get it to work.
Update:
If you don't find 'gsub' (and I've seen a few more references to it that make me think you won't find that as a string). A good trouble shooting approach is still to only keep one file at a time in your ./source/_posts/ directory to narrow down exactly what is going on.

Related

How to run wukong examples?

Wukong looks like a pretty nice Ruby way to get into Hadoop through the streaming interface. However, after looking over the examples at the git page:
https://github.com/infochimps-labs/wukong/tree/master/examples
I have no idea how to actually run any of these and generate output.
EDIT: I tried running the following example:
$ ./word_count.rb --run=local README.txt .
This generates an error:
/Users/evanzamir/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- wukong/script (LoadError)
from /Users/evanzamir/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from ./word_count.rb:2:in `<main>'
It seems to be having an issue with the line require 'wukong/script', but I'm not sure how to fix it.

Testing PocketSphinx server

I'm interested in setting up a web based speech recognition service for testing purposes. I did some research and found Ruby PocketSphinx Server. They claim to accept input as an audio file and return a JSON file with the text from the audio input. This is exactly what I need.
The problem is I'm new to Ruby and Sphinx/PocketSphinx. Even though I followed the documentation to setup the environment, I'm still completely lost. I got as far as running this command unicorn -c unicorn.conf.rb config.ru but got this error:
/usr/lib/ruby/vendor_ruby/unicorn/configurator.rb:74:in `read': No
such file or directory - unicorn.conf.rb (Errno::ENOENT) from
/usr/lib/ruby/vendor_ruby/unicorn/configurator.rb:74:in `reload' from
/usr/lib/ruby/vendor_ruby/unicorn/configurator.rb:67:in `initialize'
from /usr/lib/ruby/vendor_ruby/unicorn/http_server.rb:104:in `new'
from /usr/lib/ruby/vendor_ruby/unicorn/http_server.rb:104:in
`initialize' from /usr/bin/unicorn:121:in `new' from
/usr/bin/unicorn:121:in `<main>'
In the root directory of the ruby-pocketsphinx-server folder there should be a file called unicorn.conf.rb.
You should be running the unicorn -c unicorn.conf.rb config.ru command in the root directory.

Error while trying to import Blogger Posts into Octopress/Jekyll

I wanted to switch my main blog to Octopress earlier today and so, I cloned Octopress, configured it and deployed it in Heroku.
Then I searched the net on how to import my old blogger posts into Octopress and found this script as the answer to it:
https://gist.github.com/1578928
I have the exported blog.xml file with me. When I run the script in the gist, I get the following error. I've just started with Ruby and I don't know much about it. I would be glad if anyone could help me with this. The error seems completely new and I couldn't find any answers to this from my searches so far.
import.rb:33:in `add': dunno ide (RuntimeError)
from import.rb:158:in `block in <main>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.2-x86-mingw32/lib/nokogiri/xml/node_set.rb:239:in `block in each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.2-x86-mingw32/lib/nokogiri/xml/node_set.rb:238:in `upto'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/nokogiri-1.5.2-x86-mingw32/lib/nokogiri/xml/node_set.rb:238:in `each'
from import.rb:157:in `<main>'
Looking at the script in the Gist you linked, the problem is that it can only parse 'post' and 'comment' types, while you seem to have another one called 'ide'.
You should double check if the output XML is all right and doesn't have strangely named tags.

Ruby 1.9 and Sass encoding issues. (from ASCII-8BIT to UTF-8)

I recently upgraded to Ruby 1.9 and I can no longer compile anything with Sass.
I've seen solutions that state if I place
#charset "utf-8";
at the top of my .sccs file, it will fix it. However I'm still getting an error. Here's the full traceback
I've also tried removing any non-ascii characters from my CSS file, creating a new one, etc. It just won't compile. Any tips?
Traceback:
Sass is watching for changes. Press Ctrl-C to stop.
/home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/util.rb:496:in `encode': transcoding not supported (from ASCII-8BIT to UTF-8) (ArgumentError)
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/util.rb:496:in _enc'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/util.rb:515:inrescue in block (1 levels) in '
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/util.rb:508:in `block (1 levels) in '
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/util.rb:472:in `yield'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/util.rb:472:in `default'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/util.rb:472:in `block in check_sass_encoding'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/util.rb:471:in `each'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/util.rb:471:in `find'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/util.rb:471:in `check_sass_encoding'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/engine.rb:349:in `check_encoding!'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/engine.rb:316:in `_to_tree'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/engine.rb:291:in `_render'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/engine.rb:238:in `render'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/plugin/compiler.rb:319:in `update_stylesheet'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/plugin/compiler.rb:169:in `block in update_stylesheets'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/plugin/compiler.rb:167:in `each'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/plugin/compiler.rb:167:in `update_stylesheets'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/plugin/compiler.rb:214:in `watch'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/plugin.rb:111:in `method_missing'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/exec.rb:408:in `watch_or_update'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/exec.rb:294:in `process_result'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/exec.rb:41:in `parse'
from /home/webdev/.gem/repository/gems/sass-3.1.1/lib/sass/exec.rb:21:in `parse!'
from /home/webdev/.gem/repository/gems/sass-3.1.1/bin/sass:8:in `'
from /home/webdev/.gem/repository/bin/sass:19:in `load'
from /home/webdev/.gem/repository/bin/sass:19:in `'
To complete #nex3 answer you can
Open the config.rb file and add:
Encoding.default_external = "UTF-8"
It looks like somehow your Ruby environment is set up to load the Sass source code as ASCII-8BIT, a.k.a. BINARY. This is probably because you're either passing the -Kn flag to the Ruby process, or setting Encoding.default_external to Encoding::BINARY somewhere in your code before Sass is loaded. Undo this, and Sass should work.
I don't know exactly the core of the issue, but it seems there were some problems with Ruby 1.9.0 (the version available on apt for this Ubuntu box) and encoding.
To solve the issue, I used https://rvm.io which is a helper to download and compile Ruby from Git, giving me the latest version. After running this, sass compiles fine and everything is swell.
This happened to me and the solution was not apparent: Elena Pogorelova of Jet Brains explained in this post that non-ASCII characters in your files route may break SASS, as was in my case.
users/xxxx/projects/chilediseño/cms/scss (ñ)
I just had to eliminate the (ñ) in the name above and everything worked.
This is probably obvious, but are you sure your Sass file is UTF-8 encoded? Any decent text editor will let you convert encodings.

Using external libraries in Ruby

I have compiled a library(GDAL) written in C/C++ with Ruby bindings.
After a ran make install it was installed under
/Users/igor/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/x86_64-darwin10.6.0/
There is a directory there called "gdal" with 4 files inside: gdal.so, gdalconst.so, ogr.so, osr.so
What I want now is to use these libraries in my project. The problem is that when I try to referense these files
require 'gdal/gdal'
I get
LoadError: no such file to load --
gdal/gdal from
:29:in
require' from
<internal:lib/rubygems/custom_require>:29:in
require' from (irb):1 from
/Users/igor/.rvm/rubies/ruby-1.9.2-p136/bin/irb:16:in
`'
When I run ruby -e 'puts $:' I get following output:
/Users/igor/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1
/Users/igor/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/x86_64-darwin10.6.0
/Users/igor/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby
/Users/igor/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/vendor_ruby/1.9.1
/Users/igor/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/vendor_ruby/1.9.1/x86_64-darwin10.6.0
/Users/igor/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/vendor_ruby
/Users/igor/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1
/Users/igor/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/x86_64-darwin10.6.0
Any ideas why it doesn't work for me?
After make install on OS X you should have a .bundle file in your path /Users/igor/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/x86_64-darwin10.6.0.
If you want to use it then, you just have to require 'gdal' and it should fine.
It looks like you are not using a extconf.rb file to help you generate your makefile.
You might want to read this tutorial and check Rice if you want to write a C++ extension. (Ruby is written in C and you need to expose a C API, Rice makes that easier).
Thank you guys for your suggestions. I've finally figured out the problem. It seems like the fact that I was using rvm to manage ruby versions was causing the problem. As soon as I switched to system default(rvm use system) everything worked out well.

Resources