Make a ruby script with text IO double clickable executable file?
Assuming you're targeting Mac OS X (Unix) or Linux you can put this line at the top of your Ruby file to make it compatible with the Terminal:
#!/bin/ruby
Basically, this tells the shell (Terminal) to run the contents of the file with whatever executable you write after #!
. In this case, you're instructing it to use the ruby
executable that you use to run your code elsewhere.
To allow the Ruby script to be executed, you'll need to make it executable by running:
chmod a+x my_script.rb
Finally, to get double clicking support, you might have to replace the .rb
extension with .sh
so the operating system recognizes it as a shell script and not a Ruby file.
You might also consider a GUI of some sort. Shoes is a great way to create nice user interfaces, and it's really easy to use. It also allows you to generate executable files for Windows, OS X, and Linux if I remember correctly.
Here's an example, which creates a basic, clickable button:
Shoes.app do
@button = button "Click Me"
@button.click do
puts "Clicked!"
end
end
How to run a shell script in OS X by double-clicking?
First in terminal make the script executable by typing the following command:
chmod a+x yourscriptname
Then, in Finder, right-click your file and select "Open with" and then "Other...".
Here you select the application you want the file to execute into, in this case it would be Terminal. To be able to select terminal you need to switch from "Recommended Applications" to "All Applications". (The Terminal.app application can be found in the Utilities folder)
NOTE that unless you don't want to associate all files with this extension to be run in terminal you should not have "Always Open With" checked.
After clicking OK you should be able to execute you script by simply double-clicking it.
Unable to save the file in specified location using Autoit
It depends on the software you are trying to automate but usually this happens because the software is not recognizing there is a change in the file save path box. The problem is in how ControlSetText works. Try using ControlSend with some error checking to make sure the file path you are try to set is getting put in right. Sometimes you have to play with a few different variations to see what works with the software you are automating. Here are two examples you can try:
Example one:
WinWait("[CLASS:#32770]", "", 10)
If Not @error Then ;make sure the window was found
$hWin = WinGetHandle("[CLASS:#32770]") ;get window handle
ControlSetText($hWin, "", "Edit1", $CmdLine[1]) ;set text
ControlFocus($hWin, "", "Edit1") ;just to make sure we have focus
ControlSend($hWin, "", "Edit1", "{ENTER}")) ;should work like click button 1 but you will have to check
;better then a sleep
$hTimer = TimerInit() ; Begin the timer and store the handle in a variable.
Do
Until WinExists($hWin) = 0 Or TimerDiff($hTimer) >= 10000
EndIf
Example two:
WinWait("[CLASS:#32770]", "", 10)
If Not @error Then ;make sure the window was found
$hWin = WinGetHandle("[CLASS:#32770]") ;get window handle
While 1
ControlSetText($hWin, "", "Edit1", "") ;just makes sure there is no text in the control text
ControlFocus($hWin, "", "Edit1") ;just to make sure we have focus
ControlSend($hWin, "", "Edit1", $CmdLine[1])) ;set text using ControlSend
If ControlGetText($hWin, "", "Edit1") = $CmdLine[1] Then ExitLoop ;makes sure that the control got ALL of the text before exiting loop
WEnd
ControlClick($hWin, "", "Button1");
;better then a sleep
$hTimer = TimerInit() ; Begin the timer and store the handle in a variable.
Do
Until WinExists($hWin) = 0 Or TimerDiff($hTimer) >= 10000
EndIf
Hex representation of a color with alpha channel?
In CSS 3, to quote from the spec, "there is no hexadecimal notation for an RGBA value" (see CSS Level 3 spec). Instead you can the use rgba() functional notation with decimals or percentages, e.g. rgba(255, 0, 0, 0.5) would be 50% transparent red. RGB channels are 0-255 or 0%-100%, alpha is 0-1.
In CSS Color Level 4, you can specify the alpha channel using the 7th and 8th characters of an 8 digit hex colour, or 4th character of a 4 digit hex colour (see CSS Color Module Level 4 spec*)
As of July 2022, >95% of users can be expected to understand the #RGBA format
It has been supported since:
- Firefox 49, released Sept 2016 (Mozilla bug 567283).
- Safari 10, released Sept 2016.
- Chrome 62, released Oct 2017. For earlier versions you could enable experimental web features to use this syntax. See Chromium Issue 618472 and Webkit bug 150853.
- Opera 52, released March 2018 (or Opera 39 when experimental web features are enabled).
- Edge 79, released Jan 2020 (the first version of Edge based on Chromium)
- Samsung Internet 8.2, released Dec 2018
- Android P (your app must target Android P or newer)
It is not supported in:
- IE
- Original Edge (version numbers up to and including 18)
- Opera Mini
- UC Browser
Up to date browser support information is available on CanIUse.com
Sublime Text from Command Line
From build 3065 (Release Date: 29 August 2014) onwards Sublime text
includes a command line helper, nameley subl.exe
. It is at sublime's installation folder: copy it in to a folder included in the system path.
For example, in my case I copied it
from C:\Program Files\Sublime Text 3
to C:\Windows\System32
You may then use in your terminal/console subl
as a command to open whatever file, such as in your example:
subl file.rb
Or you may as well modify your system PATH
variable to include sublime's instalation folder, but I believe that is much more involved.
Related Topics
I Want to Return a Single Result Using .Find() with Ruby on Rails
Rails 3 + Daemons Gem: Exception When Querying Model
My Classes Can't Use Shoes Methods Like Para
Rails: How to Pass Custom Params to a Controller Method
To_SQL Not Working on Update_Attributes or .Save
How to Add "Access-Control-Allow-Origin" Headers to API Response in Ruby
Reply to Thread Google-Api-Ruby-Client
Invalid Route Name, Already in Use: 'Admin_Root' (Argumenterror) - Failed Activeadmin Install
What Does the |Variable| Syntax Mean
Find a Unique Element in a Compound Array
Disabling Flash Message Without Disabling Cache on Click on Back Button in Rails
Editing JSON Array Contents in Ruby
How to Write a Method That Counts the Most Common Substring in a String in Ruby
Ruby on Rails Group_By (How to Group Events by Month)