I wrote a program in Gnuplot (a .gp file) to read data from a .txt file and plot scatter graph. How to write a program in Ruby env for running the .gp file? Should I put all the files in the same folder as well as the Gnuplot application folder? I'm not sure how to set the right path.
why don't you try the ruby gem "gnuplot"?
sometimes it is easier to use gnuplot directly, but gem gnuplot has helped me a lot too because i can directly put the data that i want to draw from my ruby program.
i recommend you to have a try gem gnuplot
btw, if i'm not mistaken usually gnuplot read data from .dat file instead of .txt
Related
I am making a program that can analyze graphs from PDF files. I pretty much have it working the way I want, and I'm trying to automate the script with AWS Lambda.
On my local machine using mutool does the job, but this doesn't seem to work on AWS.
command = "mutool clean -d #{input_path} #{output_path}"
system command
When I run that in my lambda function the output_path file just remains empty. How can I decompress the PDF file without using mutool/system commands?
gem install pdf-reader
require 'pdf-reader'
reader = PDF::Reader.new(input_path)
content = reader.pages.first.raw_content
File.write(output_path, content)
Trying to learn more about the many mysteries of bash.
I have neovim installed. I have nvim aliased to vim. I have nvim configured to use my vim config.
Let's say I want to use the real vim command, though. which vim yields "/usr/local/bin/vim".
But calling /usr/local/bin/vim directly results in the error given in the title. Why is that? How can I run my vim command directly?
From the result of the file command it seems that the file in /usr/local/bin/vim is somehow broken (the system doesn't recognize it as an elf file).
The file command should identify any executable file with the file format (and other types of files). When this command returns output of data it means that it couldn't identify the file at all.
Since you found the vim executable in Cellar/vim/8.1.1000/bin/vim, you can use this file instead of file which is in /usr/local/bin/vim, or you can create the link by yourself, that should fix this error.
If you would create the link with absolute path instead of relative path, it should work.
So I am writing a gem that runs through the command line to learn how to count cards. How do I set the file structure so that the file is run and get get input from the user?
For example what runs the function that makes the code work is a ruby file that contains only the following:
require "cardcounter.rb"
CardCounter.run_program
Is there a way that when the user downlaods my cardcounting gem, they can just type cardcount and it would run CardCounter.run_program, without having to be in irb or anything?
You need to create a bin directory in your gem's file structure and put the relevant code there (in your case in cardcount file).
Read more here.
I am using PVRTexTool to convert png files to pvr files but the tool seems to only be able to run on one file at a time(wont accept *.png as file name).
does anyone know how to run it on a group of files at once?
Its really a hassle to run it on all of my textures.
In a shell, run
for file in *.png ; do
PVRTexToll $file
done
(I don't know how to call PVRTeXTool from a command line, so please substitute the second line with a correct version)
This is a general way to feed each file to a command which only accepts one file at a time. See any introduction on shell scripting, e.g. this discussion of the for loop.
I need to archive multiple files using ruby, but I need to archive them in such way that they could be extracted without using my script (so I need popular format).
Problems with tar are max file length and problems with random file access while writing tar.
Good pure ruby library or ruby binding is highly desirable.
Built-in compression would be a good addition (so i don't need to use zlib ruby binding around archiving).
Ruby Zip is very stable, we use it to allow users to download bundles of images.
So why not just use something like this
`tar -czf myarchive.tgz myfiles/*`
from inside of your ruby script? If they have the executable to extract the files, surely they have a command line tar executable.