I want to enter a list of cities as parameters to a SAM template. For Example: London, New York, Dubai. The list can have a large number of cities, say 50.
Using this list of cities, I want to create a log group pertaining to each city. For example:
/aws/ecs/Dubai
/aws/ecs/London
/aws/ecs/New York
How can I achieve this?
You can use Count Macro in Cloudformation.
AWSTemplateFormatVersion: "2010-09-09"
Transform: Count
Resources:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: /aws/ecs/%s
Count: ['Dubai','London','NewYork']
For more information check this question: How to loop through values in a CloudFormation template
Related
I am working on an app with a MongoDB database to send messages between two people and I want each user to create tags for each message. I want users to be able to add new tags or select tags from the list of the ones they've created. Most importantly, once you receive a message with a tag, I want that to be added to your list of tags. Does the following (truncated) data model make sense?
User:
ID: ID
Name: STRING
Tags: Array of TAG-IDs
Message:
ID: ID
Sender: USER-ID
Receiver: USER-ID
Tags: Array of TAG-IDs
Tag:
ID: ID
Label: STRING
I would suggest you put also the Label of Tags into the Tags Array. It can help you avoid an extra lookup when you are required to display the Label.
Beware the trade-off that you need to update all array entries' Label field when there is an update. This could matter depending on your actual scenario.
Here is a good article about MongoDB schema design for your reference. It has a similar example to your case.
I'm looking at an SNL dataset and I want to use seaborn to take a look at a couple different things.
I'm using this to learn more about visualizations in jupyter (aka I'm a beginner).
The data set looks like this:
aid: actor
capacity: what their role was
charid: unique character id
impid: unique impersonation id
role: name of role they played
tid: sketch id
voice: were they just a voiceover?
epid: episode id
sid: season id
Some questions:
Who are the top 20 actors who appeared on SNL?
The characters used most frequently?
The impressions most frequently?
Which characters were played by multiple actors?
I tried this but it's so many people, I want to limit it to maybe 20 people. Or if you have suggestions of other visualizations to try I'm all ears.
plt.style.use('seaborn-whitegrid')
plt.figure(figsize=(5,5))
sns.countplot(y="aid", data=appearances);
Some example plots of how to answer some of these questions would be amazing!!
Your question is quite broad but in general, for each series, you can do this:
Get the count for each unique element of a specific column and only take the 20 elements with the highest count:
top20aid=appearances.groupby(['aid'],sort=False)['aid'].count().sort_values().tail(20)
bot20aid=appearances.groupby(['aid'],sort=False)['aid'].count().sort_values().head(20)
NB: sort_values, by default, sort in ascending order. Hence to find the values with the highest count we use tail(). You can sort in descending order by using the following .sort_values(ascending=False). In this case you would select the elements with the highest count using .head(). e.g.
top20aid=appearances.groupby(['aid'],sort=False)['aid'].count().sort_values(ascending=False).head(20)
bot20aid=appearances.groupby(['aid'],sort=False)['aid'].count().sort_values(ascending=False).tail(20)
Then simply plot the results in a barplot
sns.barplot(top20aid.values,top20aid.index)
Please pardon my ignorance, I'm new to spatial data. I've been tasked with creating a map report in SSRS. When finished, the report will show locations of stores participating in the same promotion.
Currently, my database doesn't contain this information, so I have to create a table first. Luckily, I have a spreadsheet that does contain this information, so I can just import it. However, I'm not convinced that my spreadsheet has all the information I need. It shows basic information such as store name and address, but no geographical information (which I'm assuming I need).
So my question: What kind of data does a SQL table need in order to build a map report in SSRS?
You can create a custom table with the specific information that you want, but there are an inportant information that you mustn't forget, for example:
From the spatial data source:
SpatialData - A field that has spatial data that specifies the latitude and longitude of the city.
Name - A field that has the name of the city.
Area - A field that has the name of the region.
From the analytical data source:
Population - A field that has the city population.
City - A field that has the name of the city.
Area - A field that has the name of the territory, state, or region.
I have researched on this question but found nothing close. Thats why I decide to ask. Stackoverflow has been a tremendous help for me.
I have a jobs table with one attribute is location. Each job.location is either in New York, Boston, or both (New York & Boston).
In sunspot solr for rails, how do I create facet for this attribute so that if a job.location is in both cities, the job can be displayed in the results when either New York or Boston is selected in the facet?
Should it be like an array ['New York', 'Boston']?
Thanks!
You should change your design so that you have a separate Location class and set the Job class to have has_and_belongs_to_many :locations because it is a many-to-many relationship.
Then you can create an integer scope in your Job class searchable block for the location:
integer :locations, :multiple => true
to allow multiple locations per job.
Now it is easy to add a facet(:locations) that will do exactly what you want.
The above works for any number of locations, not only two. However, if you don't want to create a new class/table and are sure you only have 1 or 2 locations, you can just create a query scope field:
integer :locations, :multiple => true do
if location == 'NY & Boston'
['NY', 'Boston']
else
[location]
end
end
I need to allow for user designed form creation, via a web interface, in my software. ie, they create a question, a type (text, radio, checkboxes etc), options if needed(radio/check), then add, and continue in this process until they have created all fields in the form.
There will be no queries done against them except to view/fill/print them, ie they are adding 'questionnaires' that may be filled out unlimited number of times (some may be 20 times, some millions of times).
After some research it seemed like an EAV type solution sounded good, except there's a lot of negative views on that out there. Many people suggest using a NoSQL database for this type of situation but I don't really see the advantages - you are still having a form with many fields and then results with many fields.
There would be a single possible value for some fields (text/text_area/date), but many would also have multiple options (radio buttons, select drop downs, check boxes).
Here's a sample design in traditional SQL:
form: creator_id, name
form_field: form_id, order, question, type (text, text_area, date, radio, select, check)
form_field_option: form_field_id, name, value, order (this is used for radio/select/check)
form_result: form_id, application_id (not name I use but all results will belong to an 'application')
form_field_value: form_result_id, form_field_id, form_field_option_id, value (if a field of options the value would be blank, field of text form_field_option_id would be blank)
It would seem fairly easy to construct forms based on this and get the results. It may or may not exactly be efficient but say a typical form is 5-30 questions, would it be that bad?
Are there any advantages in putting this in a NoSQL database, ie Mongo or something similar? If so can you give me concrete examples for what they are and give me a sample design? I've seen a lot of answers like 'NoSQL is better suited to this' but I have no experience in this area, is it because of faster retrieval of results, or what? And what downsides would using NoSQL introduce?
Thanks
MongoDB would probably be a better fit for this app than a relational database. Your fundamental entities, the form design and the form results, are effectively documents whose contents are intrinsically bound together, i.e. a form field makes little sense outside the context of its parent form.
MongoDB would allow you to store these documents as a single structure each rather than scattered across various tables as in your relational data model.
This is YAML just because it's cleaner to write than JSON. The underlying structure would be the same.
_id: 12345
creator: Adrian
name: NoSQL form demonstrator
fields:
- id: first_name
label: First name
type: text
required: true
- id: last_name
label: Last name
type: text
required: true
- id: dob
label: Date of birth
type: date
- id: bio
label: Biography
type: textarea
- id: drink
label: What would you like to drink?
type: select
options:
- id: tea
label: Tea
- id: coffee
label: Coffee
- id: beer
label: Beer
- id: water
label: Mineral water
- id: mailing_list
label: Join our mailing list?
type: check
default: false
Note:
You only need to store the keys where they're needed rather than having a column for every thing in every context as you would in a relational database. e.g. there's no need for required: false -- if that's the default then just leave it out.
MongoDB documents have intrinsic order so there's no need to create a field to hold the fields' orders within the form design.
The form results would be stored in the same way. Just store them naturally as you'd expect:
_id: 545245
form_id: 12345
name: NoSQL form demonstrator
results:
- id: first_name
label: First name
type: text
value: Adrian
- id: last_name
label: Last name
type: text
value: Short
- id: dob
label: Date of birth
type: date
value: 1970-01-01
- id: bio
label: Biography
type: textarea
value: Doing things on the internet
- id: drink
label: What would you like to drink?
type: select
value: Tea
- id: mailing_list
label: Join our mailing list?
type: check
value: false