Month: June 2024
Solving Q.B Keeps Asking to Update
How can I prevent Q.B from continuously prompting for updates? I need a solution to resolve this issue and ensure uninterrupted workflow without frequent update reminders.
How can I prevent Q.B from continuously prompting for updates? I need a solution to resolve this issue and ensure uninterrupted workflow without frequent update reminders. Read More
Sharepoint Excel hierarchical access
Hi All,
I am new to Sharepoint Excel. I need to know if custom access can be created in Sharepoint Excel.
I want to create 2 sets of user groups. Senior and Junior. Both will have edit access for the file but if a cell is edited by Senior user then Junior user cannot edit that cell. This is a primary requirement.
I have been going through tutorials and documentation regarding accesses. There are standard ways like read / edit accesses. I could not find anything specific to this scenario. Usually if user has edit access then he can edit anything in sheet. I wanted to know can that be limited ?
Hi All,I am new to Sharepoint Excel. I need to know if custom access can be created in Sharepoint Excel. I want to create 2 sets of user groups. Senior and Junior. Both will have edit access for the file but if a cell is edited by Senior user then Junior user cannot edit that cell. This is a primary requirement. I have been going through tutorials and documentation regarding accesses. There are standard ways like read / edit accesses. I could not find anything specific to this scenario. Usually if user has edit access then he can edit anything in sheet. I wanted to know can that be limited ? Read More
Can’t schedule a Microsoft Teams call despite having add-on enabled
Hello,
I have the MS Teams Add-on enabled and am signed in to Teams but Office does not give me an option to schedule a Teams meeting (I can ‘Meet Now’ but want one for a week hence).
How do I correct this?
Thanks
Mike
Hello,I have the MS Teams Add-on enabled and am signed in to Teams but Office does not give me an option to schedule a Teams meeting (I can ‘Meet Now’ but want one for a week hence).How do I correct this?ThanksMike Read More
Matlab: Telnet to Keysight VXT not succesful.
Not able to Connect to Keysight VXT using telnet and run SCPI command . Following is the code used.
t = tcpip(‘10.232.133.147’, 5023);
set(t, ‘InputBufferSize’, 30000);
fopen(t);
command=’:SOUR:POW:AMPL -63 DBMn’
fprintf(t, command);
fclose(t);Not able to Connect to Keysight VXT using telnet and run SCPI command . Following is the code used.
t = tcpip(‘10.232.133.147’, 5023);
set(t, ‘InputBufferSize’, 30000);
fopen(t);
command=’:SOUR:POW:AMPL -63 DBMn’
fprintf(t, command);
fclose(t); Not able to Connect to Keysight VXT using telnet and run SCPI command . Following is the code used.
t = tcpip(‘10.232.133.147’, 5023);
set(t, ‘InputBufferSize’, 30000);
fopen(t);
command=’:SOUR:POW:AMPL -63 DBMn’
fprintf(t, command);
fclose(t); keysight, telnet, scpi MATLAB Answers — New Questions
Add header to extrated data from .mat file
%—–create input files for carmaker maneuvers
for i = 1:length(testProcRes.ManoeuvreResults) % Checking the number of data files inside the main mat file.
testinput (:,1)= testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,91); % physical test time in sec
testinput (:,2) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries(:,4); % throttle inputs in percentage
testinput (:,3) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,18); % test steering wheel angle in rad
testinput (:,4) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,19); % Velocity in m/sec
testinput (:,5) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,24); % Brake inputs.
txtname = append(testProcRes.ManoeuvreResults(1,i).ManoeuvreName,’_’,string(i),’.asc’); % Storing the file name
writetable(testinput,txtname,’Delimiter’,’ ‘,’QuoteStrings’,true, ‘Filetype’, ‘text’) % Export data into text file.
In generated txt file i would like to add header for each column eg testinput(:,1) should have time name , so on refer screenshot for more detail%—–create input files for carmaker maneuvers
for i = 1:length(testProcRes.ManoeuvreResults) % Checking the number of data files inside the main mat file.
testinput (:,1)= testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,91); % physical test time in sec
testinput (:,2) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries(:,4); % throttle inputs in percentage
testinput (:,3) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,18); % test steering wheel angle in rad
testinput (:,4) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,19); % Velocity in m/sec
testinput (:,5) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,24); % Brake inputs.
txtname = append(testProcRes.ManoeuvreResults(1,i).ManoeuvreName,’_’,string(i),’.asc’); % Storing the file name
writetable(testinput,txtname,’Delimiter’,’ ‘,’QuoteStrings’,true, ‘Filetype’, ‘text’) % Export data into text file.
In generated txt file i would like to add header for each column eg testinput(:,1) should have time name , so on refer screenshot for more detail %—–create input files for carmaker maneuvers
for i = 1:length(testProcRes.ManoeuvreResults) % Checking the number of data files inside the main mat file.
testinput (:,1)= testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,91); % physical test time in sec
testinput (:,2) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries(:,4); % throttle inputs in percentage
testinput (:,3) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,18); % test steering wheel angle in rad
testinput (:,4) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,19); % Velocity in m/sec
testinput (:,5) = testProcRes.ManoeuvreResults(1,i).ProcessedRun.Timeseries (:,24); % Brake inputs.
txtname = append(testProcRes.ManoeuvreResults(1,i).ManoeuvreName,’_’,string(i),’.asc’); % Storing the file name
writetable(testinput,txtname,’Delimiter’,’ ‘,’QuoteStrings’,true, ‘Filetype’, ‘text’) % Export data into text file.
In generated txt file i would like to add header for each column eg testinput(:,1) should have time name , so on refer screenshot for more detail add header in text file data MATLAB Answers — New Questions
Complex Integration in MATLAB with symbolic integration limits
I’m having trouble with integrating this using MATLAB. When i try and run it as shown below, the answer that comes out i’m pretty sure is wrong. This is the first time i’m using matlab to help with integration so apologies in advance if i’m doing something very silly. Can anyone give me some pointers as to what i’m doing wrong?
syms y b n_1 n_2 R
b_y = (b-((b-(b/4))/(n_1+n_2))*y);
x = (y^2*b_y)/(1+(y/R));
I = int(x,-n_1,n_2)I’m having trouble with integrating this using MATLAB. When i try and run it as shown below, the answer that comes out i’m pretty sure is wrong. This is the first time i’m using matlab to help with integration so apologies in advance if i’m doing something very silly. Can anyone give me some pointers as to what i’m doing wrong?
syms y b n_1 n_2 R
b_y = (b-((b-(b/4))/(n_1+n_2))*y);
x = (y^2*b_y)/(1+(y/R));
I = int(x,-n_1,n_2) I’m having trouble with integrating this using MATLAB. When i try and run it as shown below, the answer that comes out i’m pretty sure is wrong. This is the first time i’m using matlab to help with integration so apologies in advance if i’m doing something very silly. Can anyone give me some pointers as to what i’m doing wrong?
syms y b n_1 n_2 R
b_y = (b-((b-(b/4))/(n_1+n_2))*y);
x = (y^2*b_y)/(1+(y/R));
I = int(x,-n_1,n_2) integration, mathematics, matlab code MATLAB Answers — New Questions
Move the chat column
Hi all!
I wonder if i can move a little bit the chat column to see longer names of chats.
I did not see anything about this at the Internet.
Like the red arrow.
Best regards
Hi all! I wonder if i can move a little bit the chat column to see longer names of chats.I did not see anything about this at the Internet. Like the red arrow. Best regards Read More
Stop Teams rearranging windows
I am using Teams on my Mac to conduct an online training for software developers.
My main screen is shared in Teams and shows my PowerPoint slides in presentation mode. The teams meeting window itself has been moved to my second screen.
Now anytime when I switch between PowerPoint and some other tool (code editor, whatever) Teams rearranges the meeting window to some minimized version and into the bottom right corner of my MAIN screen where it covers parts of the editor.
Its extremely annoying having to click the diagonal arrow button in the Teams meeting windows to have it move back to its original position and size.
How can I stop Teams from repositioning the meeting window?
I am using Teams on my Mac to conduct an online training for software developers. My main screen is shared in Teams and shows my PowerPoint slides in presentation mode. The teams meeting window itself has been moved to my second screen. Now anytime when I switch between PowerPoint and some other tool (code editor, whatever) Teams rearranges the meeting window to some minimized version and into the bottom right corner of my MAIN screen where it covers parts of the editor. Its extremely annoying having to click the diagonal arrow button in the Teams meeting windows to have it move back to its original position and size. How can I stop Teams from repositioning the meeting window? Read More
Windows usb
Hello i recently purchased a legal retail copy of windows 11 pro and it came with an usb. I want to format that usb and put more up to date version of windows on it, but it reports as read only. Is there a way to change that?
Hello i recently purchased a legal retail copy of windows 11 pro and it came with an usb. I want to format that usb and put more up to date version of windows on it, but it reports as read only. Is there a way to change that? Read More
How do I separate vocals from a song on Windows PC?
I’ve recently been working on a project where I need to separate vocal from a song. I’m using a Windows PC, and I’ve tried a few programs but the results are not very good, either the operation is too complicated, or the quality of the separated sound is not good enough. I wonder if there is any methods that can do this simply and effectively? If anyone has a good recommendation or experience to share, it’s really so needed! Thanks everyone!
I’ve recently been working on a project where I need to separate vocal from a song. I’m using a Windows PC, and I’ve tried a few programs but the results are not very good, either the operation is too complicated, or the quality of the separated sound is not good enough. I wonder if there is any methods that can do this simply and effectively? If anyone has a good recommendation or experience to share, it’s really so needed! Thanks everyone! Read More
functions, formulas
=UNIQUE=SEQUENCE=SORT=SORTBY
Hello, everyone, I’m trying to use the sequence function, sort and unique in my Excel, but it doesn’t appear, should I install something? Or changed the name?
=UNIQUE=SEQUENCE=SORT=SORTBYHello, everyone, I’m trying to use the sequence function, sort and unique in my Excel, but it doesn’t appear, should I install something? Or changed the name? Read More
M365 apps for enterprises subscription info missing in produict info
HI Team,
In our organization, we have deployed the M365 apps 32 bit through ODT and manage via cloud updates. We do have E3 license activated.
When reviewing the product information, I don’t get the M365 apps for enterprises subscription inform. I have attached the screenshot for the difference. Is that anything, we need to correct?
HI Team, In our organization, we have deployed the M365 apps 32 bit through ODT and manage via cloud updates. We do have E3 license activated. When reviewing the product information, I don’t get the M365 apps for enterprises subscription inform. I have attached the screenshot for the difference. Is that anything, we need to correct? Read More
How can I recover forgotten password for Word document?
Hello everyone, I have a question here for you. I created a Word document earlier and set it password protected, but now I forgot Word document password and can’t open the file. This document is very important to me and it contains some important information for my work. I wonder if there is any way to recover this forgotten Word document password? If anyone knows how to do it, please share your experience, thank you very much!
Hello everyone, I have a question here for you. I created a Word document earlier and set it password protected, but now I forgot Word document password and can’t open the file. This document is very important to me and it contains some important information for my work. I wonder if there is any way to recover this forgotten Word document password? If anyone knows how to do it, please share your experience, thank you very much! Read More
Using MLX Framework with Phi-3
Previously, I shared with you how to use Phi-3-mini on AIPC’s NPU and iPhone. Some people want to know more about the experience of using macOS and how to use Apple Silicon to accelerate SLM models. This blog will share with you relevant knowledge, including how to use Apple MLX Framework to accelerate Phi-3-mini operation, fine-tune, and combine Llama.cpp for quantitative operation.
What’s MLX Framework
MLX is an array framework for machine learning research on Apple silicon, brought to you by Apple machine learning research.
MLX is designed by machine learning researchers for machine learning researchers. The framework is intended to be user-friendly, but still efficient to train and deploy models. The design of the framework itself is also conceptually simple. We intend to make it easy for researchers to extend and improve MLX with the goal of quickly exploring new ideas.
LLMs can be accelerated in Apple Silicon devices through MLX, and models can be run locally very conveniently.
Installation
Installing MLX is easy, you will need Python 3.11.x+, then install it in the terminal
pip install mlx-lm
Run MLX’s instructions
1. Running Phi-3-mini in Terminal with MLX
python -m mlx_lm.generate –model microsoft/Phi-3-mini-4k-instruct –max-token 2048 –prompt “<|user|>nCan you introduce yourself<|end|>n<|assistant|>”
2. Quantizing Phi-3-mini with MLX in Terminal
python -m mlx_lm.convert –hf-path microsoft/Phi-3-mini-4k-instruct
3. Running Phi-3-mini with MLX in Jupyter Notebook
Note: Please read Inference Phi-3 with Apple MLX Framework to Learn more
Fine-tuning with MLX Framework
We generally need GPU acceleration to complete model training or fine-tuning, but in Apple devices you can use Apple silicon’s MPS(Metal Performance Shaders) to replace the GPU to complete model training and fine-tuning.
What’s Metal Performance Shaders
The Metal Performance Shaders framework contains a collection of highly optimized compute and graphics shaders that are designed to integrate easily and efficiently into your Metal app. These data-parallel primitives are specially tuned to take advantage of the unique hardware characteristics of each GPU family to ensure optimal performance.
Sample – Using LoRA to fine-tuning Phi-3-mini with MLX
1. Data preparation
By default, MLX Framework requires the jsonl format of train, test, and eval, and is combined with Lora to complete fine-tuning jobs.
Note:
jsonl data format :
{“text”: “<|user|>nWhen were iron maidens commonly used? <|end|>n<|assistant|> nIron maidens were never commonly used <|end|>”}
{“text”: “<|user|>nWhat did humans evolve from? <|end|>n<|assistant|> nHumans and apes evolved from a common ancestor <|end|>”}
{“text”: “<|user|>nIs 91 a prime number? <|end|>n<|assistant|> nNo, 91 is not a prime number <|end|>”}
….
Our example uses TruthfulQA’s data , but the amount of data is relatively insufficient, so the fine-tuning results are not necessarily the best. It is recommended that learners use better data based on their own scenarios to complete.
The data format is combined with the Phi-3 template
Please download data from this link , please inculde all .jsonl in data folder
2. Fine-tuning in your terminal
Please run this command in terminal
python -m mlx_lm.lora –model microsoft/Phi-3-mini-4k-instruct –train –data ./data –iters 1000
Note: This is LoRA fine-tuning, MLX framework not published QLoRA
3. Run Fine-tuning adapter to test
You can run fine-tuning adapter in terminal,like this
python -m mlx_lm.generate –model microsoft/Phi-3-mini-4k-instruct –adapter-path ./adapters –max-token 2048 –prompt “Why do chameleons change colors? “ –eos-token “<|end|>”
and run original model to compare result
python -m mlx_lm.generate –model microsoft/Phi-3-mini-4k-instruct –max-token 2048 –prompt “Why do chameleons change colors? “ –eos-token “<|end|>”
You can try to compare the results of Fine-tuning with the original model
4. Merge adapters to generate new models
python -m mlx_lm.fuse –model microsoft/Phi-3-mini-4k-instruct
5. Running quantified fine-tuning models using ollama
Before use, please configure your llama.cpp environment
git clone https://github.com/ggerganov/llama.cpp.git
cd llama.cpp
pip install -r requirements.txt
python convert.py ‘Your meger model path’ –outfile phi-3-mini-ft.gguf –outtype f16
Note:
Now supports quantization conversion of fp32, fp16 and INT 8
The merged model is missing tokenizer.model, please download it from https://huggingface.co/microsoft/Phi-3-mini-4k-instruct
set Ollma Model file(If not install ollama ,please read [Ollama QuickStart](../02.QuickStart/Ollama_QuickStart.md)
FROM ./phi-3-mini-ft.gguf
PARAMETER stop “<|end|>”
run command in terminal
ollama create phi3ft -f Modelfile
ollama run phi3ft “Why do chameleons change colors?”
Note: Please read Fine-tuning Phi-3 with Apple MLX Framework to Learn more
Resources
Read Phi-3 CookBook https://aka.ms/phi-3cookbook
MLX framework Repo https://github.com/ml-explore
Learn more about MLX Framework https://ml-explore.github.io/mlx/
Hugging face Phi-3 Family https://huggingface.co/collections/microsoft/phi-3-6626e15e9585a200d2d761e3
Microsoft Tech Community – Latest Blogs –Read More
Send emails via SMTP relay with Azure Communication Service
We’ve come across multiple cases where customers want to send emails from Applications migrated to Azure through some kind of SMTP service. Though we’ve seen customers opting for O365 for SMTP relay, this can create issues due to throttling limitations in Office Service. Also, managing mailbox and license assignment on Office 365 console is a different story; customers would want to have seamless SMTP relay service experience from single console on Azure.
Though Azure Communication service supports sending emails outbound but currently it requires you to integrate it via the ACS SDK that Microsoft provide. In scenarios where you don’t want to modify code and just change the pointing of your SMTP server to Azure, you can now use ACS – SMTP relay built into Email communication service.
Azure Communication Service supports different types of notifications, SMTP relay in ACS is now Generally available and this blog post is simple step by step instructions of how you can quickly test the service and then migrate from Sendgrid or another service you’re using to native ACS – Email communication service for better operational experience and support.
Create Azure Communication Service Account
First step you’ll need to do is to create an ACS account. This is a parent service which has multiple notification services inside it(Chat,SMS, Email etc). Email communications service is one of them.
Create Email communication service
We’ll have to create ECS which is the actual service that holds configuration details.
Add a custom domain to ECS
ECS provides Azure managed domain which look like this “GUID.azurecomm.net” this provides limited volume of email hence using custom domain is preferred. Once you add a custom domain, the UI provides you with TXT record which you’ll need to create in your Name server. This would take 15 minutes to verify the domain
Once domain is verified the screen looks like this, you’ll have to create SPF and DKIM records so that your email doesn’t land in junk and ownership is maintained.
Once all the records are created the screen would look like this, please ignore the azure managed domain. You can only have custom domain in the account and doesn’t have to add Azure Domain explicitly.
Attach custom domain to ACS Account
Once email is validated we’ll need to attach ECS to ACS.
Create and Assign custom RBAC Role for Authentication
We’ll be using 587 port to send email which is authenticated SMTP. For authentication we have Entra ID authentication. Create a service principal by going to Entra ID – App registration page. Register the app and create a client secret. Note down Client ID, Tenant ID and Secret value. This will be used in next stage for authentication. We’ll need to create a custom RBAC role which has permission to send email. We’ll clone reader role.
And we’ll be adding two actions which is present in Azure Communication service resource provider.
Once the Role is created we’ll need to assign this to service principal
Test SMTP Relay via Powershell
That’s all, now you’ll need to find out the sender email. Which is default DoNotReply@domain.com
You’ll need credentials to authenticate to the service.
Username is < Azure Communication Services Resource name>. < Entra Application ID>. < Entra Tenant ID>
Password is the client secret which you’ve generated.
Port that we’ll need to use is 587
SMTP server address is smtp.azurecomm.net
Now you can use any third party application to send email via the above parameters. To showcase we can use PowerShell with the same parameters to send emails.
Conclusion: I trust this guide helps you in configuring SMTP relay and send emails from your custom application without any change to the application/code.
Happy Learning!
Personal Blog post of SMTP relay:
Send emails via SMTP relay with Azure Communication Service
Find similar tech blog on my personal blog
https://www.azuredoctor.com/
Microsoft Tech Community – Latest Blogs –Read More
Empowering cloud efficiency through FinOps
Now available on-demand, for free, is the recording of our Azure Webinar session “Empowering cloud efficiency through FinOps”.
FinOps Foundation Founder & Executive Director, J.R. Storment, and Microsoft speakers Sonia Cuff, Arthur Clares and Thomas Lewis, explain FinOps concepts and relevant Microsoft solutions and resources. You’ll learn about:
The FinOps operational framework and cultural practice, which maximises the business value of cloud;
Microsoft FinOps Interactive Guides, for exploring Microsoft solutions that enable FinOps Capabilities;
Quick wins for rapid cloud cost reduction;
How to prepare for Environmental, Social & Governance (ESG) regulations;
Microsoft resources to help you with your FinOps journey.
To access the webinar recording, register here: Empowering cloud efficiency through FinOps Webinar
With thanks to J.R. Storment at the team at The FinOps Foundation.
Microsoft Tech Community – Latest Blogs –Read More
How do I get rid of the title page when I create a report using custom reporters?
Hello,
Unfortunately, despite using custom reporters, I’m getting a kind of title page that I didn’t define and doesn’t use my own reporter. How do I get rid of it?
my Test Skript:
rpt = Report(Test, ‘pdf’);
%//// Page1
page1 = Test.TestReporter();
page1.department = "AUM2";
page1_detailheader = Test.TestReporter(‘detail_header’);
add(rpt, page1_detailheader)
add(rpt, page1)
%////Page2
page2 = Test.TestReporterl();
add(rpt, page2)
close(rpt);
rptview(rpt);Hello,
Unfortunately, despite using custom reporters, I’m getting a kind of title page that I didn’t define and doesn’t use my own reporter. How do I get rid of it?
my Test Skript:
rpt = Report(Test, ‘pdf’);
%//// Page1
page1 = Test.TestReporter();
page1.department = "AUM2";
page1_detailheader = Test.TestReporter(‘detail_header’);
add(rpt, page1_detailheader)
add(rpt, page1)
%////Page2
page2 = Test.TestReporterl();
add(rpt, page2)
close(rpt);
rptview(rpt); Hello,
Unfortunately, despite using custom reporters, I’m getting a kind of title page that I didn’t define and doesn’t use my own reporter. How do I get rid of it?
my Test Skript:
rpt = Report(Test, ‘pdf’);
%//// Page1
page1 = Test.TestReporter();
page1.department = "AUM2";
page1_detailheader = Test.TestReporter(‘detail_header’);
add(rpt, page1_detailheader)
add(rpt, page1)
%////Page2
page2 = Test.TestReporterl();
add(rpt, page2)
close(rpt);
rptview(rpt); report generator, title page MATLAB Answers — New Questions
I would like to know how to make sure the latitude labels have decimals in them.
I have this code creating a map of a small portion of Antarctica. I have the latitude lines appearing ever half of a degree, but the labels still show single degrees. Is it possible to have the labels have decimals?
Also is it possible to have the longitude lines appear with labels on the map instead of on the edge?
The base of the map is Bedmap.
figure(‘Color’,’w’)%Colors the figure white .
set(gca, ‘Color’, ‘none’);
mapzoom(-81.6, -148.8);%’size’,[100 100]);
framem on ; gridm on ; mlabel on ; plabel on ;
bedmap2(‘gl’,’color’,’k’,’linewidth’,1)
bedmap2(‘coast’)
setm(gca,’plinelocation’,.5,’plabellocation’,0.5 ,…
‘labelrotation’,’on’);
hold on;I have this code creating a map of a small portion of Antarctica. I have the latitude lines appearing ever half of a degree, but the labels still show single degrees. Is it possible to have the labels have decimals?
Also is it possible to have the longitude lines appear with labels on the map instead of on the edge?
The base of the map is Bedmap.
figure(‘Color’,’w’)%Colors the figure white .
set(gca, ‘Color’, ‘none’);
mapzoom(-81.6, -148.8);%’size’,[100 100]);
framem on ; gridm on ; mlabel on ; plabel on ;
bedmap2(‘gl’,’color’,’k’,’linewidth’,1)
bedmap2(‘coast’)
setm(gca,’plinelocation’,.5,’plabellocation’,0.5 ,…
‘labelrotation’,’on’);
hold on; I have this code creating a map of a small portion of Antarctica. I have the latitude lines appearing ever half of a degree, but the labels still show single degrees. Is it possible to have the labels have decimals?
Also is it possible to have the longitude lines appear with labels on the map instead of on the edge?
The base of the map is Bedmap.
figure(‘Color’,’w’)%Colors the figure white .
set(gca, ‘Color’, ‘none’);
mapzoom(-81.6, -148.8);%’size’,[100 100]);
framem on ; gridm on ; mlabel on ; plabel on ;
bedmap2(‘gl’,’color’,’k’,’linewidth’,1)
bedmap2(‘coast’)
setm(gca,’plinelocation’,.5,’plabellocation’,0.5 ,…
‘labelrotation’,’on’);
hold on; bedmap, latitude, longitude, antarctica, setm MATLAB Answers — New Questions
Graph API e-mail access stopped working after three months
Hello, I used this guide to do some e-mail read/write using Python. It worked without issues for three months (running every two minutes), then after indeed three months on the day my refresh token stopped functioning.
def connect() -> dict[str, str]:
url = “https://login.microsoftonline.com/<snipped>/oauth2/v2.0/token”
payload = {
“grant_type”: “refresh_token”,
“client_id”: “<snipped>”,
“scope”: “offline_access Mail.ReadWrite”,
“code”: “<snipped>”,
“refresh_token”: “<snipped>”,
“client_secret”: “<snipped>”,
}
headers = {
“Content-Type”: “application/x-www-form-urlencoded”,
“Cookie”: “<snipped>”,
}
try:
response = requests.post(url, headers=headers, data=payload)
response.raise_for_status()
return ast.literal_eval(str(response.text))
except Exception:
return {}
Printing the exception gives me:
400 Client Error: Bad Request for url: https://login.microsoftonline.com/<snipped>/oauth2/v2.0/token
An astute reader might suspect my client secret expired, since its default duration is three months, but I gave it a longer duration than that when I created it. It is very much not expired.
I have since tried to perform the whole process from scratch. I seem to effectively get this far:
https://login.microsoftonline.com/<<Directory (tenant) ID>>/oauth2/v2.0/authorize?client_id=<<Application (client) ID>>&response_type=code&redirect_uri=https%3A%2F%2Flocalhost&response_mode=query&scope=offline_access%20Mail.ReadWrite&state=12345644
Replacing the two IDs and visiting the URL gives me a code as before. I copy the part between …code= and &state=… and perform the Postman step (from the guide) on it:
Request Type: Post
Request URL: https://login.microsoftonline.com/<tenant id>/oauth2/v2.0/token
client_id: your client id
scope: offline_access Mail.ReadWrite
code: you got in step (a)
redirect_uri: https://localhost
grant_type: authorization_code
client_secret: your secret
But that gives me this error:
{
“error”: “invalid_grant”,
“error_description”: “AADSTS70008: The provided authorization code or refresh token has expired due to inactivity. Send a new interactive authorization request for this user and resource. <snipped>”,
“error_codes”: [
70008
],
“timestamp”: “<snipped>”,
“trace_id”: “<snipped>”,
“correlation_id”: “<snipped>”,
“error_uri”: “https://login.microsoftonline.com/error?code=70008”
}
Mind you, this happens even if I corrupt the code or make it something silly like a single character, so it seems to me the problem isn’t with the code, but for the life of me I cannot figure it out. Anyone able to tell what I’m doing wrong?
Hello, I used this guide to do some e-mail read/write using Python. It worked without issues for three months (running every two minutes), then after indeed three months on the day my refresh token stopped functioning. def connect() -> dict[str, str]:
url = “https://login.microsoftonline.com/<snipped>/oauth2/v2.0/token”
payload = {
“grant_type”: “refresh_token”,
“client_id”: “<snipped>”,
“scope”: “offline_access Mail.ReadWrite”,
“code”: “<snipped>”,
“refresh_token”: “<snipped>”,
“client_secret”: “<snipped>”,
}
headers = {
“Content-Type”: “application/x-www-form-urlencoded”,
“Cookie”: “<snipped>”,
}
try:
response = requests.post(url, headers=headers, data=payload)
response.raise_for_status()
return ast.literal_eval(str(response.text))
except Exception:
return {} Printing the exception gives me:400 Client Error: Bad Request for url: https://login.microsoftonline.com/<snipped>/oauth2/v2.0/token An astute reader might suspect my client secret expired, since its default duration is three months, but I gave it a longer duration than that when I created it. It is very much not expired. I have since tried to perform the whole process from scratch. I seem to effectively get this far: https://login.microsoftonline.com/<<Directory (tenant) ID>>/oauth2/v2.0/authorize?client_id=<<Application (client) ID>>&response_type=code&redirect_uri=https%3A%2F%2Flocalhost&response_mode=query&scope=offline_access%20Mail.ReadWrite&state=12345644 Replacing the two IDs and visiting the URL gives me a code as before. I copy the part between …code= and &state=… and perform the Postman step (from the guide) on it: Request Type: PostRequest URL: https://login.microsoftonline.com/<tenant id>/oauth2/v2.0/tokenclient_id: your client idscope: offline_access Mail.ReadWritecode: you got in step (a)redirect_uri: https://localhostgrant_type: authorization_codeclient_secret: your secret But that gives me this error: {
“error”: “invalid_grant”,
“error_description”: “AADSTS70008: The provided authorization code or refresh token has expired due to inactivity. Send a new interactive authorization request for this user and resource. <snipped>”,
“error_codes”: [
70008
],
“timestamp”: “<snipped>”,
“trace_id”: “<snipped>”,
“correlation_id”: “<snipped>”,
“error_uri”: “https://login.microsoftonline.com/error?code=70008”
} Mind you, this happens even if I corrupt the code or make it something silly like a single character, so it seems to me the problem isn’t with the code, but for the life of me I cannot figure it out. Anyone able to tell what I’m doing wrong? Read More
Using browser local storage with Blazor
Project based on .NET Blazor Web App in Server render mode.
Blazor currently has no built-in function for utilizing local browser storage. However this feature can come in useful for storing user information or partially completed forms etc. Luckily implementing a class for facilitating this function is straightforward enough. Here I’ll run over the steps required to get local storage up and running in your Blazor web app.
Note: This method uses JSRuntime so make sure if you want to call it on page/component load you will need to run it on “OnAfterRender” rather than “OnInitialize” otherwise you will get an error.
Here is a screenshot of my file structure so you can see the additional files I’ve made and where I’ve placed them:
Making the javascript functions:
Within the wwwroot of your app, make a new javascript file (I’ve called mine LocalStorage.js) and enter the following code:
window.LocalStorageActions = {
setItem: function (key, value) {
localStorage.setItem(key, value);
},
getItem: function (key) {
return localStorage.getItem(key);
},
removeItem: function (key) {
localStorage.removeItem(key);
},
clearData: function () {
localStorage.clear();
}
}
These are the four functions we will need for setting, getting, removing and clearing local storage in the browser.
Make a C# class to call the functions:
To keep things tidy, I’ve put the C# class for calling the local storage functions and it’s interface into a folder called helpers, but you can put this wherever it’s most appropriate in your solution.
You can create a new .cs file and add the following code:
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace BlazorLocalStorage.Helpers
{
public class LocalStorageHelper : ILocalStorageHelper
{
private readonly IJSRuntime _javaScript;
public LocalStorageHelper(IJSRuntime javaScript)
{
_javaScript = javaScript;
}
public async Task SetItem(string key, string value)
{
await _javaScript.InvokeAsync<string>(“LocalStorageActions.setItem”, key, value);
}
public async Task<string> GetItem(string key)
{
return await _javaScript.InvokeAsync<string>(“LocalStorageActions.getItem”, key);
}
public async Task RemoveItem(string key)
{
await _javaScript.InvokeAsync<string>(“LocalStorageActions.removeItem”, key);
}
public async Task ClearData()
{
await _javaScript.InvokeAsync<string>(“LocalStorageActions.clearData”);
}
}
}
To quickly produce the interface for this class you can right click the class name (LocalStorageHelper in this case) and select “Quick Actions and Refactoring” and then select “Extract Interface”
This will open a popup for extracting an interface from the class that you can select OK and a new file called ILocalStorageHelper.cs will appear and the LocalStorageHelper class will now inherit from the interface that’s been created.
Registering the new files ready for use:
Firstly we want to reference the new javascript file for use in the application. To do this go to the App.razor file and add the following line in the <body> section of the file.
<script src=”LocalStorage.js”></script>
Next, we need to register the LocalStorageHelper so it can be injected wherever we want to use it. To do this open the Program.cs file and add the following line before the builder.Build() method it called.
builder.Services.AddScoped<ILocalStorageHelper, LocalStorageHelper>();
Let’s try it out:
I’ve made a little example of the new class being used by modifying the Home.razor file to use the various functions we’ve created. Before adding the main code I have created a little css class to centre the content of the page to keep things neat. So you can add the following code snippet to app.css.
.center-screen {
display: flex;
justify-content: center;
align-items: center;
text-align: center;
min-height: 70vh;
}
Now we can go into the Home.razor file and replace the content with the following.
@PAGE “/”
@using BlazorLocalStorage.Helpers
@rendermode InteractiveServer
<PageTitle>Home</PageTitle>
<div class=”center-screen”>
<div>
<div class=”row”>
<label>Text-1</label>
<InputText class=”m-2″ @bind-Value=”Text1″ />
</div>
<div class=”row”>
<button class=”btn btn-success m-2″ @onclick=”Save”>Save</button>
<button class=”btn btn-info m-2″ @onclick=”Load”>Load</button>
<button class=”btn btn-warning m-2″ @onclick=”Remove”>Remove</button>
<button class=”btn btn-danger m-2″ @onclick=”Clear”>Clear</button>
</div>
</div>
</div>
@code {
[Inject] ILocalStorageHelper LocalStorage { get; set; }
public string Text1 { get; set; }
public async Task Save()
{
await LocalStorage.SetItem(“textData”, Text1);
}
public async Task Load()
{
Text1 = await LocalStorage.GetItem(“textData”);
}
public async Task Remove()
{
await LocalStorage.RemoveItem(“textData”);
}
public async Task Clear()
{
await LocalStorage.ClearData();
}
}
Apologies for the garish use of coloured buttons but it’s just meant to be an obvious demo. If you open the browsers developer tools and navigate to “Application” the select “Local Storage” you will be able to see the data stored, updated or removed as you use the demo.
If you refresh the page or close and open the browser and select load it will pull the stored data back in to the textbox.
That’s all there is to it!
If you want to see the project, I’ve stuck a copy up on github that you can have a look at:
https://github.com/DrGav/BlazorLocalStorage
Have yourselves a wonderful day,
Gavin.
Project based on .NET Blazor Web App in Server render mode. Blazor currently has no built-in function for utilizing local browser storage. However this feature can come in useful for storing user information or partially completed forms etc. Luckily implementing a class for facilitating this function is straightforward enough. Here I’ll run over the steps required to get local storage up and running in your Blazor web app. Note: This method uses JSRuntime so make sure if you want to call it on page/component load you will need to run it on “OnAfterRender” rather than “OnInitialize” otherwise you will get an error. Here is a screenshot of my file structure so you can see the additional files I’ve made and where I’ve placed them: Making the javascript functions:Within the wwwroot of your app, make a new javascript file (I’ve called mine LocalStorage.js) and enter the following code: window.LocalStorageActions = {
setItem: function (key, value) {
localStorage.setItem(key, value);
},
getItem: function (key) {
return localStorage.getItem(key);
},
removeItem: function (key) {
localStorage.removeItem(key);
},
clearData: function () {
localStorage.clear();
}
} These are the four functions we will need for setting, getting, removing and clearing local storage in the browser. Make a C# class to call the functions:To keep things tidy, I’ve put the C# class for calling the local storage functions and it’s interface into a folder called helpers, but you can put this wherever it’s most appropriate in your solution.You can create a new .cs file and add the following code: using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace BlazorLocalStorage.Helpers
{
public class LocalStorageHelper : ILocalStorageHelper
{
private readonly IJSRuntime _javaScript;
public LocalStorageHelper(IJSRuntime javaScript)
{
_javaScript = javaScript;
}
public async Task SetItem(string key, string value)
{
await _javaScript.InvokeAsync<string>(“LocalStorageActions.setItem”, key, value);
}
public async Task<string> GetItem(string key)
{
return await _javaScript.InvokeAsync<string>(“LocalStorageActions.getItem”, key);
}
public async Task RemoveItem(string key)
{
await _javaScript.InvokeAsync<string>(“LocalStorageActions.removeItem”, key);
}
public async Task ClearData()
{
await _javaScript.InvokeAsync<string>(“LocalStorageActions.clearData”);
}
}
} To quickly produce the interface for this class you can right click the class name (LocalStorageHelper in this case) and select “Quick Actions and Refactoring” and then select “Extract Interface” This will open a popup for extracting an interface from the class that you can select OK and a new file called ILocalStorageHelper.cs will appear and the LocalStorageHelper class will now inherit from the interface that’s been created. Registering the new files ready for use:Firstly we want to reference the new javascript file for use in the application. To do this go to the App.razor file and add the following line in the <body> section of the file. <script src=”LocalStorage.js”></script> Next, we need to register the LocalStorageHelper so it can be injected wherever we want to use it. To do this open the Program.cs file and add the following line before the builder.Build() method it called. builder.Services.AddScoped<ILocalStorageHelper, LocalStorageHelper>(); Let’s try it out:I’ve made a little example of the new class being used by modifying the Home.razor file to use the various functions we’ve created. Before adding the main code I have created a little css class to centre the content of the page to keep things neat. So you can add the following code snippet to app.css. .center-screen {
display: flex;
justify-content: center;
align-items: center;
text-align: center;
min-height: 70vh;
} Now we can go into the Home.razor file and replace the content with the following. @PAGE “/”
@using BlazorLocalStorage.Helpers
@rendermode InteractiveServer
<PageTitle>Home</PageTitle>
<div class=”center-screen”>
<div>
<div class=”row”>
<label>Text-1</label>
<InputText class=”m-2″ @bind-Value=”Text1″ />
</div>
<div class=”row”>
<button class=”btn btn-success m-2″ @onclick=”Save”>Save</button>
<button class=”btn btn-info m-2″ @onclick=”Load”>Load</button>
<button class=”btn btn-warning m-2″ @onclick=”Remove”>Remove</button>
<button class=”btn btn-danger m-2″ @onclick=”Clear”>Clear</button>
</div>
</div>
</div>
@code {
[Inject] ILocalStorageHelper LocalStorage { get; set; }
public string Text1 { get; set; }
public async Task Save()
{
await LocalStorage.SetItem(“textData”, Text1);
}
public async Task Load()
{
Text1 = await LocalStorage.GetItem(“textData”);
}
public async Task Remove()
{
await LocalStorage.RemoveItem(“textData”);
}
public async Task Clear()
{
await LocalStorage.ClearData();
}
} Apologies for the garish use of coloured buttons but it’s just meant to be an obvious demo. If you open the browsers developer tools and navigate to “Application” the select “Local Storage” you will be able to see the data stored, updated or removed as you use the demo. If you refresh the page or close and open the browser and select load it will pull the stored data back in to the textbox. That’s all there is to it! If you want to see the project, I’ve stuck a copy up on github that you can have a look at:https://github.com/DrGav/BlazorLocalStorage Have yourselves a wonderful day,Gavin. Read More