csharpfritz / csharp_with_csharpfritz Goto Github PK
View Code? Open in Web Editor NEWShow notes, slides, and samples from the CSharp with CSharpFritz show
License: MIT License
Show notes, slides, and samples from the CSharp with CSharpFritz show
License: MIT License
Hi Jeff, thank you for your lessons and your answers!
How to add social share buttons to Blazor?
So far I've managed to get an active page address and sharing links.
Links are taken from: https://github.com/bradvin/social-share-urls
But I could only get index.html
title
and meta description
tag contents by using JavaScript.
This is my separate Blazor component, Social.razor:
@inject NavigationManager UriManager
@inject IJSRuntime jsRuntime
<a href="https://www.linkedin.com/sharing/share-offsite/?url=@(UriManager.Uri)" title="LinkedIn" target="_blank">LinkedIn</a>
<a href="https://www.facebook.com/sharer.php?u=@(UriManager.Uri)" title="Facebook" target="_blank">Facebook</a>
<a href="https://twitter.com/intent/tweet?url=@(UriManager.Uri)&text=@Title" title="Twitter" target="_blank">Twitter</a>
<a href="http://pinterest.com/pin/create/button/?url=@(UriManager.Uri)" title="Pinterest" target="_blank">Pinterest</a>
<a href="https://web.skype.com/share?url=@(UriManager.Uri)&text=@Title" title="Skype" target="_blank">Skype</a>
<a href="https://social-plugins.line.me/lineit/share?url=@(UriManager.Uri)" title="Line" target="_blank">Line</a>
<a href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=@(UriManager.Uri)&title=@Title&summary=@Description" title="QZone" target="_blank">QZone</a>
<a href="http://service.weibo.com/share/share.php?url=@(UriManager.Uri)" title="Weibo" target="_blank">Weibo</a>
<a href="https://reddit.com/submit?url=@(UriManager.Uri)&title=@Title" title="Reddit" target="_blank">Reddit</a>
<a href="http://www.livejournal.com/update.bml?subject=@Title&event=@(UriManager.Uri)" title="LiveJournal" target="_blank">LiveJournal</a>
<a href="http://vk.com/share.php?url=@(UriManager.Uri)&title=@Title&comment=@Description" title="VKontakte" target="_blank">VK</a>
<a href="https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&st.shareUrl=@(UriManager.Uri)" title="Odnoklassniki" target="_blank">OK</a>
<a href="https://t.me/share/url?url=@(UriManager.Uri)&text=@Title" title="Telegram" target="_blank">Telegram</a>
@code {
public string Description = "";
public string Title = "";
protected override async Task OnInitializedAsync()
{
Title = await jsRuntime.InvokeAsync<string>("getTitle");
Description = await jsRuntime.InvokeAsync<string>("getDescription");
}
}
JavaScript to get an active page title, inserted into index.html
<script>window.getTitle = () => { return document.title; };</script>
JavaScript to get meta description contents, inserted into index.html:
<script> window.getDescription = () => { var metas = document.getElementsByTagName('meta'); for(var i in metas) { if (typeof(metas[i].name) != 'undefined' && metas[i].name.toLowerCase() == "description") { return encodeURIComponent(metas[i].content); } } return ''; } </script>
My question, how to get t:
PageTitle
from the active page<meta name="description" content="MegaSuperExcellPage">
inside HeadContent
It looks like that it is possible without JavaScript
How to use xUnit / nUnit
May need to be two episodes
Lists, Arrays, Dictionaries, HashSets, Indexer methods
Intro to using Generics should be covered as well
Hi Jeff,
W3Counter demands to add its script for every page on a website.
Is there a workaround to avoid manual labour?
Any bright ideas for simple web analytics?
Hi, Fritz! Can you talk about how when a user visits our page that has our WASM, we can immediately detect if that user has installed our WASM locally, and if not, how we can pop up a window in which they can click a button to install it? Any gotchas we should know about? Thanks!
What is the recommended to do? create the constructor before the class properties or the properties before the constructor?
Creating, using, and more
+=
++
etc
Will this series cover documenting code with XML Documentation Comments?
Official Docs for ref: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/xmldoc/
/cc @csharpfritz
Need to talk more about operators and string formatting operations
Let's talk about the new features of C# 9 as they are released with .NET 5
Hi Jeff,
a humble request to elaborate more on Blazored.LocalStorage and file saving to a local PC.
As simple as possible. Saving a few different counters on disk, like in game character stats creation.
Hey I saw someone asking for some WPF series and he didn't make an issue, so.. I did. Totally agreed with this idea, I feel like docs are outdated so would be great to see some series about WPF.
Thanks in advance!
What makes good class design? SOLID principles
I think it would be nice to have dev container configuration added.
This repository is already containerized and dev container adds features on top of it.
Refπ: https://code.visualstudio.com/docs/remote/create-dev-container
I'd be happy to contribute.
Hello Jeff, as you can see in the "header" the "content-length" of my "request" is too long... π
First, I want to thank you and congratulate for the passion, dedication and tech detail in your live streamings, good job!
Second, if you can at some time in the near future, explain about the end-to-end process for get the same configuration just like your repository: how can I deploy or set the notebooks in github with binder support, and also get the same locally with VS Code with and without docker.
I am a humble instructor of C# in a non-profit organization in my city (Rosario, Argentina) and I wish to replicate your teach technique, at least for the basics concepts of the language
Thanks again!
PS: I originally post the same question in Fritz.LiveStream by mistake. Sorry
Project Tye should be introduced as well
Add links to the README for information about getting started with .NET Interactive and Jupyter Notebooks
October? This is an intermediate topic and may be good to present with a guest
Maybe for the August 24th session
Let's talk about a user interface next. ... but which one?
Vote with a π on the response that you are interested in seeing first.
Based on the timing of the episodes, this should be a .NET 5 hosted series
Getting below error while executing docker-compose up command. I am in the correct directory and running the command. Let me know if it has anything do with any more configuration that is needed before running the docker command or it is something else.
Thanks in advance.
docker-compose up
Traceback (most recent call last):
File "site-packages/urllib3/connectionpool.py", line 677, in urlopen
File "site-packages/urllib3/connectionpool.py", line 392, in _make_request
File "http/client.py", line 1252, in request
File "http/client.py", line 1298, in _send_request
File "http/client.py", line 1247, in endheaders
File "http/client.py", line 1026, in _send_output
File "http/client.py", line 966, in send
File "site-packages/docker/transport/unixconn.py", line 43, in connect
FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "site-packages/requests/adapters.py", line 449, in send
File "site-packages/urllib3/connectionpool.py", line 727, in urlopen
File "site-packages/urllib3/util/retry.py", line 403, in increment
File "site-packages/urllib3/packages/six.py", line 734, in reraise
File "site-packages/urllib3/connectionpool.py", line 677, in urlopen
File "site-packages/urllib3/connectionpool.py", line 392, in _make_request
File "http/client.py", line 1252, in request
File "http/client.py", line 1298, in _send_request
File "http/client.py", line 1247, in endheaders
File "http/client.py", line 1026, in _send_output
File "http/client.py", line 966, in send
File "site-packages/docker/transport/unixconn.py", line 43, in connect
urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "site-packages/docker/api/client.py", line 205, in _retrieve_server_version
File "site-packages/docker/api/daemon.py", line 181, in version
File "site-packages/docker/utils/decorators.py", line 46, in inner
File "site-packages/docker/api/client.py", line 228, in _get
File "site-packages/requests/sessions.py", line 543, in get
File "site-packages/requests/sessions.py", line 530, in request
File "site-packages/requests/sessions.py", line 643, in send
File "site-packages/requests/adapters.py", line 498, in send
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "docker-compose", line 3, in
File "compose/cli/main.py", line 67, in main
File "compose/cli/main.py", line 123, in perform_command
File "compose/cli/command.py", line 69, in project_from_options
File "compose/cli/command.py", line 132, in get_project
File "compose/cli/docker_client.py", line 43, in get_client
File "compose/cli/docker_client.py", line 170, in docker_client
File "site-packages/docker/api/client.py", line 188, in init
File "site-packages/docker/api/client.py", line 213, in _retrieve_server_version
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
[1226] Failed to execute script docker-compose
Csharp
Listened to the recording for notebook 1 and felt like there were a few jumps or assumptions that newbies like me might not immediately get so had some suggestions that might make the stepping stones closer together:
// Everything in C# is an object
Can there be a short definition of what it means to be 'an object'? Something like:
_"The idea that there's a series of out-of-the-box (or user designed) specifications / blueprints - known as TYPES. When something new is created to those specifications / blueprints, it's known as an OBJECT.
As a result of being built to those particular blueprints / specifications, the new object will have characteristics (known as properties), and things it can do (known as methods).
A real world example would be if I got a new vehicle (let's call it 'myVehicle') built to 'car' specifications. It has characteristics (properties) such as colour, make, model. It also has things it can do (methods) like go forward, reverse.
The example OBJECT myVehicle is said to be "of TYPE car".
Properties are usually retrieved by adding a .Something after the name of the object. For example car.colour might return 'blue'.
Methods are usually triggered with .Something(). For example car.Goforward()
The brackets allow for extra detail to be added to the instruction. For example, instructing the car to advance a distance of 3 might be car.Goforward(3)"_
// Maybe an introduction to Type Casting
_"Trying to squeeze something that is originally of one shape into another shape. For example squeezing an integer into a hole designed for a decimal. C# can figure that out (implicit conversion) on the basis it fits into the hole with space left over.
However, trying to do the other way round (decimal into something designed for an integer) does not want to go naturally, so needs to be forced (explicit conversion)."_
// Modify and assign at the same time
Worth putting the equivalent code after in a comment?
e.g. // apples = apples + 10;
e.g. // apples = apples - 10;
...
Just thoughts - happy to write up and send over PR if useful. If doesn't work / fit the flow, no worries.
Need to go back and cover null
I would suggest a series on Roslyn including source generators and even combining code fixes with source generators including using IIncremental for performance.
Introduce and discuss NULL, NullReferenceException.
Tips, tricks, and why you NEED to use this NullReferences and nullability in your C# code
I've been getting a lot of questions from students on the usage of class vs structs. We have a doc here that discusses the topic.
Personally, I don't think I've ever created a struct for a production application. I'd love to hear/see some practical usage of where one is better suited than the other.
Hi Jeff
Is it possible to teach us How can we Securely connect Blazor to Azure sql database in such a way that can not be hacked.
Thanks in advance.
Hello, as the REST API becomes a standard of today's web communication, I would really love to see an in-deph series about it.
Here are some lesson ideas:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.