How to read and use ruby-nmap documentation? - ruby

I find myself unable to use the ruby-nmap documentation at
http://www.rubydoc.info/gems/ruby-nmap/Nmap
There are simply no code examples and therefore I quite can't figure out on how to use & read the documentation properly. Can somebody give me an overview on how to get started and what for example "#address" means?

You could look at the github page, that seems to have some usage examples.

E.g.
require 'nmap/program'
Nmap::Program.scan(targets: '192.168.0.1', verbose: true)
Follow Nmap::Program.scan documentation and choose your options from Nmap::Task. Experiment a bit :)

Related

langRestrict=en doesn't return any values anymore

I used to use queries like this when searching:
https://www.googleapis.com/books/v1/volumes?q=isbn:0590353403&langRestrict=en&maxResults=5&printType=books&showPreorders=false&fields=items(volumeInfo(authors,imageLinks,pageCount,title,industryIdentifiers))
Recently however, it seems that using langRestrict=en no longer return results. If I remove that, it works again.
https://www.googleapis.com/books/v1/volumes?q=isbn:0590353403&maxResults=5&printType=books&showPreorders=false&fields=items(volumeInfo(authors,imageLinks,pageCount,title,industryIdentifiers))
If I look at the book in question, the language is listed as language="un" now:
https://www.googleapis.com/books/v1/volumes?q=isbn:0590353403
Can anyone explain what changed, and should I be using langRestrict=un instead? (What language is un? I can't seem to find information on it.) Thank you.

How to write a filter with the MediaWiki AbuseFilter extension

Hello there,
just a "quick" question - I already installed the mediawiki properly - same with the extension itself, all working properly.
The thing is that Mediawiki extension page (https://www.mediawiki.org/wiki/Extension:AbuseFilter) won't tell me much about HOW to write a code for a filter, and google searches didn't return any valuable data like code block examples.
I'd be overjoyed if somebody could provide me a working code for the filter, even as simple as one for replacing typical f-bomb for the word "flowers", or whatever, since strReplace does nothing on it's own and I have no idea how to handle things.
Thanks in advance for any suggestions. :)
The official manual is here. For real-life examples, just go to Special:AbuseFilter on a wiki that's using it and see the code of public filters. For example, on English Wikipedia.

Use Flyspell-prog-mode with go-autocomplete

Using flyspell-prog-mode in emacs causes go-automplete to choke. Is there anyway I can make these two modes play nicely together?
I have researched using another spell checker but did not find one that has same capabilities as flyspell (i.e only check comments and strings, and do it on the fly). Any tips most appreciated, thanks
This is a general issue with auto-complete. Just do
(ac-flyspell-workaround)
after setting up auto-complete.
jpkotta was correct. Complete solution for reference was:
(with-eval-after-load 'go-mode
(require 'go-autocomplete)
(ac-flyspell-workaround))

Ruby: configure_with method

I occasionally see configure_with in Ruby code but can't find any documentation for this method despite several Google searches.
For an example of configure_with see
Where to place/access config file in gem?
Any suggestions?
Here are some references:
http://rubydoc.info/github/sferik/rails_admin/RailsAdmin/Config.configure_with
http://www.ruby-doc.org/gems/docs/r/rack_gyazo-0.1.2/Rack/Gyazo.html#method-c-configure_with
http://ruby-doc.org/gems/docs/h/heroku_mongo_watcher-0.3.0/HerokuMongoWatcher/Configuration.html
Since you didn't provide nearly enough information to narrow it down, it falls on you.

How to detect if an element exists in Watir

I'm relatively new to Watir but can find no good documentation (examples) regarding how to check if an element exists. There are the API specs, of course, but these make precious little sense to me if I don't find an example.
I've tried both combinations but nothing seems to work...
if browser.image (:src "/media/images/icons/reviewertools/editreview.jpg").exists
then...
if browser.image (:src "/media/images/icons/reviewertools/editreview.jpg").exists?
then...
If anyone has a concrete suggestion as per how to implement this, please help! Thanks!
It seems you are missing a comma between parameters.
Should be
if browser.image(:src, "/media/images/icons/reviewertools/editreview.jpg").exists?
Also you can find this page useful in future to know what attributes are supported.
The code you posted should work just fine.
Edit: Oops, wrong. As Katmoon pointed out, there is a missing comma.
browser.image(:src "/media/images/icons/reviewertools/editreview.jpg").exists?
One problem you may get caught up in is if the browser variable you specified is actually an element that doesn't exist.
e.g.
b = Watir::IE.start(ipAddress)
b.frame(:name, "doesntExist).image(:src "/media/images/icons/reviewertools/editreview.jpg").exists?
The above code will throw a Watir::UnknownFrameException. You can get around this by first verifying the frame exists or by surrounding the code in a begin/rescue block.
Seems like you are using it correctly. Here is an old RDoc of Watir.
Does it not work because Watir cannot find it? Hard to tell because there is no source or link to the page that is being tested. I think that I only use image.exists?. In general, errors that come from when the image exists but is not found are:
The how is not compatible with the element type. There is a cheatsheet to help you see which object types can be found with different attributes here.
The what is not correct. You may have to play with that a little bit. Consider trying a regex string to match it such as browser.image(:src, /editreview.jpg/). As a last resort, maybe use element_by_xpath, but there are maintenance costs with that.
The location is not correct. Maybe the element is in a frame or something like that. browser.frame("detail").image(:src, /editreview.jpg/).
Try those, but please let me know what worked. One more thing, what are you checking for? If it's part of the test criteria, you can handle it that way. If you need to click on it, then forget the .exists? and just click on it. Ruby will let you know if it's not there. If you need it to be grace, learn about begin/rescue.
Good luck,
Dave

Resources