jakewmeyer / ruby-scripts Goto Github PK
View Code? Open in Web Editor NEWA collection of ruby scripts for those who live in the command line
License: MIT License
A collection of ruby scripts for those who live in the command line
License: MIT License
Ex. someone types in "united states", it would return "USD", in case the person doesn't know the currency symbol, but knows the name of the country.
Looking for a solution here
I have a suggestion that would help the commands be more useful to those creating scripts. It would also help the commands be used together in interesting ways.
Right now, many of them are interactive. They take an argument but you can't provide it as a command argument, you have to wait until the command runs and then you're prompted. For example, with ip_geo
, you're prompted what IP address you want. I noticed the stock
and currency
commands work this way too.
What I think would work better is if the command also allowed you to specify the argument as you run it, to avoid being prompted, for example. I could run ip_geo
like:
ip_geo 123.234.345.456
and get its output.
To go along with this, it would be neat if we could use options for the commands to make them only output pieces of data, so that they could be piped into other commands (perhaps even other Ruby-Scripts commands). For example, I could use an option for only outputting the WAN IP from ip_list
and use it this way, with ip_geo
(-m
for "machine output" etc):
ip_list -m wan | xargs ip_geo -m isp
...and I'd end up with only my ISP name in stdout.
What I envision is a sort of syntax with an option (like my -m
option above) to specify which output values you'd want. Perhaps, with ip_list
, the option -m wan,lan1
would print just the WAN address followed by the first LAN address, with a default delimiter (maybe a space). If all the commands were built this way, they could be combined in interesting ways.
Write a script that pulls from a stock price API, parses the information, and displays it ot the user in the command line.
Heya Jake,
I think you can safely omit the arguments to puts, in other words,
puts ''
should be equivalent to:
puts
If you want to you can also use something such as:
alias e puts
To make things even shorter. Anyway, it's great that you published code,
several of the code I have not ever thought about, such as encrypt, but
also the weather API showing more information than temperature (I
had a very simple weather script but only for local use in my country
and only the temperature; I never had the idea to include wind etc...)
By the way, I have noticed that you used the same banner for many
scripts. You can probably write this into a shared code, or into a
class and re-use that class. This may be a bit extra work since your
code is very simple so not really a need to do so, but if you intend
to add more code into your project there, I think it may be easier for
you to keep things more organized, and classes do help a lot here in
ruby. Feel free to close this issue at any moment in time, I just wanted
to give some feedback!
All the scripts need better error handling, to make the code more robust and fault tolerant
Writing a script that looks at the publicly available crime records so determine the amount of crime near your current location. Good exercise in interpretation of data, and interacting with a rest-api.
Add spacing and boxes to the responses, as well as exception handling
Currency converter uisng Fixer.io API
Hello Jake,
Following my comment on reddit, I would like to suggest to you that you may put these scripts also into a gem. That way others can also do "gem install " easily.
Looking for an API currently to provide the necessary data.
Currently the exception handling is catching all standard error, and not specific exceptions, which is bad practice. Top of the priority list currently.
When I try to use any of the commands from this gem, I get an error message mentioning a LoadError:
[mwelke@mdesk-arch ~]$ weather
/home/mwelke/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- rest-client (LoadError)
from /home/mwelke/.rvm/rubies/ruby-2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/mwelke/.rvm/gems/ruby-2.4.1/gems/jake-scripts-0.2.0/exe/weather:4:in `<top (required)>'
from /home/mwelke/.rvm/gems/ruby-2.4.1/bin/weather:23:in `load'
from /home/mwelke/.rvm/gems/ruby-2.4.1/bin/weather:23:in `<main>'
from /home/mwelke/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `eval'
from /home/mwelke/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `<main>'
Setup:
Something along the lines of Speedtest-CLI but implemented in a ruby-ish sort of way. Currently looking for an API that would support this type of functionality, but had zero luck thus far. Could possibly look into building the platform myself, but I need to do more research before committing to that implementation.
weather.rb, lines 46 and 66
visibility, not visability
Will submit a PR if you want, on mobile currently.
I get the following error when running netgeo -w
☁ provision [master] ⚡ netgeo -w
/Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rest-client-2.0.2/lib/restclient/request.rb:758:in `rescue in transmit': SSL_connect returned=1 errno=0 state=error: certificate verify failed (RestClient::SSLCertificateNotVerified)
from /Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rest-client-2.0.2/lib/restclient/request.rb:647:in `transmit'
from /Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rest-client-2.0.2/lib/restclient/request.rb:145:in `execute'
from /Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rest-client-2.0.2/lib/restclient/request.rb:52:in `execute'
from /Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rest-client-2.0.2/lib/restclient.rb:67:in `get'
from /Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/netgeo-0.1.0/exe/netgeo:25:in `block (2 levels) in netgeo'
from /Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/slop-4.3.0/lib/slop/option.rb:60:in `call'
from /Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/slop-4.3.0/lib/slop/option.rb:60:in `ensure_call'
from /Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/slop-4.3.0/lib/slop/parser.rb:95:in `process'
from /Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/slop-4.3.0/lib/slop/parser.rb:102:in `try_process'
from /Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/slop-4.3.0/lib/slop/parser.rb:61:in `block in parse'
from /Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/slop-4.3.0/lib/slop/parser.rb:46:in `each'
from /Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/slop-4.3.0/lib/slop/parser.rb:46:in `parse'
from /Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/slop-4.3.0/lib/slop/options.rb:71:in `parse'
from /Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/slop-4.3.0/lib/slop.rb:23:in `parse'
from /Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/netgeo-0.1.0/exe/netgeo:19:in `netgeo'
from /Users/ctompkinson/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/netgeo-0.1.0/exe/netgeo:118:in `<top (required)>'
from /Users/ctompkinson/.rbenv/versions/2.2.2/bin/netgeo:23:in `load'
from /Users/ctompkinson/.rbenv/versions/2.2.2/bin/netgeo:23:in `<main>'
I suspect this is due to missing a rescue when performing a get, which could handle and output a human readable error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.