Tidbits | A place to put random things
kandi X-RAY | Tidbits Summary
kandi X-RAY | Tidbits Summary
A place to put different things.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Tidbits
Tidbits Key Features
Tidbits Examples and Code Snippets
Community Discussions
Trending Discussions on Tidbits
QUESTION
I'm trying to get my script to choose between three options of conversation, labeled petconvo1, petconvo2, or petconvo3. The program asks what pet the user has and then picks a random thing to say about them. Based on what tidbit the script picks, I want to continue the conversation there. My problem is that it just stops and doesn't keep going with the conversation. What's the best way to do this?
My code is below.
...ANSWER
Answered 2021-Mar-02 at 15:16hmm first in the if statements you should use the elif statement. Afterwards you should use set the random selection to a var in order to check it. This code works for me.
QUESTION
Given I have two microservices: Service A and Service B.
Service A owns full customer data and Service B requires a small subset of this data (which it gets from Service A through some bulk load say).
Both services store customers in their own database.
If service B then needs to interact with service A say to get additional data (e.g. GET /customers/{id}) it clearly needs a unique identifier that is shared between the two services.
Because the ids are GUIDs I could simply use the PK from Service A when creating the record in Service B. So both PKs match.
However this sounds extremely fragile. One option is to store the 'external Id' (or 'source id') as a separate field in Service B, and use that to interact with Service A. And probably this is a string as one day it may not be a GUID.
Is there a 'best practice' around this?
update
So I've done some more research and found a few related discussions:
Should you expose a primary key in REST API URLs?
Is it a bad practice to expose the database ID to the client in your REST API?
conclusion
I think my idea of trying to keep both Primary Keys for Customer the same across Service A and B was just wrong. This is because:
- Clearly PKs are service implementation specific, so they may be totally incompatible e.g. UUID vs auto-incremented INT.
- Even if you can guarantee compatibility, although the two entities both happen to be called 'Customer' they are effectively two (potentially very different) concepts and both Service A and Service B both 'own' their own 'Customer' record. What you may want to do though is synchronise some Customer data across those services.
So I now think that either service can expose customer data via its own unique id (in my case the PK GUID) and if one service needs to obtain additional customer data from another service it must store the other service identifier/key and uses that. So essentially back to my 'external id' or 'source id' idea but perhaps more specific as 'service B id'.
...ANSWER
Answered 2020-Dec-12 at 21:57I think it depends a bit on the data source and your design. But, one thing I would avoid sharing is a Primary key which is a GUID or auto-increment integer to an external service. Those are internal details of your service and not what other services should take a dependency on.
I would rather have an external id which is more understood by other services and perhaps business as a whole. It could be a unique customer number, order number or a policy number as opposed to an id
. You can also consider them as a "business id". One thing to also keep in mind is that an external id can also be exposed to an end-user. Hence, it is a ubiquitous way of identifying that "entity" across the entire organization and services irrespective of whether you have an Event-Driven-Design or if your services talk through APIs. I would only expose the DB ids to the infrastructure or repository. Beyond that, it is only a business/ external id.
QUESTION
I'm trying to create a MQTT client that'll connect to the Google Cloud IoT Core, but for some reason, it won't connect at all. Here's what I have so far
...ANSWER
Answered 2020-Nov-25 at 07:03I realized that when I was creating the project and registry on the Google Console, I actually mistyped the name I was intending (I thought it was "testmqtt" but it was actually "tesmqtt").
So if you're having an issue similar to this, I'd suggest trying the follwing:
- Make sure your you've spelled everything right. Make sure the project title is correct, the registry title, etc. It sounds dumb but these types of mistakes happen, so it doesn't hurt to check them first. Otherwise you'll overthink things like I did.
- Check out this this page for troubleshooting. There's two parts of this troubleshooting page that might really help you. The first is trying to see if you can actually connect to the cloud at all. You can test if you're able to make a connection by issuing a command like
openssl s_client -connect mqtt.googleapis.com:8883
on the command line. You'll need to have openssl downloaded in order to issue that command, however. You can see the page I just linked for more details about testing your connection. The second thing you can do is check to see if you have authentication by running a gcloud command using Google's sdk. The troubleshooting page I linked also has more details in this regard. - This quickstart guide is also particularly helpful. It might be confusing to navigate at first but understanding it will be your best bet.
- Google's github repository also has some good examples of how to make an mqtt connection to the cloud IoT core.
DavidC in the comments below helped me find some of these helpful links, so credit should go to him.
QUESTION
I used ask init --hosted-skill-id=
to pull a local copy of my skill. Running git remote -v
shows the repository is hosted on AWS CodeCommit at https://git-codecommit.us-east-1.amazonaws.com/v1/repos/
.
I can't see the CodeCommit repository in my AWS account (when logged in as root user). I also can't see any IAM roles listed in my AWS account. I considered logging in as the ask_cli_default
profile generated by ask configure
but it only has an access key and secret; no password.
Which AWS account holds the Alexa-hosted CodeCommit repositories? Is there any way to grant access to another account?
Other potentially relevant tidbits
- Context: Yesterday I created a skill in the Alexa developer console based on a Hello World template. Now I want to share it with a friend so we can develop it together. Ideally we would both be able to push to a shared git repository, build, deploy, and test using the simulator in Alexa developer console.
ask --version
= 2.20.0- I can
git clone
to another local directory using the (generated) username and password fromask util git-credentials-helper
. - a question in the AWS forums Alexa Hosted sets up a CodeCommit repository -- unanswered
- official AWS docs for setting up cross-account access to CodeCommit -- Requires access to the CodeCommit repository from AWS console. This is where I want to get to.
ANSWER
Answered 2020-Nov-19 at 22:42Alexa Hosted is hosted in Alexa's AWS account, so it won't show up in your AWS account. Instead, it provides you with a unique (and highly constrained) AWS IAM role within the Alexa Hosted account that is tied to your skill and your Amazon developer account.
What you need to do if you want to bring in other developers is assign them Developer roles on your account so they can access the skill and its resources using their own account.
This is the documentation for adding people to your org's developer account: https://developer.amazon.com/docs/app-submission/manage-account-and-permissions.html#add_other_users
QUESTION
I'm trying to add a column to a production hours dataset that will tell if a provider who worked last week was also working three weeks earlier. The current dataset looks something like this:
...ANSWER
Answered 2020-Nov-12 at 22:35If you are running MySQL 8.0, you can use window functions and a range
specification:
QUESTION
I am currently trying to use Log4Net to insert logs into a MS SQL Server DB. I believe I have Log4Net at least working because I was able to use the FileAppender option/example given Here and I was able to generate a file with the stack traces. However, 8 hours of research and tutorials has me totally stomped on getting the MS SQL Server config examples given Here - same place to work.
I cannot get even their example to work. I created the table, I updated my log4net.config file from the FileAppender option to the provided MS SQL Server option and I fed it the correct connection string settings and... nothing.
I am going to post the code tidbits I believe will be helpful and a photo of proof that my DB table does exist.
CONFIG FILE
...ANSWER
Answered 2020-Jul-08 at 14:46I spend quite a lot of time trying different approaches and here is how I made it work with the least changes required.
First, install NuGet package MicroKnights.Log4NetAdoNetAppender
Then update your log4net.config
file to look like this:
QUESTION
I am building a typing.NamedTuple class (see typing.NamedTuple docs here, or the older collections.namedtuples docs it inherits from) that can accept different ways of being initialized.
Why NamedTuple in this case? I want it to be immutable and auto-hashable so it can be a dictionary key, and I don't have to write the hash function.
I understand that I need to use __new__
rather than __init__
due to NamedTuples being immutable (for example, see this Q&A. I've searched and there are some tidbits out there (e.g. answers to this question on setting up a custom hash for a namedtuple), but I can't get everything working, I'm getting an error about not being able to overwrite __new__
.
Here's my current code:
...ANSWER
Answered 2020-May-25 at 21:27You can avoid needing to define __new__()
by defining a classmethod
. In the sample code below, I've simply named it make()
.
This is a common way to provide alternative constructors for any class.
Note that I also changed the first call to the function so it passes the arguments properly to the make()
method.
QUESTION
Edited with additional details added
I have a shapefile of 2,061 Open Street Map (OSM) road segments. Each segment in my shapefile is is identified by its OSM Way ID.
Here is an example of five segments from my data:
...ANSWER
Answered 2020-Mar-03 at 10:08Traffic signals should always be tagged "highway" = "traffic_signals"
, but individual nodes may also be tagged with a key of "traffic_signals"
. Thus the first step to get all traffic signals can be done like this:
QUESTION
I have a dataset that looks like this (the Groceries dataset from the arules CRAN package)
libraries:
...ANSWER
Answered 2020-Feb-26 at 14:21This seems to work:
QUESTION
I have a bar chart that I'd like to:
1) On click, the selected bar changes color [The code I have works]
2) The circle div changes color based on the bar's height [I can't seem to add that to the code above]
I know
...ANSWER
Answered 2020-Jan-26 at 06:30I think this is what you want to achieve, I will leave it to you to manage the color scheme, the thing that you have to manage is the color from [0, 255].
Just add it inside the click event you attached to the bars.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Tidbits
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page