How to get Processing to work on Cloud9 using Ruby language? - ruby

I am currently working on a personal project using the Ruby language in Cloud9 IDE. Recently, I came across an environment/programming language called Processing. My goals is to make Processing available for my use in Cloud9 IDE.
I am a complete novice and have no clue what I am doing. I followed directions from the following website: Directions for setting up Processing
I entered the following commands into Cloud9's terminal:
rvm install jruby
rvm use jruby
gem install ruby-processing
PROCESSING_ROOT: "/Applications/Processing.app/Contents/Java"
Entering in PROCESSING_ROOT: "/Applications/Processing.app/Contents/Java"
outputted message bash: PROCESSING_ROOT:: command not found
I wasn't too surprised by this, since the last entry probably needs information specific to my setup. Here are my questions:
1.) Are these directions correct for what I am trying to do? (get Processing to work in Cloud9 IDE). If they are not correct, can someone please point me to the correct directions, or give me directions?
2.) If these directions are correct, how can I successfully finish the last step? I tried running DrawRuby.rb, a simple program copied from the internet that supposedly made use of Processing. When I ran the code, the message "You need to set PROCESSING_ROOT in ~/.rpsrc" appeared. I am not sure if this piece of information is relevant or not, but I figured I would add it.
This is where I am at, and I am completely stuck. If someone could give me some help, I would be very grateful. Also, please make your explanation easy to understand. I am relatively new to the programming world, and may not necessarily understand terminology or how things should work.
Cheers!
*** Edit: I created a new workspace in Cloud9 IDE and tried Jed's suggestion. This is what happened:echo 'PROCESSING_ROOT: "/Applications/Processing.app/Contents/Java"' > ~/.rpsrc
:~/workspace $ rp5 run Draw.rb
WARNING: you need to set PROCESSING_ROOT in ~/.rp5rc
NameError: uninitialized constant Processing::RP_CONFIG
Did you mean? Config
RbConfig
const_missing at org/jruby/RubyModule.java:3344
spin_up at /usr/local/rvm/gems/jruby-9.1.7.0/gems/ruby-processing-2.7.1/lib/ruby-processing/runner.rb:188
run at /usr/local/rvm/gems/jruby-9.1.7.0/gems/ruby-processing-2.7.1/lib/ruby-processing/runner.rb:105
execute! at /usr/local/rvm/gems/jruby-9.1.7.0/gems/ruby-processing-2.7.1/lib/ruby-processing/runner.rb:67
execute at /usr/local/rvm/gems/jruby-9.1.7.0/gems/ruby-processing-2.7.1/lib/ruby-processing/runner.rb:61
<main> at /usr/local/rvm/gems/jruby-9.1.7.0/gems/ruby-processing-2.7.1/bin/rp5:10
load at org/jruby/RubyKernel.java:979
<eval> at /usr/local/rvm/gems/jruby-9.1.7.0/bin/rp5:1
eval at org/jruby/RubyKernel.java:1000
<main> at /usr/local/rvm/gems/jruby-9.1.7.0/bin/jruby_executable_hooks:15

You need to add a file to your home directory (~/) called .rpsrc and then add that environmental setting (PROCESSING_ROOT) to your file. The following should work from the command line in your cloud9 environment:
echo 'PROCESSING_ROOT: "/Applications/Processing.app/Contents/Java"' > ~/.rpsrc

I know it might be a bit late for you but ruby-processing is now deprecated, and will only work with processing-2.2.1. For processing-3.3.7 use either JRubyArt or propane latter does not even require processing install.

Related

Update libraries after manual change

So I started working on my first open-source contribution in ruby. There I have the library I'm working on in the /lib/ folder. Now when I tried changing the code, my program (which uses the library) still uses the old code.
For example: Broke a function on purpose by deleting its end keyword (which should be causing an immediate crash), but it kept working perfectly after I did.
Another example was changing the code in such a way it should still work (mutating the output string) but it still returned the old string.
user~$ bin/ruby-hyphen -V "this is a test sentence"
this is a test sen-tence
Does anyone know if I have to tell the runtime to refresh it or something along those lines?
I found out why that happened. The file has a *.gemspec, which made it act as if it was a gem. To see the changes I needed to enter:
gem build *.gemspec
bundle exec rake install
Or, if you want to develop quicker: change everywhere you require it into a require_relative. That should also fix it. I hope this question helps someone in the future!

Tensorflow object detection: ImportError: No module named nets

I am currently attempting to install the tensorflow object detection app on Windows 7 (employer requirement) and I am failing at a few steps from the end.
Basically I get the following error when I run the installation test command:
ImportError: No module named nets.
I have read some solutions on the subject:
https://github.com/tensorflow/models/issues/729
https://github.com/tensorflow/models/issues/1842
which looks like this:
export PYTHONPATH="$PYTHONPATH:"somepath"/tensorflow/models/slim"
basically meaning that I must set the right path in the PYTHONPATH environmental variable.
Working with Windows, I tried calling this:
SET PYTHONPATH="$PYTHONPATH:C:tensorflow/models/slim
And when it didn't work, I created a PYTHONPATH variable in system-> environmental variables.
I'm still getting the error so I suppose that I am still missing something but due to my lack of knowledge I still can't figure out what.
Would someone familiar with Windows be able to point out what's missing?
Thanks
in linux:
add export export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim to ~/.bashrc
attention:you should keep single quote mark
if you work with windows, i guess it should like this:PYTHONPATH=$PYTHONPATH:'C:/tensorflow/models':'C:/tensorflow/models'/slim
just my guess, you can take a try.
good luck!
If you run the setup.py it will install all the relevant modules for object detection. The other option is download the git directory. cd to the folder and try to run the module from there. You might face protubuf issue. Try to install it before running the code. It's bit complicated to install protobuf in windows. But if you are not using ".pb" file, then you don't need to.
I figured out a way to make it work. I am not writing this as a final answer as it is mostly a workaround and due to lack of understanding from my part I cannot guarantee it will work (and also it might not be best good practice).
Anyway here it is:
As Beta previously suggested, you have to run setup.py, however running it from models folder did not do it for me, I also had to run it from object detection folder.
However there was a problem there, it generated an error saying the BUILD already existed (which was correct) so I had to delete the BUILD file from inside of model.
After that it worked, turns out the path I had set was working fine.
Now if some experts would look into this and explain how and why this workaround worked it might make this a valid solution.

Problems installing Flagmatic

I'm trying to install Flagmatic on Mac OS X Yosemite, a software package used to solve problems in extremal graph theory using the "flag algebras" developed by Razborov. I'd like to use Flagmatic to help with a research problem I'm working on, but I'm finding it very difficult to install. I'm a mathematician and while I've had some experience using Sage and Python through the Terminal I don't really know how to fix the sort of problems that I'm running into here. Here's the most up-to-date user guide so you can follow what I'm trying to do. I can broadly break down the problem as follows:
First, there is a link in the user guide to download the semidefinite programming package CSDP which Flagmatic needs in order to do some calculations. You then need to move CSDP to somewhere Flagmatic can find it, so I typed
sudo cp ~/Downloads/csdp/usr/local/bin/
into Terminal, which seemed to work. Then the user guide says by typing
csdp
into Terminal it should launch CSDP. This doesn't work - I get a permission denied message even though I typed sudo. Can anyone explain why this is happening and how to remedy it?
Secondly, when I run Sage (maths software) in the Terminal, I then want to be able to change directory to the pkg folder where there is a script called setup.py. When I run sage and type
python setup.py install
or
-python setup.py install
while in the pkg directory, I get an invalid syntax message with a pointer to the particular phrase setup.py. This is what the user guide tells you to do. If I instead try to install outside of Sage I get an error message The environment variable SAGE_ROOT must be defined. Can anyone provide some explanation and help with how to fix this?
Wow, this is somewhat dated information that they provide, since for well over a year csdp is an experimental Sage package. You should be able to just do
sage -i csdp
to install it (if you have compiler tools, which you probably do in this case). I guess the old instructions would still work but are a little brittle w.r.t. Sage.
Anyway, to the actual problem. You need to do the exact command given in the instructions:
sage -python setup.py install
However, this assumes (!) that you have a sage command in your PATH. Which you may not!
In this case, I recommend you use whatever command you use to run Sage, but instead of just typing /commmand/for/sage do /command/for/sage -python setup.py install in that directory. It will have all the right environment variables set up so that it installs in the right place, I am guessing.
Now, I'm not sure why flagmatic isn't just having themselves become an upstream package on the Sage servers, but that is a question that is harder to answer.
I might udpate the documentation in the near future. For now, however, you might want to visit this: https://github.com/jsliacan/flagmatic-2.0.git. I keep Emil's copy of Flagmatic 2.0 with updated install info. If you follow the README file, you should be fine.
I just built sage on Yosemite from source (worked fine) and then installed Flagmatic 2.0 (or Flagmatic-dev) without difficulties. It should work for you too.
I hope this helps.

TestFirst.org Learn_ruby rake and depreciation warnings :should and :expect syntax

After many searches via Google I'm ready to get some input from the community. I'm trying to apply for App Academy in San Francisco and one of the required pre-work is TestFirst's Learn_ruby. I original had this configured on a Linux VM on my windows box. It worked very well. When I ran rake it would list one problem at a time; the text was is helpful colors; and the output was very condensed so I only got what I needed to read. I've recently wiped and configured my system as a dual boot Xubuntu 14.04/ Windows and the VM I once had is long gone. I worked to get Ruby setup in my linux vm just as I had done in the VM.
My problem now is when I run rake on my projects I get the same depreciation warning:
Deprecation Warnings:
Using should from rspec-expectations' old :should syntax without
explicitly enabling the syntax is deprecated. Use the new :expect
syntax or explicitly enable :should instead. Called from
/home/kaji/Projects/learn_ruby/05_silly_blocks/silly_blocks_spec.rb:25:in
`block (3 levels) in '.
After googling this back and forth I understand for the most part what the error is telling me. And I've even found a solution to get it to go away. Thanks to this post: RSpec's New Expectation Syntax, I was able to find a syntax to make the warning go away. (basicly had to change blah.should == # to expect(blah()).to eq(#) inside the *_spec.rb file. This seems to make the warning happy. However I still see signs that I have another problem.
The output isn't as 'friendly' as it was when I was on my VM. It's not in color; it dumps all the errors at once. What I enjoyed the most about learn_ruby was it gave me one objective at a time with minimal output. Now i have to scroll up quite a ways just to see what my issues are.
I've tired removing RVM completely and all gems and reinstalling to see if I could resolve this. No dice. I'm such a Ruby Noobie i'm a little overwhelmed with all this. I'd like to just get back to learning the basics but this has been troubling me for over a week. Has anyone had this problem/fix the except
I've also tried removing the rpsec ~<=2.0 from the Rakefile. I'm using ruby -v 2.1.2, rails 4.1.1 and i have RSpec 3.0.0, 2.99.0, 2.0.0. I even tried finding a tutorial on changing the syntax but it was real confusing as it introduced lots of Ruby concepts I have no idea on. At that point I feel like I'm over my head and there is something simple I'm missing.
Hope I provided enough info for assistance.
I hope I'm answering the correct question, since you seem to have figured out the one in the title (i.e. the preferred syntax having changed from blah.should to expect(blah).to). It would help if you changed the title to reflect the actual question.
RSpec.configure do |config|
config.fail_fast = true
config.color_enabled = true
}
will make RSpec fail at first error, rather than after running all tests, and enable the colours, for that one file.
Or you can run rspec with rspec --fail-fast --color.
Alternately, you can put this in $HOME/.rspec so it always does it:
--fail-fast
--color

Uninitialized constant error using Ruby in RubyMine

Has anyone used RubyMine who could help me out?
I am new to RubyMine, and when I create my first project and add a few classes and wire them together for a simple meaningless application I am getting this error:
"uninitialized constant RubyApp (NameError)"
But when I take all the classes and put them in one file then run it, it runs fine.
What am I missing about using RubyMine here?
Thanks for the help.
Is "RubyApp" one of your classes?
If so, it sounds like you're not requiring the other ruby files you're creating.
RubyMine pretty much doesn't get in your way at all, although it does like having gems 'attached' to the project.
Not sure if this applies to your case, since I've only run into this issue with gems. But, Rubymine requires you to link the gems your using and what not into your project settings for things to work. At least that is how I remember it when I tried it out.

Resources