gomal tao
Shared posts
Högre rörelsevinst Àn vÀntat för Ericsson
7 Best Tools For Developers - They Can't Live Without It
 The best tools for developers are a priority for them to work. As a developer, he always works with code editors, browsers, terminals, etc. to improve his productivity. VS Code is one of the best editors, every developer would like to work with it. I've also listed the VS Code extensions for JS that are useful for a developer. And browser extensions are also a great way to improve productivity and I've also listed Chrome extensions for a developer.
If you are a junior programmer, this will give you an idea the improve your coding skills, and if you are a senior developer, you are still learn something new from it. Extensions are one the best tools for developers.
Let's see the best tools for developers.
Read More: 7 Best Tools For Developers - They Can't Live Without It
Integrating Azure Speech Service with LUIS(Language Understanding Service)
5 EXACT alternatives of VSCode!
At the end of the day, Visual Studio Code(or VSC) is a text editor just like notepad or atom or something else. But what makes VSCode special than others? Not sure about you, for me it is...
- Extensibility
- Lightweight
- Customization
- Debugger đ
- Ease of use
makes the difference. Although I haven't used some different text editors other then Vim, I am pretty sure I will get somewhat disappointed if I use some other text editors other than VSCode. I know those text editors also have something great to offer, but for me, VSCode is the best. However, someone said
Varieties are the spice of life
So, if you wanna try something else but still want the flavor of good old(not too much old though) VSCode then here is a list of 5 EXACT alternatives for Visual Studio Code.
1. Visual Studio
Do you know that Visual Studio Code was inspired from Visual Studio?
Though Visual Studio is not as light-weight(because it's an IDE, not a code editor) as VSC, you still have the major features like Extensibility, Debugging, Ease of use. And if you are up to the following stuff, Visual Studio is just for you.
- Game development
- Mobile app development with unity
- Desktop app development with C++
- .NET development
- Linux development with C++
- ...
In a nutshell, if you are up to any kind of development with C++, you must try out Visual Studio.
Ow, I forgot the mention, you can use almost all the extensions that you use with VSCode!!
2. Visual Studio Code Insiders
If you like to stay up to date all the time then Visual Studio Code Insiders is just for you. VSC Insiders and VSC are almost the same. But the insiders version is updated quite frequently(I generally receive 5 updates per week). If you want to try out all the latest features of Visual Studio Code, then don't forget to try out Visual Studio Code Insiders.
And, don't even worry about the instability issue. I am using insiders daily never faced any issue with it. It feels EXACTLY like VSCode.
FYI: I am writing this blog in VSC Insiders
3 Visual Studio Codium
Open source version of VSCode.
Wait! Isn't VSCode open source itself? Here is what folks from Microsoft have to say.
When we [Microsoft] build Visual Studio Code, we do exactly this. We clone the vscode repository, we lay down a customized product.json that has Microsoft specific functionality (telemetry, gallery, logo, etc.), and then produce a build that we release under our license. When you clone and build from the vscode repo, none of these endpoints are configured in the default product.json. Therefore, you generate a âcleanâ build, without the Microsoft customizations, which is by default licensed under the MIT license
That means the Visual Studio Code you use isn't baked from the official GitHub repo although, technically it's the same repo with some small changes.
VSCodium does all the things for you to turn the main VSCode repo into binary so that you can use it without any problem.
If you don't want people to track your data
Visual Studio Code collects telemetry data, which is used to help understand how to improve the product. For example, this usage data helps to debug issues, such as slow start-up times, and to prioritize new features.
Consider using Visual Studio Codium
The VSCodium project exists so that you donât have to download+build from the source. This project includes special build scripts that clone Microsoftâs vscode repo, run the build commands, and upload the resulting binaries for you to GitHub releases. These binaries are licensed under the MIT license. Telemetry is disabled.
That means you are getting the original Visual Studio Code in your machine. So, if you want the real experience of open source Visual Studio Code then this is for you.
4 Visual Studio Codespaces(PAID)
Can you run VSCode on your mobile phone? Certainly not. However, if you want to keep coding even when you are on the run, you will prefer something lightweight. Most of the time, it's a laptop. But in the worst-case scenario, you will need something lighter than a laptop. And you guessed it right. It's a mobile phone.
Visual Studio Codespaces is an online version of VSCode. Alternatively, it's a web app of VSCode. But why should you use VSCodespaces instead of VSCode? There is no strong reason behind it. đ
Here are a few reasons that might change your mind to use VSCodespaces.
- Cross-platform(shall I say cross-device? đ ) development
- Remote workflow
- Collaborative development
However, there is a catch. You will need to pay for this.
Here is how it works
You host an environment on the cloud and then access it via Codespaces. Let's say, you will use Azure for hosting the app. And you will host a standard environment that will have the following specs.
- 4 Cores CPU
- RAM of 8GB
- 64 GB SSD storage
It will cost you about $0.169 per hour. Not that expensive.
5 Eclipse Theia
If you like the idea of VSCode as a web app but don't have the money to spare, then you should consider trying out Eclipse Theia.
Eclipse Theia follows the same concept as Codespaces, a web app. The main difference is the company(and the money). Here is what Eclipse has to say.
We believe VS Code is an excellent product. That is why Theia embraces many of the design decisions and even directly supports VS Code extensions.
Theia versus VS Code
- Theia's architecture is more modular and allows for way more customizations,
- Theia is designed from the ground to run on Desktop and Cloud, and
- Theia is developed under a vendor-neutral Open-Source Foundation.
This is it. I use the VSCode Insiders version in my day to day operation. It has never disappointed me. Let me know in the comment section which one you liked the most.
Until next time, happy coding for you. đ
Becoming a Technical Fellow at Headspring, and New Beginnings
Problem with Winforms timer
Hey :3
I'm currently writing a playbar control for music or videos, and in the background it is using a System.Windows.Forms.Timer which ticks every interval (default is 50 milliseconds) to redraw the control. When the current position is greater or equals the total duration that is set for the control, it should finish (and raise the Finished event). The duration and current position are represented by System.TimeSpan. But there is a problem: Somehow when setting the duration to 20 seconds, as an example, the playbar is finished after around 25 seconds (as determined by a System.Diagnostics.Stopwatch). I feel like it's a performance problem because it becomes better the higher the interval is.
This is my timer.Tick event handler:
private void OnTimerTick(object sender, EventArgs e) { CurrentPosition = CurrentPosition + TimeSpan.FromMilliseconds(timer.Interval); if (CurrentPosition >= Duration) { timer.Enabled = false; Finished?.Invoke(this, EventArgs.Empty); Running = false; return; } Invalidate(); }
I don't know if this code snippet is enough to answer the question. If you need more information, feel free to ask. This is the whole code: https://pastebin.com/C6NMATw6
Thanks in advance.
[link] [comments]
The Case for Comma-Leading Lists
Introduction
Comma-leading lists are an objectively better presentation style.
They make logical sense; the next value on the list is dependant on the comma, and so, they should be kept together.
The style may look alien at first, but give it a test drive and you'll be surprised at how quickly it starts to look normal.
For now, let's have a look at the benefits.
Justification
1. No Merge Conflicts
When adding a new value to a list with trailing commas, you're making 2 additions and 1 deletion.
This will give you a merge conflict just because someone else adds a value on a different branch.
By using the comma-leading style, you make 1 addition and 0 deletions.
These commits play ball with each other, without needing any conflict resolution.
"Ah, but I've used a dangling comma," you say? Allow me to continue.
2. Dangling Commas Bad
It's true that using a trailing comma after the final value will prevent conflicts, but it's dumb for two reasons.
1. Language Inconsistency
SQL doesn't support them.
The JSON standard and Pre-ES5 JavaScript don't support them.
It's better to stick to a style that works across more languages, especially for a multi-lingual codebase.
2. Redundant Logic
There's not a second element. It's unnecessary context, so why justify it?
And, if an interpreter ever decides to stick a None
in there, good luck.
3. Better Presentation
Separating Context
With the comma-leading style, the logic stays on the left, and the data stays on the right.
This makes it quicker and easier to scan when looking through code.
It will also allow you to quickly identify logic errors, such as missing commas.
Saving Whitespace
When you indent after the opening bracket, you're adding extra columns of whitespace on the left-hand side.
Placing the commas on the left keeps the code neat and narrow. Neat!
Summary
Comma-leading lists are easier for source control, more compatible across languages, and much faster to read since they keep data separate from the list's logic.
Do the world a favour and switch to a better standard of data structure.
animals = [ "ant"
, "bat"
, "cat"
, "dog"
]
What's not to love? đ
Hey, guys! Thank you for reading. I hope that you enjoyed this.
Keep up to date with me:
- DEV: https://dev.to/tao/
- Twitter: https://twitter.com/LloydTao
- GitHub: https://github.com/LloydTao
- LinkedIn: https://www.linkedin.com/in/LloydTao/
Catch you around!
Vendors Update Controls for .NET Core 3.1, Blazor
ASP.NET Core in .NET 5 â sending a request
Sending a request in ASP.NET Core in .NET 5 is a standard operation that can be achieved pretty easily. However, details matter in this case and Iâll show you the best practice available. We will also take a look at some advanced features to get the full scope.
Using a real available API
In this article, I will be using 3rd party free service for fetching weather forecasts â http://weatherstack.com. To be able to use it, just register on their website and you can use it as well. 1000 requests in a month are available for a free account and that should be more than enough to fulfill our needs.
First, letâs have a look at the requests we are going to make. To test the API, Iâm using a Postman app, which is very powerful, yet intuitive. I strongly encourage you to read my article about it here: Postman the right way
Here is how a request to fetch current weather in PoznaĆ looks like:
This is a GET
request to http://api.weatherstack.com/current
with two parameters:
-
access_key
which you get when registering on the website -
query
that can be a city name
The response that we got is a 200 OK
with JSON content.
 To make this request, Iâll create a WeatherStackClient
class.
using Microsoft.Extensions.Logging; using System; using System.Net.Http; using System.Text.Json; using System.Threading.Tasks; namespace PrimeHotel.Web.Clients { public class WeatherStackClient : IWeatherStackClient { private const string AccessKey = "3a1223ae4a4e14277e657f6729cfbdef"; private const string WeatherStackUrl = "http://api.weatherstack.com/current"; private HttpClient _client; private readonly ILogger<WeatherStackClient> _logger; public WeatherStackClient(HttpClient client, ILogger<WeatherStackClient> logger) { _client = client; _logger = logger; } } }
There are a few things to notice here:
-
AccessKey
which is hardcoded for now, but in a real-life API should be moved to configuration -
IWeatherStackClient
interface that is introduced for Dependency Injection support -
HttpClient
class is passed in a constructor. It will be automatically created and maintained by the framework
Now letâs create the logic.
public async Task<WeatherStackResponse> GetCurrentWeather(string city) { try { using var responseStream = await _client.GetStreamAsync(GetWeatherStackUrl(city)); var currentForecast = await JsonSerializer.DeserializeAsync<WeatherStackResponse>(responseStream); return currentForecast; } catch (Exception e) { _logger.LogError(e, $"Something went wrong when calling WeatherStack.com"); return null; } } private string GetWeatherStackUrl(string city) { return WeatherStackUrl + "?" + "access_key=" + AccessKey + "&query=" + city; }
Letâs go through this code and explain whatâs going on:
-
_client.GetStreamAsync
is an asynchronous method that takes a URL an returns a stream. There are more methods, like:GetAsync
,PostAsync
,PutAsync
,PatchAsync
,DeleteAsync
for all CRUD operations. There is alsoGetStringAsync
that serializes a response content to string â just likeGetStreamAsync
does -
GetWeatherStackUrl
is merging a service URL with query parameters, returning a full URL address -
JsonSerializer.DeserializeAsync<WeatherStackResponse>(responseStream)
deserializes a stream and format output as aWeatherStackResponse
class
The WeatherStackResponse
class looks like this:
using System.Text.Json.Serialization; namespace PrimeHotel.Web.Clients { public class WeatherStackResponse { [JsonPropertyName("current")] public Current CurrentWeather { get; set; } public class Current { [JsonPropertyName("temperature")] public int Temperature { get; set; } [JsonPropertyName("weather_descriptions")] public string[] WeatherDescriptions { get; set; } [JsonPropertyName("wind_speed")] public int WindSpeed { get; set; } [JsonPropertyName("pressure")] public int Pressure { get; set; } [JsonPropertyName("humidity")] public int Humidity { get; set; } [JsonPropertyName("feelslike")] public int FeelsLike { get; set; } } } }
Notice that I used JsonPropertyName
attribute to identify what JSON property is each property matching. Here is the structure that we are going to map.
One last thing â we need to register our WeatherStackClient
in a Dependency Injection container. In order to do so, we need to go to Startup
class and add the following line in ConfigureServices
method.
services.AddHttpClient<IWeatherStackClient, WeatherStackClient>();
We are using a dedicated method for registering classes using HttpClient
. Underneath itâs using IHttpClientFactory
that helps to maintain the pooling and lifetime of clients. You have a limited number of HTTP connections that you can maintain on your machine and if you create too much clients each blocking a connection, you will end up failing some of your requests. It also adds a configurable logging experience (via ILogger
) for all requests sent through. All in all, it makes a developerâs life easier and allows you to do some smart stuff too.
Does it work? Yes it does! The response was correctly mapped into my class and I can return it.
Do you wonder what was logged when making this request? Letâs have a quick look.
As I mentioned earlier IHttpClientFactory
also provides a logging mechanism, so that every request is logged. Here you can see that not only address was logged, but also HTTP method and time of execution. This can be pretty useful for debugging.
Adding a retry mechanism
In a micro-services world, every micro-service can have a bad day once in a while. Therefore, we need to have a retry mechanism for services we call and we know that they fail from time to time. In ASP.NET Core for .NET 5 there is a third-party library integrated just that purpose â itâs Polly. Polly is a comprehensive resilience and transient fault-handling library for .NET. It allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner.
For our scenario letâs add a retry mechanism, that will call WeatherStack service and retry 3 times after an initial failure. With Polly, a number of retries and delays between then can be easily set. Letâs have a look at the example â itâs in the Startup method where we configure DI container.
services.AddHttpClient<IWeatherStackClient, WeatherStackClient>() .AddTransientHttpErrorPolicy( p => p.WaitAndRetryAsync(new[] { TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10) }));
With this code we will retry the same request after 1, 5, and 10 seconds delay. There is no additional code needed. Polly will do everything for us. We will see logs that something failed, only after all retries will fail, we will get the exception.
Adding a cancellation token
A cancellation token is a mechanism that can stop the execution of an async call. Letâs say that our request shouldnât take more than 3 seconds, because if it does, we know that something isnât right and there is no point to wait.
To implement that we need to create a cancellation token and provide that when making a call with an HTTP client.
public async Task<WeatherStackResponse> GetCurrentWeatherWithAuth(string city) { try { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(3)); using var responseStream = await _client.GetStreamAsync(GetWeatherStackUrl(city), cancellationTokenSource.Token); var currentForecast = await JsonSerializer.DeserializeAsync<WeatherStackResponse>(responseStream); return currentForecast; } catch (TaskCanceledException ec) { _logger.LogError(ec, $"Call to WeatherStack.com took longer then 3 seconds and had timed out "); return null; } catch (Exception e) { _logger.LogError(e, $"Something went wrong when calling WeatherStack.com"); return null; } }
If the request takes too long, we will receive a TaskCancelledException
, which we can catch and react to it differently, that when getting unexpected exception.
Provide authorization
Basic authorization is definitely the simplest and one of the most popular ones used. The idea is that every request to the specific service needs to be authorized, so that along with our content, we need to send authorization info. With basic authorization, we need to pass a user and password encoded as base64
string and put in a request header. Letâs see how that can be accomplished.Â
private const string ApiKey = "3a1223ae4a4e14277e657f6729cfbdef"; private const string Username = "Mik"; private const string Password = "****"; public WeatherStackClient(HttpClient client, ILogger<WeatherStackClient> logger) { _client = client; _logger = logger; var authToken = Encoding.ASCII.GetBytes($"{Username}:{Password}"); _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue( "Basic", Convert.ToBase64String(authToken)); }
In this way every call from WeatherStackClient
will have authorization info and we do not need to add anything when we make requests. The only place we need to put additional code is a constructor.
Note that authorization is not needed to call weatherstack.com and is added only to show how it can be done.
This article did not cover all of the possibilities of IHttpClientFactory
so if you want to know more, just go to this Microsoft article.
Hope you like this post, all code posted in this article is available at my GitHub account:
https://github.com/mikuam/PrimeHotel
Â
Nhibernate QuerySyntaxException is not mapped from
Article: Understanding Classic Java Garbage Collection
Java Garbage Collection remains a topic of major interest even after 25 years. Many developers are still confused about the fundamentals of the topic, even of the most widely-used implementation (Parallel on Java 8).
By Ben EvansHow JavaScript Works: Web APIs, Callback Queue, and Event Loop
Hello everyone đ, I hope you are doing great.
So, In the previous article, we learned about Google's V8 Engine, Heap Memory, and Call Stack.
In this article, we will learn about Web APIs, Callback Queue, and Event Loop.
đ Web APIs
The Web APIs are provided by the web browser that gives additional functionality to the V8 engine.
The Web API calls are added to the Web API Container from the Call Stack. These Web API calls remain inside the Web API Container until an action is triggered. The action could be a click event or HTTP request, or a timer finishes its set time. Once an action is triggered, a callback function is added to the Callback Queue.
đ§âđ€âđ§ Callback Queue
The Callback Queue is a FIFO data structure.
The Callback Queue stores all the callback functions in the order in which they are added.
â»ïž Event Loop
What happens when you have function calls that take a large amount of time to execute in the Call Stack?
For example
- Executing a for loop from 1 to 10B
- Making a network request
- Doing image processing
Let's take an example.
Synchronous Code Visualization
You may ask why this is a problem? The problem is when the Call Stack has a function to execute, the browser cannot do anything else because it is blocked.
The solution is an asynchronous callback, promises, and async / await.
Let's take an example.
Asynchronous Code Visualization
The Event Loop has only one simple job to do. It looks at the Call Stack and Callback Queue, if the Call Stack is empty, it pushes the first callback function of the Callback Queue to the Call Stack..
I hope now you have a good understanding of how JavaScript works.
In the next article, we will learn how V8 compiles our JavaScript code.
đ Resources
What the heck is the event loop anyway? | Philip Roberts | JSConf EU
Thanks for reading! My name is Bipin Rajbhar; I love helping people to learn new skills đ. You can follow me on Twitter if youâd like to be notified about new articles and resources.
Rust 1.43 stabilizes six APIs and adds minor changes
Rust 1.43 has been released according to schedule. The latest version of the multi-paradigm programming language is a minor release, but that doesnât mean nothing has happened. Letâs take a look at the stabilized APIs and language changes that this version has on board.
The post Rust 1.43 stabilizes six APIs and adds minor changes appeared first on JAXenter.
Object Destructuring In JavaScript
Migrationen splittrar Texas
Beskow lĂ€mnar Swedbank â gĂ„r till DNB
NVIDIA GeForce GTX 1060 6GB Video Card Coming For $249 on July 19th
The NVIDIA GeForce GTX 1060 will be coming on July 19th for as little as $249 from board partners and will feature GeForce GTX 980-level performance! NVIDIA will also be releasing a special limited GeForce GTX 1060 Founders Edition, basically the reference model, that will be available only directly from NVIDIA for $299. The NVIDIA ...more
The post NVIDIA GeForce GTX 1060 6GB Video Card Coming For $249 on July 19th appeared first on Legit Reviews.
Hela VW-ledningen anmÀld för att ha manipulerat aktiekursen
VW-hÀrvan utvidgar sig. PÄ mÄndagen stod det klart att en förundersökning inletts mot förre koncernchefen Martin Winterkorn och ytterligare en medlem i den tidigare koncernledningen. PÄ tisdagen kom avslöjandet att den tyska finansinspektionen anmÀlt hela koncernledningen för att ha manipulerat kursen i samband med avgasskandalen.
Why does the state exist?
Man avrÀttade sin dator med Ätta skott - "Jag Ängrar ingenting"
Efter en blÄskÀrm för mycket fick Lucas Hinch nog och sköt inte mindre Àn Ätta skott i sin Dell.