4 Python Loop Mistakes Everyone Makes (And How to Fix Them)
Source link
بلاگ
-
4 Python Loop Mistakes Everyone Makes (And How to Fix Them)
-
4 Docker Commands Everyone Gets Wrong
4 Docker Commands Everyone Gets Wrong
Source link -
Use your own user @ domain for Mastodon discoverability with the WebFinger Protocol without hosting a server
Mastodon is a free, open-source social networking service that is decentralized and distributed. It was created in 2016 as an alternative to centralized social media platforms such as Twitter and Facebook.
One of the key features of Mastodon is the use of the WebFinger protocol, which allows users to discover and access information about other users on the Mastodon network. WebFinger is a simple HTTP-based protocol that enables a user to discover information about other users or resources on the internet by using their email address or other identifying information. The WebFinger protocol is important for Mastodon because it enables users to find and follow each other on the network, regardless of where they are hosted.
WebFinger uses a “well known” path structure when calling an domain. You may be familiar with the robots.txt convention. We all just agree that robots.txt will sit at the top path of everyone’s domain.
The WebFinger protocol is a simple HTTP-based protocol that enables a user or search to discover information about other users or resources on the internet by using their email address or other identifying information. My is first name at last name .com, so…my personal WebFinger API endpoint is here https://www.hanselman.com/.well-known/webfinger
The idea is that…
-
A user sends a WebFinger request to a server, using the email address or other identifying information of the user or resource they are trying to discover.
-
The server looks up the requested information in its database and returns a JSON object containing the information about the user or resource. This JSON object is called a “resource descriptor.”
-
The user’s client receives the resource descriptor and displays the information to the user.
The resource descriptor contains various types of information about the user or resource, such as their name, profile picture, and links to their social media accounts or other online resources. It can also include other types of information, such as the user’s public key, which can be used to establish a secure connection with the user.
There’s a great explainer here as well. From that page:
When someone searches for you on Mastodon, your server will be queried for accounts using an endpoint that looks like this:
GET https://${MASTODON_DOMAIN}/.well-known/webfinger?resource=acct:${MASTODON_USER}@${MASTODON_DOMAIN}
Note that Mastodon user names start with @ so they are @username@someserver.com. Just like twiter would be @shanselman@twitter.com I can be @shanselman@hanselman.com now!
So perhaps https://www.hanselman.com/.well-known/webfinger?resource=acct:FRED@HANSELMAN.COM
Mine returns
{
"subject":"acct:shanselman@hachyderm.io",
"aliases":
[
"https://hachyderm.io/@shanselman",
"https://hachyderm.io/users/shanselman"
],
"links":
[
{
"rel":"http://webfinger.net/rel/profile-page",
"type":"text/html",
"href":"https://hachyderm.io/@shanselman"
},
{
"rel":"self",
"type":"application/activity+json",
"href":"https://hachyderm.io/users/shanselman"
},
{
"rel":"http://ostatus.org/schema/1.0/subscribe",
"template":"https://hachyderm.io/authorize_interaction?uri={uri}"
}
]
}This file should be returned as a mime type of application/jrd+json
My site is an ASP.NET Razor Pages site, so I just did this in Startup.cs to map that well known URL to a page/route that returns the JSON needed.
services.AddRazorPages().AddRazorPagesOptions(options =>
{
options.Conventions.AddPageRoute("/robotstxt", "/Robots.Txt"); //i did this before, not needed
options.Conventions.AddPageRoute("/webfinger", "/.well-known/webfinger");
options.Conventions.AddPageRoute("/webfinger", "/.well-known/webfinger/{val?}");
});then I made a webfinger.cshtml like this. Note I have to double escape the @@ sites because it’s Razor.
@page
@{
Layout = null;
this.Response.ContentType = "application/jrd+json";
}
{
"subject":"acct:shanselman@hachyderm.io",
"aliases":
[
"https://hachyderm.io/@@shanselman",
"https://hachyderm.io/users/shanselman"
],
"links":
[
{
"rel":"http://webfinger.net/rel/profile-page",
"type":"text/html",
"href":"https://hachyderm.io/@@shanselman"
},
{
"rel":"self",
"type":"application/activity+json",
"href":"https://hachyderm.io/users/shanselman"
},
{
"rel":"http://ostatus.org/schema/1.0/subscribe",
"template":"https://hachyderm.io/authorize_interaction?uri={uri}"
}
]
}This is a static response, but if I was hosting pages for more than one person I’d want to take in the url with the user’s name, and then map it to their aliases and return those correctly.
Even easier, you can just use the JSON file of your own Mastodon server’s webfinger response and SAVE IT as a static json file and copy it to your own server!
As long as your server returns the right JSON from that well known URL then it’ll work.
So this is my template https://hachyderm.io/.well-known/webfinger?resource=acct:shanselman@hachyderm.io from where I’m hosted now.
If you want to get started with Mastodon, start here. https://github.com/joyeusenoelle/GuideToMastodon/ it feels like Twitter circa 2007 except it’s not owned by anyone and is based on web standards like ActivityPub.
Hope this helps!
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
-
-
Python For Loop | Docs With Examples
Python For Loop | Docs With Examples
Source link -
6.37 Million Google Clicks! 🤑
Yesterday Online PNG Tools smashed through 6.36M Google clicks and today it’s smashed through 6.37M Google clicks! That’s 10,000 new clicks in a single day – the smash train keeps on rollin’!
What Are Online PNG Tools?
Online PNG Tools offers a collection of easy-to-use web apps that help you work with PNG images right in your browser. It’s like a Swiss Army Knife for anything PNG-related. On this site, you can create transparent PNGs, edit icons, clean up logos, crop stamps, change colors of signatures, and customize stickers – there’s a tool for it all. The best part is that you don’t need to install anything or be a graphic designer. All tools are made for regular people who just want to get stuff done with their images. No sign-ups, no downloads – just quick and easy PNG editing tools.
Who Created Online PNG Tools?
Online PNG Tools were created by me and my team at Browserling. We’ve build simple, browser-based tools that anyone can use without needing to download or install anything. Along with PNG tools, we also work on cross-browser testing to help developers make sure their websites work great on all web browsers. Our mission is to make online tools that are fast, easy to use, and that are helpful for everyday tasks like editing icons, logos, and signatures.
Who Uses Online PNG Tools?
Online PNG Tools and Browserling are used by everyone – from casual users to professionals and even Fortune 100 companies. Casual users often use them to make memes, edit profile pictures, or remove backgrounds. Professionals use them to clean up logos, design icons, or prepare images for websites and apps.
Smash too and see you tomorrow at 6.38M clicks! 📈
PS. Use coupon code
SMASHLING
for a 30% discount on these tools at onlinePNGtools.com/pricing. 💸 -
Python Split() Method | Docs With Examples
Python Split() Method | Docs With Examples
Source link -
3 Simple Tips to Help Your Roofing Business Take Off
In the competitive world of roofing, establishing a successful business can be challenging. As a roofer, you must differentiate yourself from the competition while ensuring customer satisfaction. In this article, we’ll explore three simple yet effective tips that can help take your roofing business to heights you never imagined. These strategies can pave the way for growth, increased visibility, and customer loyalty, ultimately boosting your bottom line. Read on to discover how investing in marketing, building business connections, and offering unique services can make all the difference in propelling your roofing enterprise forward.
Invest In Marketing
Investing in marketing is a crucial step in expanding the reach of your roofing business. By utilizing digital marketing strategies such as social media advertising and search engine optimization, you can effectively target potential customers searching for roofing services. This investment will not only increase your visibility but also establish your brand as a trusted name within the roofing industry.
Traditional marketing methods, including direct mail campaigns and local community sponsorships, can also play a significant role in attracting new clients. As asphalt shingle roofs typically last between 15 to 30 years, homeowners will frequently require roof replacement or repairs during this timeframe. By maintaining a consistent presence in your community, you’ll ensure that your business is top of mind when these needs arise.
Another key aspect of marketing is leveraging customer testimonials and reviews, which can build trust and credibility. Showcasing positive feedback from satisfied clients on your website and social media channels can greatly influence potential customers’ decisions. This trustworthiness will set your business apart from competitors who fail to prioritize customer satisfaction and engagement, making your marketing efforts even more rewarding.
Make Business Connections
Building strong business connections is essential for the growth and success of your roofing enterprise. Networking with other local businesses and joining industry associations can provide valuable opportunities for collaborations and referrals. By creating partnerships with businesses such as real estate agencies and home improvement stores, you can expand your customer base and increase your workload.
Attending industry events and trade shows is another effective method for networking and making connections. It also allows you to stay up to date with industry trends and innovations, keeping your services competitive. Given that 33% of homeowners replace their roofs due to storm damage, collaborating with insurance companies can provide a steady stream of business during inclement weather seasons.
Moreover, fostering relationships with suppliers can yield significant benefits for your roofing business. By negotiating bulk purchasing and discounts, you can reduce costs and improve your profit margins. Strong supplier relationships also ensure you receive quality materials promptly, allowing you to maintain the high standards that will earn your customers’ trust and repeat business.
Offer Unique Services
To stand out in the crowded roofing market, offering unique, innovative services can differentiate your business from competitors. Specializing in green roofing solutions or energy-efficient installations such as thermal insulation can attract environmentally conscious clients. Offering consultations and personalized solutions demonstrates a commitment to customer needs and expectations.
Incorporating solar panel installation into your services can significantly boost your business, given the growing interest in renewable energy. According to the Solar Energy Industries Association, 97% of all solar installations in the United States are on residential rooftops, presenting a lucrative opportunity for roofing businesses. By training your team in solar technology, you can offer an additional service that aligns with current sustainability trends.
Providing comprehensive service packages, including regular maintenance and emergency repairs, ensures you meet a wide range of customer needs. These all-inclusive offerings create a seamless experience for homeowners and foster long-term relationships. A robust service menu demonstrates your roofing business’s versatility and commitment to excellence, securing a loyal client base.
Adopting effective marketing strategies, forging valuable business connections, and offering unique services can significantly boost your roofing business. These measures will not only increase your visibility and attract new clients but also create a strong foundation for long-term success. By embracing innovation and prioritizing customer satisfaction, you can ensure your business thrives in a competitive market. Start implementing these simple yet powerful strategies today and watch your roofing business reach new heights. Remember, the key to success lies in your commitment to growth, quality, and exceptional service.
-
GitHub Copilot for CLI for PowerShell
GitHub Next has this cool project that is basically Copilot for the CLI (command line interface). You can sign up for their waitlist at the Copilot for CLI site.
Copilot for CLI provides three shell commands:
??
,git?
andgh?
This is cool and all, but I use PowerShell. Turns out these ?? commands are just router commands to a larger EXE called github-copilot-cli. So if you go “?? something” you’re really going “github-copilot-cli what-the-shell something.”
So this means I should be able to to do the same/similar aliases for my PowerShell prompt AND change the injected prompt (look at me I’m a prompt engineer) to add ‘use powershell to.’
Now it’s not perfect, but hopefully it will make the point to the Copilot CLI team that PowerShell needs love also.
Here are my aliases. Feel free to suggest if these suck. Note the addition of “user powershell to” for the ?? one. I may make a ?? and a p? where one does bash and one does PowerShell. I could also have it use wsl.exe and shell out to bash. Lots of possibilities.
function ?? {
$TmpFile = New-TemporaryFile
github-copilot-cli what-the-shell ('use powershell to ' + $args) --shellout $TmpFile
if ([System.IO.File]::Exists($TmpFile)) {
$TmpFileContents = Get-Content $TmpFile
if ($TmpFileContents -ne $nill) {
Invoke-Expression $TmpFileContents
Remove-Item $TmpFile
}
}
}function git? {
$TmpFile = New-TemporaryFile
github-copilot-cli git-assist $args --shellout $TmpFile
if ([System.IO.File]::Exists($TmpFile)) {
$TmpFileContents = Get-Content $TmpFile
if ($TmpFileContents -ne $nill) {
Invoke-Expression $TmpFileContents
Remove-Item $TmpFile
}
}
}
function gh? {
$TmpFile = New-TemporaryFile
github-copilot-cli gh-assist $args --shellout $TmpFile
if ([System.IO.File]::Exists($TmpFile)) {
$TmpFileContents = Get-Content $TmpFile
if ($TmpFileContents -ne $nill) {
Invoke-Expression $TmpFileContents
Remove-Item $TmpFile
}
}
}It also then offers to run the command. Very smooth.
Hope you like it. Lots of fun stuff happening in this space.
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
-
Python Sleep() Method | Docs With Examples
Python Sleep() Method | Docs With Examples
Source link