listing other than windows images from amazon using fog - ruby-on-rails

I have been using fog for one of my project,i have used describe_images with filter parameters, but now i am getting only the windows images, so is there any way to get the other AMIs with changing the parameter(platform)?. lets an example 'platform => linux' something like that
spec_images = #conn.describe_images('Owner' => 'amazon','platform' => 'windows')
my_images = spec_images.body["imagesSet"]
# List image ID, architecture and location
for key in 0...my_images.length
print my_images[key]["imageId"], "\t" , my_images[key]["architecture"] , "\t\t" ,
my_images[key]["imageLocation"], "\n";
end

According to the API documentation for the DescribeInstances call...
Use windows if you have Windows based instances; otherwise, leave
blank.
So "windows" is the only valid value for that filter, presently, and according to the AWS developer forums, there isn't currently a way to filter for non-Windows instances:
It appears there is no way currently to filter for linux instances
using ec2-describe-instances. This is expected behavior and no easy
workaround at this time. We will be updating our documentation to
reflect this. I apologize for the inconvenience.

Related

Cytoscape - Set nodeCustomGraphicsSizeSync and nodeSizeLocked from CyREST

Is there a way to programatically set nodeCustomGraphicsSizeSync and nodeSizeLocked in Cytoscape with the CyRest api ?
They are usually set in the UI by the two checkboxes "Fit Custom Graphics to node" and "Lock node width and height" (see image).
I tried this, which does not work:
from py2cytoscape.data.cyrest_client import CyRestClient
cy = CyRestClient()
my_style = cy.style.create('custom_theme', original_style=cy.style.get('default'))
net = cy.network.create(name='My Network', collection='My network collection')
my_style.update_defaults({
'NODE_SIZE':200, #works
'NODE_CUSTOMGRAPHICS_SIZE_1':80, #works,
'NODE_CUSTOMGRAPHICS_POSITION_1':'N,S,c,0.00,0.00', #works
'nodeCustomGraphicsSizeSync' : 'false', # does not work
'nodeSizeLocked' : 'false' # does not work
})
cy.style.apply(my_style, net)
I think it is because these are not VisualProperties but Visual Property Dependencies
I found this mention of a related issue, but no other references (the redmine seems down):
3245 Creating a copy of a VisualStyle--VisualPropertyDependencies not copied
from https://cytoscape.org/cy3_welcome_letter_v14.pdf
I'm using Cytoscape 3.7.2 and py2cytoscape.
There is a way in CyREST, but I'm not sure it's been made available through py2cytoscape. Basically, you need to update the dependencies, which is a different REST endpoint (/{name}/dependencies) and you want to use "enabled" rather than "true". You may want to see if there is an update_dependencies in py2cytoscape (I don't see one after a quick look at the docs). If not, add an issue in github: https://github.com/cytoscape/py2cytoscape
-- scooter

Rails Console output breaks when modifying

Totally lacking intuition here.
First i thought i only happens when copying and pasting code from editor. Unfortunately it's more common. Only thing I am doing is trying to insert more code somewhere in the middle of current input or modifying it.
Expected behavior:
Modify input without side effects.
What actually happens:
VERY OFTEN when modifying input it gets messed up.
If that happens every key press will copy and insert current input alongside with pressed character.
Vital notes:
Encoding is set to UTF-8 in terminal(s)
Issue persists on different emulators ( Terminator, gnome-terminal )
Issue persists when using different Ruby runtime console ( IRB, Pry )
Issue appears to be related to Ruby runtime, NOT Linux shell (i guess...)
Issue appears since:
Since system install. Didn't appear on my MacBook Air
System:
ArchLinux, although coworker reported same thing happens on his MacBook Pro.
How to reproduce (works for me):
Open rails console
Type example code: Shift.where(name: "som").where(name: "dom").where(name: "pom")
Navigate cursor to modify first where statement.
Change "som" to "SOM"
Should see it break
Press random key repeatedly to see it break even more.
Images:
Good input
Now i will navigate to first where statement to change "som" to uppercase "SOM"
I basically navigated my cursor and pressed SHIFT+S, SHIFT+O, SHIFT+M
Hope it's clear enough :-)
Thank you!
EDIT 1:
Tried using zsh instead of bash, didn't help
Disabled spring gem, didn't help
EDIT 2:
Folks on reddit suggested that i should check if there are any Ruby readline warnings eg. "Readline is not installed". None of them appear anywhere. Also reinstalled ruby 2.4.1, seems like it's not the problem in my case.
EDIT 3:
I cannot reproduce the issue in a different Rails project.
Issue appears on Rails 5.1.1, meanwhile 5.0.3 works flawlessly.
Is it possible that Rails itself (or rather one of its gems) can be the cause?
I had a very similar issue, and I boiled it down to my coloring.
I had the following in my IRBRC:
class String
def _colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def red
_colorize(31)
end
def yellow
_colorize(33)
end
end
IRB.conf[:PROMPT][:MY_PROMPT] = {
:AUTO_INDENT => true, # enables auto-indent mode
:PROMPT_I => "[ME]".red + " > ".yellow, # normal prompt
:PROMPT_S => "[ME]".red + " ".yellow, # prompt for continuated strings
:PROMPT_C => "[ME]".red + " * ".yellow, # prompt for continuated statement
:RETURN => "[ME]".red + "=> ".yellow + "%s\n".red # format to return value
}
IRB.conf[:PROMPT_MODE] = :MY_PROMPT
And when I removed the .red and .yellow, everything was just fine.
I think it's because my coloring characters like \e[31m was getting counted as a length 5 characters instead of 0 characters.
My solution was to remove my coloring for the time being. Hopefully someone will come up with a better solution than that.

Base CRM Rails Gem legacy search?

It looks like Base CRM has upgraded their API and replaced all of their endpoints/parameters.
Previously I was able to retrieve "Won" deals using this call:
session = BaseCrm::Session.new("<LEGACY_ACCESS_TOKEN>")
session.deals.all(stage: :won, sort_by: :last_activity, sort_order: :desc, page: 1)
This query recently started ignoring my parameters, yet it continued to respond with unfiltered data (that was fun when I realized that was happening).
The new syntax is:
client = BaseCRM::Client.new(access_token: "<YOUR_PERSONAL_ACCESS_TOKEN>")
client.deals.where(organization_id: google.id, hot: true)
yet this does not work:
client.deals.where(stage_name: :won)
client.deals.where(stage_name: "Won")
client.deals.where(stage_id: 8) # specified ID found in Base Docs for "Won"
etc.
I've looked into the most recent updates to the Base CRM Gem as well as the Base CRM API Docs but have not found a solution to searching by specific deal stage.
Has anyone had any luck with the new API and this kind of query?
Is there a way to use the legacy API?
I've left message with Base but I really need to fix this, you know, yesterday.
Thanks for your help!
ADDITIONAL INFO
The legacy API/gem responded with JSON where the v2 API/gem responds with a BaseCRM::Deal object:
$ session.deals.find(123456)
# <BaseCRM::Deal
dropbox_email="dropbox#67890.deals.futuresimple.com",
name="Cool Deal Name",
owner_id=54321,
creator_id=65432,
value=2500,
estimated_close_date=nil,
last_activity_at="2016-04-21T02:29:43Z",
tags=[],
stage_id=84588,
contact_id=098765432,
custom_fields={:"Event Location"=>"New York, NY", :Source=>"Friend"},
last_stage_change_at="2016-04-21T02:08:20Z",
last_stage_change_by_id=559951,
created_at="2016-04-18T22:16:35Z",
id=123456,
updated_at="2016-04-21T02:08:20Z",
organization_id=nil,
hot=false,
currency="USD",
source_id=1466480,
loss_reason_id=nil
>
Checkout stage_id. Is this a bug? According to the Docs stage_id should return an integer between 1 and 10.

Check device type via user_agent (rails)

I want to know whether my users are browsing a page in my rails application with
a tablet or
a mobile device or
a desktop computer
I digged through many different solutions. Here are my favorites:
The ua-parser gem: https://github.com/ua-parser/uap-ruby which seems to be very clean but unfortunately it always plots Other when I use parsed_string.device - I can detect the OS and browser with it very well.
Writing it from scratch
Writing from scratch ended up in sth like this:
if request.user_agent.downcase.match(/mobile|android|iphone|blackberry|iemobile|kindle/)
#os = "mobile"
elsif request.user_agent.downcase.match(/ipad/)
#os = "tablet"
elsif request.user_agent.downcase.match(/mac OS|windows/)
#os = "desktop"
end
However, what I miss is a complete documentation of the user agent 'device' definitions.
For example:
What patterns do I need to look at if my user is browsing on a tablet/mobile device or desktop? I can't just guess and checking e.g. the ua-parser regex is not helping me either (very complicated): https://github.com/tobie/ua-parser/blob/master/regexes.yaml
Is there any simple solution to solve my problem?
How does google analytics do it? I tried to research but could not find it. They're also displaying devices (desktop/tablet/mobile).
The browser gem has a suggestion to do this, but until that is added you could still use the gem to figure it out by using browser.device?
I'm looking to do the 2nd option, because I need it as lean-n-mean as possible. There'se a lot of information in the User-Agent string, that I just don't need. And I don't want a function that tries to parse it all. Just simply: bot, desktop, tablet, mobile and other.
It's kind of a lot to read, but I'm looking for keywords using this extensive list.
So far, the following keywords seems to work for me. It's regular expressons in php, but you'll get the idea.
//try to find crawlers
// https://developers.whatismybrowser.com/useragents/explore/software_type_specific/crawler/
if (preg_match('/(bot\/|spider|crawler|slurp|pinterest|favicon)/i', $userAgent) === 1)
return ['type' => 'crawler'];
//try to find tablets
// https://developers.whatismybrowser.com/useragents/explore/hardware_type_specific/tablet/
// https://developers.whatismybrowser.com/useragents/explore/hardware_type_specific/ebook-reader/
if (preg_match('/(ipad| sm-t| gt-p| gt-n|wt19m-fi|nexus 7| silk\/|kindle| nook )/i', $userAgent) === 1)
return ['type' => 'tablet'];
//try to find mobiles
// https://developers.whatismybrowser.com/useragents/explore/hardware_type_specific/mobile/
// https://developers.whatismybrowser.com/useragents/explore/hardware_type_specific/phone/
if (preg_match('/(android|iphone|mobile|opera mini|windows phone|blackberry|netfront)/i', $userAgent) === 1)
return ['type' => 'mobile'];
//try to find desktops
// https://developers.whatismybrowser.com/useragents/explore/hardware_type_specific/computer/
if (preg_match('/(windows nt|macintosh|x11; linux|linux x86)/i', $userAgent) === 1)
return ['type' => 'desktop'];
return ['type' => 'other'];

get DynamicSearchAd along with TextAd via Google Adwords API

Google provides nice examples of getting TextAd via API: https://code.google.com/p/google-api-adwords-php/source/browse/examples/v201209/BasicOperations/GetTextAds.php
I expected that getting DynamicSearchAd will be as easy as modifying line 54 to:
$selector->predicates[] = new Predicate('AdType', 'IN', array('TEXT_AD', 'DYNAMIC_SAERCH_AD'));
however for campaign with bunch of negative keywords, 0 postiive keywords and bunch of ads [ visible in the interface ] my result is buch of negative keywords and 0 ads, like they were not existing. I have googled for quite a long time already, but most recent post about keywordless ads is from 2012 and since then I believe that DynamicSearchAds went out from beta and are not available for everyone.
I played quite a little bit with sample example, changing fields [ like removing Headline and leaving only Id etc ], without success.
So my question is, how should I modify this example to obtain DSA ?
You've got missprint on constant in Predicate.
'DYNAMIC_SAERCH_AD' must be 'DYNAMIC_SEARCH_AD'

Resources