Ruby Script to Runnable File - ruby

I'm a programming newb trying to send a Ruby script/mini-game thing to his teacher that can be ran by doubleclick. JRuby seems like a possible solution, as does Warbler, but I can't seem to figure either of those out. It doesn't have to be a specific filetype if it can be run without the terminal, just by clicking on it. Another possible solution is creating a shell script that runs the file as shown here, but I think that only works if you tell the computer running the script that it can be doubleclicked. It may even be possible to run by doing something in the Ruby file itself, but I am too inexperienced to know.
Thanks in advance for your answers!

When you say that only works if you tell the computer running the script that it can be doubleclicked, that isn't entirely true. If you email the file by itself, it might have its permissions removed, but if you package it up into a zip, then you're teacher shouldn't need to run chmod again.
Anyway, I'm not sure about the windows support for this approach (Ruby programmers tend to use Unix systems like OSX or Linux).
To make a cross platform executable, take a look at this question, which links to some packages such as "Ruby Ship"

Related

Run program without any thing installed?

Recently I have been making many useful programs, And I wanted to share these with my friends but in order to do that I first need to install that programming language on their computer. so I have been wondering that how could I code programs that don't require me to install something else.
meaning in order to run that program you only need to run a setup once and then you can use that program.

Ruby/Tk in a browser

Is there a quick and easy way to make a ruby/Tk script run in a browser? I wrote a handy-dandy little ruby/tk script to do stuff. A friend saw it and said that his friends would love to use it, but they are extremely non-technical and cannot handle installing ruby (even though I showed him how simple it is). What he wants is for me to give him a link that someone can click on a browser and magically make the tool run.
I've looked around and get the impression that it cannot be done. 'it just does not work that way'. But I have not seen a clear 'NO' . I see things on how to get ruby to run in a browser, but not the Tk part. I also looked at rubyscript2exe but get the impression that it was abandoned.
No, you can't directly run Ruby in the browser like that.
There are websites such as RubyFiddle which let you run short snippets. What they're actually doing is executing the code remotely then displaying the result.
Because this code is actually being executed remotely, there's no way of running something interactive (like a TK UI) with it. There are some services which give you a hosted Ruby environment with working Terminal, but even these aren't going to work with a TK UI.
This section of Ruby Gems https://www.ruby-toolbox.com/categories/packaging_to_executables has a good list of all the tools available to package Ruby apps for distribution though, so you might be able to send them a simple installer to allow them to use it locally?
I've had a lot of success doing this with https://github.com/larsch/ocra/ which is actively maintained.

Write a windows script

I would like write a script to automate a certain task on windows.
I use a monitor to extend the screen of my laptop but every time I remove the plug and reconnect the monitor I have to go on to desktop properties and display settings to extend the monitor and set the resolution.
Well I assume on LINUX you can do this by using shell scripting but I am not sure how to do this in windows.
From my research on the internet I have found that BASH scripts could be used to do this task automatically.
Please guys I don't need a software to do this I would like to write the script myself so that I can learn something as well.
I have read up on bash scripting but I cant find methods to access windows components and just to let you know I am an intermediate JAVA programmer. I guess I could use JAVA as well.
I hope my questions are clear.
Thank You
Bash scripting is for *nix systems, the equivalent on windows is Batch Scripting.
Some quick googling indicates that this can be done through registry edits, but they would not take effect until the next reboot.
Other than that, it doesnt look like doing that through batch scripting is possible.
If you want to look at another programming language to do this, check out this answer

What kind of Tools Exist for Setup Automation in Windows?

I'm looking for some type of solution for getting a window dev environment up and running quickly.
Currently we have a large setup document (50+ pages) for doing an install, and I'd like to automate this process as much as possible. The doc includes things like updating environment variables, installing programs, downloading source code, etc.
I know that the majority of these tasks can be done with a batch script, but that's kind of ugly and a lot of work. And while virtualization would be nice, it is not an option for us.
I'm wondering if anything exists for Windows that would make this less tedious. Something like Ruby's Chef would be great. Does anything like this exist for windows?
Well there is Pkgmgr.exe for unattended installation of windows components if you mix it with a powershell script you should be able to get what you want but it wont be as easy as using Chef. Check here for an example of what you can do with Pkgmgr.exe http://learn.iis.net/page.aspx/133/using-unattended-setup-to-install-iis-70/
System Center is the Microsoft way of pushing out standard desktops. It's quite heavyweight mind you.
You could use VMWare for this. Just create a base machine image, with the necessary stuff installed, and point people at the VM.

How can I determine if my process is being run interactively?

Is there a standard(ish) POSIX way of determining if my process (I’m writing this as a Ruby script right now; but I’m curious for multiple environments, including Node.js and ISO C command-line applications) is being run in an interactive terminal, as opposed to, say, cron, or execution from another tool, or… so on and so forth.
Specifically, I need to acquire user input in certain situations, and I need to fail fatally if that is determinably not possible (i.e. being run by cron.) I can do this with an environment variable, but I’d prefer something more standard-ish, if I can.
I've always used $stdout.isatty to check for this. Other approaches might include checking the value of ENV['TERM'] or utilizing the ruby-terminfo gem.
The closest you'll get, AFAIK, is isatty(). But as the page itself says, nothing guarantees that a human is controlling the terminal.
As #Mitch wrote it in a comment, which can also be useful to some people:
For anyone who came here looking for windows, try System.Environment.UserInteractive for .Net or GetUserObjectInformation for win32, which will fail for non-interactive processes

Resources