Thursday, 23 September 2021

Mailgun: sending variables to template example - Fix ''Create and start coding'' greyed out issue.

First of all in Mailgun we'll add a template.   ( Keep reading for the ''Create and start coding'' greyed out issue fix tip ) 

So log into your account and on the dashboard you'll see all of your domains.  Click on the name of the domain that you want to add a template for.   Although there is a domain dropdown on the Template page itself, so no big deal if you want to change that later on. 

Next up, you'll need to click on 'Sending' in the left hand menu to see more options.  The 5th option down in this dropdown should be 'Templates' .



Click on this.  And then in the next page you'll get to 'Create Message template' 

You'll need to make sure the characters in the 'name' are valid and you have some sort of description.  Otherwise the 'Create and start coding' button is greyed out and you can't click on it. 


I’m sure this will trip someone else up , but the name input cannot be capitalised. If it is the Mailgun 'Create Message template' will remain greyed out.

In the HTML of template you’re setting up , you can add variable using the following.


1{{ firstname }} {{ lastname }}


How to send from Flask .

So here the function for sending a standard MIME email. With some HTML

1 def send_html_message(self): 2 return requests.post( 3 self.send_message_api, 4 auth=("api", self.mailgun_api_key), 5 data={ 6 "from": self.from_string, 7 "to": [self.to_address_2], 8 "cc": [self.to_address_1], 9 "subject": "HTML test", 10 "html": "<strong>Hello World</strong><br><p>Hi</p><p>This is an HTML test send </p>", 11 }, 12 )

 

And this is one where we use our ‘newsletter’ template and send through some variables.


1 def send_simple_message_template(self): 2 return requests.post( 3 self.send_message_api, 4 auth=("api", self.mailgun_api_key), 5 data={"from": self.from_string, 6 "to": "David Millward <dj@flowmo.co>", 7 "subject": self.subject, 8 "template": "newsletter", 9 "v:firstname":"David", 10 "v:lastname":"John", 11 })


This one will send our newsletter, with the clients name on it.






Tuesday, 21 September 2021

Docker - failed to solve with frontend dockerfile.v0: failed to create LLB definition: no match for platform in manifest sha256:X: not found 7ERROR: Service 'myservice' failed to build : Build failed


docker-compose up -d
2... 3------ 4 > [internal] load metadata for docker.io/library/python:3-onbuild: 5------ 6failed to solve with frontend dockerfile.v0: failed to create LLB definition: no match for platform in manifest sha256:X: not found 7ERROR: Service 'myservice' failed to build : Build failed


I found in this post that if I ran the following lines of code in terminal before my compose command, then that would eliminate the first issue I have.


1export DOCKER_BUILDKIT=0 2export COMPOSE_DOCKER_CLI_BUILD=0 3docker-compose up -d 4 5ERROR: Service 'myservice' failed to build : no matching manifest for linux/arm64/v8 in the manifest list entries


So that second line of issue looks like it may have to do with my Mac M1 chip


1ERROR: Service 'myservice' failed to build : no matching manifest for linux/arm64/v8 in the manifest list entries



Adding the 'platform: linux/x86_64' to the following services seems to have worked.


1version: '3' 2 3services: 4 myservice: 5 platform: linux/x86_64 6 container_name: myservice_container 7 build: ./myservice 8 volumes: 9 - ./myservice:/usr/src/app 10 ports: 11 - 8080:8080


Wednesday, 15 September 2021

Python Panda's - Cannot convert non-finite values (NA or inf) to integer

 In the .csv that we're processing we have a column thats 'total_in_thousands' .  

In that column the values are all in decimals and I presume the legacy code would like them to be integers. 

csv = csv.astype({'total_uv_in_thousands' : 'int64'})

However this giving me this error. 


1 astype_nansafe 2 raise ValueError("Cannot convert non-finite values (NA or inf) to integer") 3ValueError: Cannot convert non-finite values (NA or inf) to integer


To resolve this I’ve changed on NaN’s in this column to zero and it now works.
csv = csv.fillna({'total_uv_in_thousands' : 0}).astype({'total_uv_in_thousands' : 'int64'})


This works. 


Monday, 13 September 2021

MacOS Big Sur 11 . How do I see the 'Download' folder in 'Finder'

This isn't an issue specifically for Mac OS Big Sur but something I end up searching for every now and again.  I think it probably affects those of us who use Windows and Macs , as searching in Finder in default can be pretty frustrating some times.

Anyway the 'Downloads' folder was happily in the left menu of Finder and then it suddenly disappeared. 
Equally this issue and fix could apply to any of the following Folders. 

1. Recents
2. Airdrop
3. Applications
4. Desktop
5. Documents
6. Downloads
7. Movies
8. Music
9. Pictures
10. Home

To fix this in 'Finder' - click on 'Finder' on the top menu > And select 'Preferences' 


From here you can select to re-add the Downloads folder. 




Google Big Query: Why isn’t my Scheduled query saving.

 I just thought I’d note this down for others, as the logically way to fix this ( at least to me ) didn’t work.


This is in Scheduled tasks .  After clicking on the task that you want to change and then clicking on edit.  It’s easy enough to make your changes to the query and re-running it to check that it’s fine.  However when clicking on the Save button and choosing either of the Save methods, when you go back in again the Query is the same as it was before.  This is the Save button I was clicking on. 


What I needed to do though was to click on 'Schedule' and then 'Update scheduled query' 


Now when you 'Update' at the bottom of the options that displays, you'll then go back into your Scheduled query and it'll be updated :)


Monday, 16 August 2021

Vue.js Nightwatch Error connecting to localhost on port 4444

 I was receiving the above error when attempting to run my my first tests. 

Also note this in the error message. 

""Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line""

The reason for this was that I needed to install Firefox ( I'd recently renewed my laptop and it hadn't added this browser yet ! )