Wednesday 24 February 2021

VS Code - 'Goto definition' issues.

I had some issues with my ‘goto definitions’ in Visual Studio Code.

Here are the fixes I had to make for each language.

PYTHON

In the settings.json file I had to add

1// Defines type of the language server. 2 "python.jediEnabled": false, 3 "python.languageServer": "Microsoft",


PHP

I installed the extension ''PHP Intelephense' 

https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client

Do this from the extensions section in VS Code



JAVASCRIPT

I had the 'ESLint' extension that was affecting the core 'JS intellisense' extension.
Also on my searches, I've found 'npm intellisense' module.  Which gives you the 'goto definitions' for anything NPM installed - which is pretty awesome :)

 

Google searches I made to sort this were ->

visual studio code php go to definition not working extension

VS code php go to definition not working extension

visual studio code python go to definition not working extension

VS code python go to definition not working extension

visual studio code javascript go to definition not working extension

VS code javascript go to definition not working extension

Tuesday 23 February 2021

Vue.js and Firebase / Firestore - Adding a image from a Form

I am going to show my code for a single image, I'll be expanding this to multiple images shortly.   One thing that was a sticking point for me was how to retrieve the File from the forms 'Event' .  

The recommended path on event.target.file was not working. In the end the solution was to log.console the event item, and painfully search through it.
I found it at
var selected_file = event.target.form[7].files[0];

Here’s the code that will work in principle.


HTML


1 <form id="add-survey-form"> 2 <div id="input-group-7" role="group" class="form-group"> 3 <label id="input-group-7__BV_label_" for="input-7" class="d-block">Images:</label><div> 4 <input id="survey_images" type="file" placeholder="Images" class="form-control" aria-describedby="input-group-7__BV_description_"><!----><!----> 5 <small tabindex="-7" id="input-group-7__BV_description_" class="form-text text-muted">Survey images.</small></div></div> 6 7 <button v-on:click="addSurvey">Add Survey</button> 8 </form>


VUE.JS


1 methods: { 2 async addSurvey(event) { 3 const auth = await firebase.auth(); 4 const db = await firebase.firestore(); 5 event.preventDefault(); 6... 78 var selected_file = event.target.form[7].files[0]; 9 firebase.storage().ref('survey/UID-FOLDER/image.jpg').put(selected_file).then(function (){ 10 console.log('succesfully uploaded') 11 }).catch(error => { 12 console.log(error.message); 13 })

 

 

Thursday 4 February 2021

Letter to my MP - Scott Mann - February 2021 and the reply.

Dear Scott Mann



After watching the 5th part of David Attenboroughs ‘Perfect Planet’ with my family yesterday evening ( which if you haven’t seen it I urge you to ) I have made a pledge to myself to write to you more often.   As you know I have written to you a few times now over the past few years mainly on environmental issue.  Of which you often reply stating how much you care about the environment and what you intend to do.  However your voting record in parliament says a remains poor on environmental issues and does not reflect the dire situation we are in. 


Let me remind you of how you’ve previously voted on Bills where your vote conflicts your supposed commitment to the environment. 

On the 29th September 2020 you voted not to require a "climate and nature emergency impact statement" as part of any proposal for financial assistance under a United Kingdom Internal Market Act. 

February last year voted not to call on the Government to develop and implement a plan to eliminate the substantial majority of transport emissions by 2030.

On the 24th October 2019 you voted against a motion calling on the Government "to rebuild the economy so that it works in the interest of the many, not just handing out rewards to those at the top" and bring forward "a green industrial revolution to decarbonise the economy and boost economic growth".

On the 3rd May 2016 you voted not to reduce the permitted carbon dioxide emission rate of new homes.

On the 14th March 2016 you voted against requiring a strategy for carbon capture and storage for the energy industry.

I won’t list all the votes that you have sided against the environment but let’s not forget your continued support for the HS2 rail link.  The fact that we are destroying ancient woodlands so that people can save 30mins on a journey is frankly disgusting.   It is not good enough to state how many trees you intend to plant but we also need to protect what we have.   Added to this the trend of office workers being able to do a majority of their work remotely has already made this project defunct. 


Looking ahead at what you may be able to vote on in the future I would like to state my horror and the proposed plans for a new coal mine in Cumbria.  It’s hard to believe that in 2021 that this is even being mentioned.  We have left saving ourselves and this planet desperately late and if we are serious about tackling the climate crisis, then another coal mine is an insane idea. 


Another issue that is on my mind is that another Cornish MP George Eustice has given the go ahead for products containing 'neonicotinoid thiamethoxam' to treat crops.  A chemical that is banned by the EU , and which this country also helped to get banned.   A 2019 report by the UN Food and Agriculture Organisation and the World Health Organisation said there was a “rapidly growing body of evidence” that “strongly suggests that the existing levels of environmental contamination” by neonicotinoids were causing “large-scale adverse effects on bees and other beneficial insects”.    

Add that to the fact that a  recent scientific review of insect numbers around the world suggested that 40% of species were undergoing "dramatic rates of decline", with bees, ants and beetles disappearing eight times faster than mammals, birds or reptiles.  Allowing these chemicals is gambling with our future and should not be allowed.


As a Brexiteer I’m sure that you didn’t fight so hard so that you can get rid of regulations that environmentalists fought hard to get put in place.



Thank you for your time in reading this  I would prefer if you would not send a letter in reply but also reply by email as it’s better for the environment if everyone were to do this .  


Thank you. 


DJ Millward



And the Reply 

Dear David-john

Thank you for contacting me about a variety of concerns around the Environment Bill, I have had several communications on this Bill so I will take this opportunity to cover as many elements of the Bill as possible.

I remain fully committed to the Environment Bill as a key part of delivering the manifesto commitment to create the most ambitious environmental programme of any country on Earth. I would like to assure you that carrying over the Bill to the next session does not diminish the ambition for our environment in any way, with Report Stage recommencing early in the Second Session and Royal Assent expected in the Autumn. Key work on implementing the Bill’s measures will continue at pace, including establishing the Office for Environmental Protection, setting long-term legally binding targets for environmental protection and creating a new Deposit Return Scheme for drinks containers.

The Environment Bill will place environmental ambition and accountability at the heart of Government. I am pleased that legislative measures will be introduced to address the biggest environmental priorities of our age, ensuring we can deliver on the commitment to leave the natural world in a better condition than we found it. These will include meeting net-zero by 2050, as well as wider long-term legally binding targets on biodiversity, air quality, water, and resource and waste efficiency which will be established under the Bill.

The Office for Environmental Protection (OEP) is now expected to commence shortly after Royal Assent. The Office for Environmental Protection will have the power to take public bodies to an upper tribunal if there are breaches of the law. I believe it is important that the OEP is independent and fully transparent in order to effectively hold the Government to account on its targets. I am therefore pleased by assurances from Ministers that the OEP will be operationally independent from Government, including from the Department for Environment, Food and Rural Affairs. This means that Ministers will not be able to set its programme of activity or influence its decision-making.

The Environment Bill requires that Statutory Instruments setting out environmental targets must be laid before parliament by 31 October 2022. Ministers will continue to develop targets through a robust, evidence-led process to meet this deadline. Long-term targets will be developed through a robust evidence-led process, and Ministers shall not prejudge where this will take them. Ministers have also committed that their proposed objectives for biodiversity targets include restoring species populations and priority habitats, which will improve the state of nature. By setting targets of at least 15 years, Ministers will ensure that Governments look beyond the short term, but this does not mean we should not make progress until 2030. I am confident that the process put in place to develop targets will contribute to meeting new global goals set under the convention on biological diversity.

The UK is committed to playing a leading role in developing an ambitious and transformative post-2020 framework for global biodiversity under the convention on biological diversity. Following agreement of this framework, Ministers will publish a new strategy for nature in England that will outline how they will implement the convention on biological diversity’s new global targets domestically and meet the 25-year environmental goals for nature at the same time.

I recognise the importance of setting legally binding targets to support these ambitions, so I am pleased that the Environment Bill includes a requirement to set at least one long-term, legally binding target in relation to biodiversity, as well as targets for air quality, water and resource efficiency, and waste reduction. I know that the Government will determine the specific areas in which targets will be set using the robust and transparent target-setting, monitoring, and reporting process that the Bill legislates for, and will seek advice from independent experts. I am pleased that both Parliament and the public will have the opportunity to provide input to the development of these targets.

I am pleased that last year the Government set out its approach to tackling deforestation linked to UK demand for products such as cocoa, rubber, soya, and palm oil. Combined, the new package of measures will ensure that greater resilience, traceability, and sustainability are built into the UK’s supply chains by working in partnership with other countries and supporting farmers to transition to more sustainable food and land use systems. The measures include the introduction of a new law in the Environment Bill which will require greater due diligence from businesses, and make it illegal for UK businesses to use key commodities if they have not been produced in line with local laws protecting forests and other natural ecosystems. The final, operational details of the proposal will be implemented through secondary legislation, which will be subject to further consultation. This will consider which commodities will be prescribed, the thresholds that determine which businesses will be subject to the requirements, the precise information businesses will be required to report on and the level of fines.

I am pleased that connecting more people from all backgrounds with the natural environment for their health and wellbeing is a key part of the 25-Year Environment Plan, which is the Government's first environmental improvement plan. Under the Bill, long-term targets can be set out for any aspects of the natural environment or people’s enjoyment of it. The Bill requires the Government to set out at least one target in four priority areas, air quality, biodiversity, water waste and resource efficiency, as well as the fine particulate matter target. I understand that there is also scope to set further future targets.

The Resources and Waste Strategy sets out Government plans to eliminate all avoidable plastic waste throughout the lifetime of the 25 Year Environment Plan, however for the most problematic plastics the Government will go faster, working towards all plastic packaging placed on the market being recyclable, reusable, or compostable by 2025. In 2019, consultations ran on a number of key policy measures set out in the strategy: reforming existing packaging waste regulations; exploring the introduction of a deposit return scheme for drinks containers; increasing consistency in the recycling system; I am pleased that the Environment Bill includes powers to enable Government to deliver these measures.

The Environment Bill gives the Secretary of State the power to amend two pieces of legislation regulating the use of chemicals in the UK. This will allow the Secretary of State to take further steps where necessary to ensure a smooth transition to a UK chemicals regime following the UK’s exit from the EU. I am encouraged that the Bill makes it possible to keep the legislation up to date and respond to emerging needs or ambitions for the effective management of chemicals.

It is fundamental to the protection of our country that the exemptions for armed forces, defence and national security are maintained. A critical part of the role of Defence and Home Office Ministers is to make decisions about the use of UK forces to prevent harm, save lives, protect UK interests or deal with a threat. It would not be appropriate for Ministers to have to go through the process of considering the set of environmental principles before implementing any vital and urgent policies related to these decisions. Furthermore, the Ministry of Defence has its own environmental policies in place, as well as a commitment that its policies protect the environment, with a strong record on delivering on those commitments.

I am pleased that the UK has been at the forefront of opposing animal tests where alternative approaches could be used. This is known as the "last-resort principle", which we will retain and enshrine in legislation through the Environment Bill. I am pleased that Ministers are determined that there should be no need for any additional animal testing for a chemical that has already been registered, unless it is subject to further evaluation that shows the registration dossier is inadequate or there are still concerns about the hazards and risks of the chemical, especially to human health.

The Government continues to support the restrictions on neonicotinoids to protect pollinators, and emergency authorisations for pesticides are only granted in exceptional circumstances where diseases or pests cannot be controlled by any other reasonable means. These emergency authorisations can provide short term availability of a product if the applicant can demonstrate that this addresses a danger which cannot be contained by any other reasonable means, that the use will be limited and controlled and that the necessary protection of people and of the environment can be achieved. Under EU legislation, Member States may also grant emergency authorisations in exceptional circumstances. I can assure you that the UK’s approach to the use of emergency authorisations has not changed as a result of the UK’s exit from the EU.

The UK has left the EU and EU REACH regulations have been brought into UK law. The UK continues to seek high standards of protection for the environment and human health in the UK REACH regime. I am pleased that the Environment Bill already includes safeguards to protect the fundamental principles of REACH, and therefore the proposed amendment was not necessary.

Outside the EU Britain can develop global gold standard environmental policies. Having left the Common Agricultural Policy we can use public money for public goods, rewarding environmentally responsible land use, and leaving the Common Fisheries Policy means we are able to grant access and allocate quotas based on sustainability, allowing us to pursue the highest standards in marine conservation.

Thank you again for taking the time to contact me.

Kind regards,