Differences between revisions 8 and 71 (spanning 63 versions)
Revision 8 as of 2016-11-16 15:17:44
Size: 2621
Editor: scot
Comment:
Revision 71 as of 2024-08-23 20:37:33
Size: 28595
Editor: scot
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
----

2024-08-23

Today I set up a bunch of static websites with Caddy. One of them did have a few PHP files with it too, so I needed to set that up on Caddy as well. To do that I read this [[https://php.watch/articles/caddy-php|site]], which had a great tutorial.

----

2024-07-23

How do you diff two PDFs for free and in a nice way? As it turns out all you need is diffpdf on linux or WSL2 on Windows 11 is all you need. It provides the two PDFs in one window with the differences highlighted. If you want to create a new PDF with the highlighted differences also check out diff-pdf on github.

----

2024-06-06

"You should think of it (Google) as more of an organism, a living thing. I have said that we should be concerned about what happens when it comes alive, like Skynet. But we made a deal with the governor of California to come and aid us." - Hal Varian, Cheif Economist at Google in 2009 (Arnold Schwarzenegger was the governor then)

Quoted from The signal and the noise by Nate Silver

2024-05-28

Installing [[https://www.blackhatworld.com/seo/android-emulator-as-a-virtual-machine.1486782/|Android on proxmox]].

----

2024-05-13

Windows has a tendency to resume from sleep without the network being connected. The problem solves itself in about 30 seconds which suggests a timeout. I'd really like to know the details, but the following incantation works:
(See: [[https://answers.microsoft.com/en-us/windows/forum/all/slow-connecting-to-internet-on-wake-from-sleep/e6db4504-1ce9-4400-9941-dda6d8a09e9f|here]] for detailes)

{{{
Open Control Panel> Click Hardware and Sound > Click Power Options> then click Choose what the power buttons do > Click Change settings that are currently unavailable> Check Sleep (or uncheck then check it again)

Click Save Changes then restart.
}}}

----

2024-02-26

Wrote a new page on Database Encryption. DatabaseManagementSystems/SqlServerEncryptingDatabases

----

2024-02-04

[[https://www.syncfusion.com/blogs/post/top-10-net-core-libraries-every-web-developers-should-know.aspx|Libraries .NET Core web developers should know.]]

----
Line 4: Line 55:

----

2023-11-2

How do you count the number of changes in two documents?

{{{
diff -y --suppress-common-lines [doc1] [doc2] | grep '^' | wc -l
}}}

----
2023-10-5

Just playing around with pdsh and wrote a quick tutorial to get started: ParallelShell (pdsh)

----
2023-08-04

Just got back from CSCE 2023 and thoroughly enjoyed it. Lots of focus on AI which led me to look at [[https://www.codeproject.com/Articles/5322557/CodeProject-AI-Server-AI-the-easy-way|CodeProject.AI ]]. This may be the way to manage the lab.

 * Recognize objects (mice, keyboards, chairs etc.) to see if something goes missing.
 * Recognize people both operators (to tell when people arrive and leave) and guests (students/faculty/staff) who take objects like chairs.

----

2023-05-24

Do you want to have a SQL Server setup for development, but don't want to have it as a docker on your development machine? I have enough projects going on that I would just as soon have a development SQL Server in a container running on Plex. How hard is that? Easy!!! Make sure you have the pre-requisites (use an Ubuntu 20.04 container) and follow the directions [[https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-linux-ver16&preserve-view=true|here]].

----

2023-02-17

C# has long used indented code inside of the namespace block. But in C# 10, we have the ability to use file scoped namespace. There are a couple of ways to do this. In Visual Studio 2022, you can change this in the options:

Tools, Options, Text Editor (I did a search for this), C#, Code Style - Find Namespace declarations and change it to File scoped = Suggestion (you can make it warning if you like). See: https://stackoverflow.com/questions/69889519/vs-2022-convert-to-file-scoped-namespace-in-all-files

----

2022-11-15

Most/Least regretted majors in college - spoiler: CS is the least regretted major.

https://www.cnbc.com/2022/11/12/the-top-10-most-regretted-college-majors.html

----

2022-09-29
Looking at Screen Cast software again and ran across this recent review of free screen cast software: https://wethegeek.com/best-free-screencast-software-on-windows/

----

2022-08-11
Using an ILogger in a console app? Its a real pain see: [[ILogger]]

----
2022-07-08

I'm working a bit with SQL Server right now and came across [[https://www.guru99.com/sql-server-questions.html|this excellent website]] related to SQL Server and Interview questions

----
2022-04-13

We have some individuals that needed a crash course on git and github. Here are a couple that I appreciated. They'll get you up and running with the main ideas.
 * [[https://www.youtube.com/watch?v=USjZcfj8yxE|Learn Git in 15 Minutes]]
 * [[https://www.youtube.com/watch?v=nhNq2kIvi9s|Learn Github in 20 Minutes]]

Also had a cool Pics website used in our CTF: https://source.unsplash.com/1920x1080/?beach
----
2021-10-03

Today I ran across a funny issue that has plagued me before and I had to resurrect from my brain the solution (quite simple and obvious actually). In installing some software to flash an Atmel device, I ran across an installation error 1327 (Invalid Drive). The offending/missing drive was a mapped network share, that the install for some reason was trying to use as temporary space. But there it was currently mapped in file explorer. Ah-Hah, I say! The installer runs as administrator and the administrator account does not have the mapped drive. So how do you fix it? Well, to start with the installer is looking for a temporary location in places it should not! So either we remove the location from the registry (a difficult task and a lengthy one as it is not obvious which of the myriad of references it is pulling from the registry). OR temporarily give the administrator users a drive letter that it is looking for. The latter is the easiest, fastest and cleanest:

 1. open an Administrator cmd/powershell prompt.
 1. {{{subst X: Y:\[newly created folder]}}} where X is the offending/missing drive and Y is some physical drive on your system with an empty directory that is our [newly created folder].
 1. Run the installer, and wonder of wonders it works now!
 1. After the installation, type: {{{subst /D X:}}} and the drive is gone.
 1. Now we just delete the folder that we mapped to X: and your system is back to where it was with no messy registry editing.

----
2021-09-03

{{attachment:2021-09-03 Top 10 Salaries.png}}

----
2021-06-01

Today, I ran across http://c-nergy.be/blog/?p=16025 it shows how to use active directory to authenticate on Ubuntu 20.10. Very cool.


----
2021-05-27

Today, I was programming some educational software in C# and needed to check the equality of two {{{List<T>}}} objects. Now the normal way to compare two objects (from the very base Object), is to check and see if the two object's references are the same. And that is exactly what {{{List<T>}}} does. Suppose X is a List<T> object. Then {{{X.Equals(obj)}}} only checks the references. Of course that is not what I want to do, I want to check the lists to see if they contain the same values. Now, its pretty simple to override Equals in the objects themselves, but what about {{{List<T>}}}? As it turns, LINQ has an extension method to do this for us: {{{X.SequenceEqual(obj)}}}. So...

{{{#!highlight csharp
using System.Linq;

...


      X.SequenceEqual(obj
}}}

----

2021-02-16

picoCTF is on again this year. See:

 * [[https://picoctf.org/competitions/2021-spring.html|picoCTF compettition site]]
 * [[https://play.picoctf.org/register|Registration for a picoCTF account]]

----
2020-09-20

Just a quick link to talk about writing GUI programs on multiple platforms. Have you heard of .NET MAUI? Take a look [[https://devblogs.microsoft.com/dotnet/introducing-net-multi-platform-app-ui/|here]].

----
2020-03-16
We are on spring break right now and will be doing classes online for the rest of the semester. Of course the largest infection is that of fear. Based on the research that I’ve done on the numbers (not the media hype), the actual COVID-19 death rate is less than the flu and for some variants of the flu, much less. Be careful how you read data. Flu deaths are usually reported as the ratio of confirmed deaths to estimated infections. COVID-19 is being reported in a standard epidemic model for new diseases that measures confirmed deaths to confirmed infections. This value is always higher by orders of magnitude. The second issue has to do with testing. According to the CDC yesterday, they have performed 4069 tests for COVID-19 in the USA. That is a drop in the bucket compared to other countries like South Korea who as of 3/13/2020 had tested in excess of 250,000. Their confirmed deaths to confirmed cases is between 0.6%-0.7% as of yesterday. As I mentioned above, the confirmed rate of deaths to the estimated number of infections is orders of magnitude lower. But if we just used 1 order of magnitude (i.e. divide it by 10 – as in there are likely 10 times more cases than actually confirmed), then that ratio drops to 0.07% whereas, the flu’s estimated death rate is at least .14% which is at least twice as high. And there you have it. Fear is likely to do more damage in the USA than the actual virus.

Now, it is worth saying that I’m usually on the other side of this argument. I wish we did more to combat the flu than we do every year in the USA. But the fear that is being spread is causing economic distress that is unwarranted! What should you do? 1) Keep your head – this is not SARS or some other more deadly virus. 2) Avoid getting sick – after all you don’t want this any more than you would want the flu. 3) Dare I say invest in some stock that has dropped like a rock, it will eventually go back up. 4) What does it mean to keep your head and try not to get sick? Follow the CDC guidelines:
 * Avoid close contact with people who are sick.
 * Stay home when you are sick, except to get medical care. (My addition: If you are sick and need to go to the doctor, let them know you are coming in sick and ask them how you should proceed. They may send you to a special location that can test for COVID-19)
 * Cover your coughs and sneezes with a tissue.
 * Clean frequently touched surfaces and objects daily (e.g., tables, countertops, light switches, door knobs, and cabinet handles) using a regular household detergent and water.
   * If surfaces are dirty, they should be cleaned using a detergent and water prior to disinfection. For disinfection, a list of products with Environmental Protection Agency (EPA)-approved emerging viral pathogens claims, maintained by the American Chemistry Council Center for Biocide Chemistries (CBC), is available at Novel Coronavirus (COVID-19) Fighting Productspdf iconexternal icon. Always follow the manufacturer’s instructions for all cleaning and disinfection products.
 * Wash your hands often with soap and water for at least 20 seconds, especially after going to the bathroom; before eating; and after blowing your nose, coughing, or sneezing. If soap and water are not readily available, use a hand sanitizer that contains at least 60% alcohol. Always wash your hands with soap and water if your hands are visibly dirty.

Finally share the real store with others. Yes COVID-19 is new to the USA, but its not completely new to the world – we have reasonable data on what will happen when we act reasonably (e.g. like South Korea). Be careful – it is a virus and all viruses should be taken seriously. Protect the most vulnerable – elderly and those with diseases already. It is extremely rare for a healthy person who contracts COVID-19 to die from it (people 60 and older account for 80% of the deaths in China). By the way, CNN is reporting 6,500 deaths world wide from COVID-19. In 2018-2019 flu season we saw 56,000 deaths due to the flu world wide. Hmm. Notice also that this epidemic is worst in countries with high density populations and where people regularly ignore the above CDC guidelines.

Do you want to read some positive news about South Korea and the USA – see: [[https://www.npr.org/sections/goatsandsoda/2020/03/13/815441078/south-koreas-drive-through-testing-for-coronavirus-is-fast-and-free]]. And do note that 90% of their healthcare response to this epidemic is private and they are doing a much better job than we are doing! We should learn from that. Let’s not go down the road of government healthcare.

----
2019-06-12

Got a little frustrated with the IoC -> Dependency Injection stuff in ASP.NET core while trying to retrieve configuration settings and use them in the {{{ConfigureServices}}} method. In order to help you following along, here is the JSON:

{{{#!highlight json
{
  "ConnectionStrings": {
    "IdentityServer4Connection": "Server=db.home.scotnpatti.com; Database=AttnClassAppIdentityServer4; User Id= is4qs; Password=ConstraintDB;",
    "AspNetIdentityConnection": "Server=db.home.scotnpatti.com; Database=AttnClassAppAspNetIdentity; User Id= is4qs; Password=ConstraintDB;"

  },
  "UriSettings": {
      "RedirectUris": [ "https://home.scotnpatti.com:5003/callback.html" ],
      "PostLogoutRedirectUris": [ "https://home.scotnpatti.com:5003/index.html" ],
      "AllowedCorsOrigins": [ "https://home.scotnpatti.com:5003" ]
  },
  "Logging": {
    "LogLevel": {
      "Default": "Warning"
    }
  },
  "AllowedHosts": "*"
}
}}}

Here is what I learned.

It seems quite common in the constructor to save off {{{IConfiguration}}} and {{{IHostingEnvironment}}} instances for later use.

{{{#!highlight csharp

...

public IConfiguration Configuration { get; }
public IHostingEnvironment Environmsnet { get; }

...

public Startup(IConfiguration configuration, IHostingEnvironment environment)
{
    Configuration = configuration;
    Environment = environment;
}
}}}

Inside of {{{ConfigureServices}}} (which does exactly what it says) we can configure a service related to our configuration and then use it later using dependency injection. But what if I want to use it here? How do I get the value now? That was the question that really bothered me. The prevailing internet opinion is do it using DI or noway. Almost every documentation page or stack overflow discussion centered around injecting it into a controller. There was even some prickly remarks that you shouldn't do it any other way as that is an anti-pattern.

'''Point 1: {{{ConfigureServices}}} is to configure services not consume them!'''

'''Point 2: I learned the order - Constructor first (no surprise there), {{{ConfigureServices}}} method second and {{{Configure}}} method last.'''

'''Point 3: You can use dependency injection on {{{Startup}}}, the constructor, and on the {{{Configure}}} method, but NOT ON {{{ConfigureServices}}} hence the saving off of the two items in the constructor above.'''

From point #1 above, it becomes a matter of creating a settings object and binding it to a section in appsettings.json. This can be completely accomplished by the following code in {{{ConfigureServices}}}:

{{{#!highlight csharp
...
services.Configure<Uris>((settings) =>
{
    Configuration.GetSection("UriSettings").Bind(settings);
});
...
}}}

Of course the Uris object was defined as a Plain Old C# Object (POCO) with public properties that match the settings I want to use (yes they will match string, string[], etc.). It implements the {{{IUris}}} interface that will be used to access the service. This will become a little clearer in the next example, so stick with me a moment.

Then using the knowledge gained from Points #2 and #3, I injected {{{IUris}}} service into {{{Configure}}} as follows:

{{{#!highlight csharp
private void InitializeDatabase(IApplicationBuilder app, IUris uris)
{
    ...//use uris here somewhere for something
}
}}}

'''Whew, take a deep breath. Because this framework hides so much, what is going on amounts to magic, and as a programmer ''magic is totally unacceptable!''.'''

So here is another way to do it that exposes a bit of the magic to the light of day. Suppose instead that I had done the following in {{{ConfigurationServices}}}:

{{{#!highlight csharp
//This method allows us to create a service that is the Settings Object that we want. It does not rely on the IOptions<...> class. Yahoo!
//1. Loads the section in to an IConfigurationSection
IConfigurationSection sec = Configuration.GetSection("UriSettings");
//2. This translates the section json into the a new object of type Uris
services.Configure<Uris>(sec);
//3. Builds the service provider so that we can use it.
ServiceProvider sp = services.BuildServiceProvider();
//4. Uses the Service provider to get an object of type IOptions whose value is a Uris object built from the appsettings.json.
IOptions<Uris> iop = sp.GetService<IOptions<Uris>>();
//5. Get the Uris object from the iop.Value.
Uris uris = iop.Value;
//6. Registers a service with the Dependency Injection container using the object we retreived as the singleton.
services.AddSingleton<IUris>(uris);
}}}

If I use this code instead, it is clear what is happening.

 1. We get a section {{{sec}}} from appsettings.json.
 1. We configure a new service using {{{sec}}} and the class {{{Uris}}}, based on {{{IUris}}}.
 1. Since we are configuring services, I don't have a service provider here, so we build one.
 1. Now we can actually get the service (which uses the [[https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-2.2|OptionsPattern]] to return our object)
 1. Finally we can actually get the settings object we created.
 1. Optionally we can create a service directly that will return us the actual object instead of the IOptions<IUris> object.

Less magic? Yes, but not the standard way to do this, just much more understandable. AND, I have a reference to the actual object that is the service in the Dependency injection container.

But, you say, I JUST WANTED A VALUE FROM THE CONFIGURATION FILE! Ok, ok, I hear you. So you still need to do the IConfiguration save in the constructor! Then just do the following anywhere you have access to it:

{{{#!highlight csharp
...
string redirectUri = Configuration["UriSettings:RedirectUris"];
...
}}}

----
2019-05-31

Looking at the C# 8 features. See: [[https://mybuild.techcommunity.microsoft.com/sessions/77032?source=sessions#top-anchor&ocid=AID747785&wt.mc_id=CFID0415&MC=Vstudio&MC=CSHARP&MC=MachLearn&MC=.NET&MC=AppDnDTool|The video presentation]] or see [[https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8|the webpage]]

'''Range calculations:''' Syntax gets shorter. Consider the following license plate number and state, that is then separated into two variables, plate and state.

{{{#!highlight csharp
string x = "BVD789-TN";
string plate = x.Substring(0, x.Length - 2);
string state = x.Substring(x.Length - 2);
}}}

can become

{{{#!highlight csharp
string x = "BVD789-TN";
string plate = x[..^3]; //where 0 is assumed
string state = x[^2..]; //where length is assumed
}}}

'''Property pattern:''' allows you to use switch more easily. Consider the following

{{{#!highlight csharp
switch(vehicle)
{
   case Car c when c.Passenger == 1;
      return 2.00m+0.50m;
   ...
}
}}}

Becomes:

{{{#!highlight csharp
public static decimal CalculateToll(object vehicle)
   => vehicle switch
   {
      Car { Passengers: 0 } => 2.00m+0.50m,
      Car { Passengers: 1 } => 2.00m,
      Car { Passengers: 2 } => 2.00m-0.50m,
      Car _ =>2.00m-1m,

      Taxi { Fares: 0 } => 3.50m + 1.00m,
      ...
      DeliveryTruck t when t.GrossWeightClass > 5000 => 10.00m + 5.00m,
      ...
      _ => throw new ArgumentException(message: "Not a known vehicle type", paramName: nameof(vehicle)
   };
}}}

Or even with nested switch expressions

{{{#!highlight csharp
public static decimal CalculateToll(object vehicle)
   => vehicle switch
   {
      Car c => c.Passengers switch
      {
         0 => 2.00m+0.50m,
         1 => 2.00m,
         2 => 2.00m-0.50m,
         _ => 2.00m-1m, //Note they called the "_" the discard (symbol) which matches any.
      },
      Taxi { Fares: 0 } => 3.50m + 1.00m,
      ...
      DeliveryTruck t when t.GrossWeightClass > 5000 => 10.00m + 5.00m,
      ...
      _ => throw new ArgumentException(message: "Not a known vehicle type", paramName: nameof(...
   };
}}}

'''IAsyncEnumerable is a new type. ''' It allows you to produce and consume realtime data. See the video above at abut 35 Minutes.

{{{#!highlight csharp
private static async Task ChartTollsAsync()
{
   await foreach (var t in TollSystem.GetVehiclesAsync())
   {
      await TollSystem.ChargeTollAsync(t.vehicle, t. time, t.inbound, t.license);
   }
}
}}}

Default implementation in Interfaces. Allow you to have an implementation in an interface. Then you can override the interface and create the implementation, but you don't have to. Interesting.

.Net 4.8 is the last implementation of the .NET framework that will be available. (0:42 in the video). This begs the question what are the different .Net frameworks and what are they for? Where do they belong? Where should I use them?

=== .NET Framework vs. .NET Core vs. .NET Standard ===

 1. Libraries that target .NET Standard will run on any .NET Standard compliant runtime, such as .NET Core, .NET Framework and Mono/Xamarin (smaller surface area, but wider compatibility)
 1. libraries that target .NET Core can only run on the .NET Core runtime.
 1. Libraries that target .NET Framework can only run on Windows.

Ignoring libraries for a moment, the reason that .NET Standard exists is for portability; it defines a set of APIs that .NET platforms agree to implement. Any platform that implements a .NET Standard is compatible with libraries that target that .NET Standard. One of those compatible platforms is .NET Core.

To summarize:

 1. A .Net Core Class Library is built upon the .Net Standard. If you want to implement a library that is portable to the .Net Framework, .Net Core and Xamarin, choose a .Net Standard Library
 1. .Net Core will ultimately implement .Net Standard 2 (as will Xamarin and .Net Framework)
 1. .Net Core, Xamarin and .Net Framework can, therefore, be identified as flavours of .Net Standard

To future-proof your applications for code sharing and reuse , you would rather implement .Net Standard libraries (since portable class libraries are now deprecated).

Sources:

 * https://stackoverflow.com/questions/42939454/what-is-the-difference-between-net-core-and-net-standard-class-library-project for a nice discussion.
 * https://www.davidyardy.com/blog/net-standard-vs-net-core/
 * https://devblogs.microsoft.com/dotnet/introducing-net-standard/

----
2019-02-11

Security: Installed Suricata at home today as part of pfSense. I noticed that (unamed cell company) is using IKEv2 with weak parameters... Hmmm. Turns out it is the Galaxy Note 5 (Android 7.0) that is the instigator of this particular alert. Apparently all email coming from unamed cell company goes through their hosts (even if it is using the outlook app) using outdated VPN connection configurations. The next question would be, is it hackable. Perhaps more later.

----
2019-02-07

I'm playing with Docker Containers. I didn't have a full concept of what it does, so I started [[https://www.youtube.com/watch?v=rfjmeakbeH8|here on youtube]]. This video covers high level concepts related to efficiency, performance and security.

----

2018-12-29

I've been playing around with several things this break and I've been able (amid being sick) to catch up on a bunch of stuff.

 1. I re-created my [[https://www.scotnpatti.com|website]] using [[https://getbootstrap.com/|bootstrap]]. Don't judge to harshly, I just started playing with it. But at least now it will be visible on my phone.
 2. I updated all my infrastructure at home - updated the firewall, got backups running correctly again, updated plex etc.
 3. In an effort to create a dashboard that would monitor the various processes and backups etc, I started playing around with nodejs and express. And what did I find? A new tutorial resource that I think I'm going to love! I highly recommend taking a look at the Mozilla Developer Network tutorials at https://developer.mozilla.org/en-US/

----

2018-01-23

||[[https://www.informationweek.com/devops/programming-languages/10-most-in-demand-programming-languages-of-2018/d/d-id/1330856?elq_mid=82739&elq_cid=19993339&_mc=NL_IWK_EDT_IWK_daily_20180123&cid=NL_IWK_EDT_IWK_daily_20180123&elqTrackId=056bd7f54daf41a0bd6bcdf491c233f6&elq=571f1e18d68e4f6887c01df3a97d07a6&elqaid=82739&elqat=1&elqCampaignId=29477|10 most in demand Prog. Languages for 2018]] ||
|| Java - Pervasive||
|| Python - Web, Scientific Programming and Data Science||
|| Javascript - Web||
|| C++ - "C, C++ and C# will still be the most popular languages in 2018 because they power so much software"||
|| C# - Games, Enterprise, Web ||
|| PHP - Web ||
|| Perl - glue code||
|| Swift - Apple of course, but increasing in popularity ||
|| R - Data mining... ||
|| Rust - Systems language from Mozilla ||

----

2016-11-30

[[http://www.networkcomputing.com/data-centers/why-you-cant-avoid-devops/1513079780?_mc=NL_IWK_EDT_IWK_daily_20161130&cid=NL_IWK_EDT_IWK_daily_20161130&elqTrackId=a475655ac6fe4767bbf35219fef312b1&elq=3617e48bfb214b3c8bf7ce75af33f6a2&elqaid=75153&elqat=1&elqCampaignId=24537|Why you can't avoid DevOps]]

Current Events in CS & IT


2024-08-23

Today I set up a bunch of static websites with Caddy. One of them did have a few PHP files with it too, so I needed to set that up on Caddy as well. To do that I read this site, which had a great tutorial.


2024-07-23

How do you diff two PDFs for free and in a nice way? As it turns out all you need is diffpdf on linux or WSL2 on Windows 11 is all you need. It provides the two PDFs in one window with the differences highlighted. If you want to create a new PDF with the highlighted differences also check out diff-pdf on github.


2024-06-06

"You should think of it (Google) as more of an organism, a living thing. I have said that we should be concerned about what happens when it comes alive, like Skynet. But we made a deal with the governor of California to come and aid us." - Hal Varian, Cheif Economist at Google in 2009 (Arnold Schwarzenegger was the governor then)

Quoted from The signal and the noise by Nate Silver

2024-05-28

Installing Android on proxmox.


2024-05-13

Windows has a tendency to resume from sleep without the network being connected. The problem solves itself in about 30 seconds which suggests a timeout. I'd really like to know the details, but the following incantation works: (See: here for detailes)

Open Control Panel> Click Hardware and Sound > Click Power Options> then click Choose what the power buttons do > Click Change settings that are currently unavailable> Check Sleep (or uncheck then check it again)

Click Save Changes then restart. 


2024-02-26

Wrote a new page on Database Encryption. DatabaseManagementSystems/SqlServerEncryptingDatabases


2024-02-04

Libraries .NET Core web developers should know.


I'll try to update this with events that are relevant for at least a semester or even a year. Some of these will be lists that relate to CS and CSA majors


2023-11-2

How do you count the number of changes in two documents?

diff -y --suppress-common-lines [doc1] [doc2] | grep '^' | wc -l


2023-10-5

Just playing around with pdsh and wrote a quick tutorial to get started: ParallelShell (pdsh)


2023-08-04

Just got back from CSCE 2023 and thoroughly enjoyed it. Lots of focus on AI which led me to look at CodeProject.AI. This may be the way to manage the lab.

  • Recognize objects (mice, keyboards, chairs etc.) to see if something goes missing.
  • Recognize people both operators (to tell when people arrive and leave) and guests (students/faculty/staff) who take objects like chairs.


2023-05-24

Do you want to have a SQL Server setup for development, but don't want to have it as a docker on your development machine? I have enough projects going on that I would just as soon have a development SQL Server in a container running on Plex. How hard is that? Easy!!! Make sure you have the pre-requisites (use an Ubuntu 20.04 container) and follow the directions here.


2023-02-17

C# has long used indented code inside of the namespace block. But in C# 10, we have the ability to use file scoped namespace. There are a couple of ways to do this. In Visual Studio 2022, you can change this in the options:

Tools, Options, Text Editor (I did a search for this), C#, Code Style - Find Namespace declarations and change it to File scoped = Suggestion (you can make it warning if you like). See: https://stackoverflow.com/questions/69889519/vs-2022-convert-to-file-scoped-namespace-in-all-files


2022-11-15

Most/Least regretted majors in college - spoiler: CS is the least regretted major.

https://www.cnbc.com/2022/11/12/the-top-10-most-regretted-college-majors.html


2022-09-29 Looking at Screen Cast software again and ran across this recent review of free screen cast software: https://wethegeek.com/best-free-screencast-software-on-windows/


2022-08-11 Using an ILogger in a console app? Its a real pain see: ILogger


2022-07-08

I'm working a bit with SQL Server right now and came across this excellent website related to SQL Server and Interview questions


2022-04-13

We have some individuals that needed a crash course on git and github. Here are a couple that I appreciated. They'll get you up and running with the main ideas.

Also had a cool Pics website used in our CTF: https://source.unsplash.com/1920x1080/?beach


2021-10-03

Today I ran across a funny issue that has plagued me before and I had to resurrect from my brain the solution (quite simple and obvious actually). In installing some software to flash an Atmel device, I ran across an installation error 1327 (Invalid Drive). The offending/missing drive was a mapped network share, that the install for some reason was trying to use as temporary space. But there it was currently mapped in file explorer. Ah-Hah, I say! The installer runs as administrator and the administrator account does not have the mapped drive. So how do you fix it? Well, to start with the installer is looking for a temporary location in places it should not! So either we remove the location from the registry (a difficult task and a lengthy one as it is not obvious which of the myriad of references it is pulling from the registry). OR temporarily give the administrator users a drive letter that it is looking for. The latter is the easiest, fastest and cleanest:

  1. open an Administrator cmd/powershell prompt.
  2. subst X: Y:\[newly created folder] where X is the offending/missing drive and Y is some physical drive on your system with an empty directory that is our [newly created folder].

  3. Run the installer, and wonder of wonders it works now!
  4. After the installation, type: subst /D X: and the drive is gone.

  5. Now we just delete the folder that we mapped to X: and your system is back to where it was with no messy registry editing.


2021-09-03

2021-09-03 Top 10 Salaries.png


2021-06-01

Today, I ran across http://c-nergy.be/blog/?p=16025 it shows how to use active directory to authenticate on Ubuntu 20.10. Very cool.


2021-05-27

Today, I was programming some educational software in C# and needed to check the equality of two List<T> objects. Now the normal way to compare two objects (from the very base Object), is to check and see if the two object's references are the same. And that is exactly what List<T> does. Suppose X is a List<T> object. Then X.Equals(obj) only checks the references. Of course that is not what I want to do, I want to check the lists to see if they contain the same values. Now, its pretty simple to override Equals in the objects themselves, but what about List<T>? As it turns, LINQ has an extension method to do this for us: X.SequenceEqual(obj). So...

   1 using System.Linq;
   2 
   3 ...
   4 
   5 
   6       X.SequenceEqual(obj


2021-02-16

picoCTF is on again this year. See:


2020-09-20

Just a quick link to talk about writing GUI programs on multiple platforms. Have you heard of .NET MAUI? Take a look here.


2020-03-16 We are on spring break right now and will be doing classes online for the rest of the semester. Of course the largest infection is that of fear. Based on the research that I’ve done on the numbers (not the media hype), the actual COVID-19 death rate is less than the flu and for some variants of the flu, much less. Be careful how you read data. Flu deaths are usually reported as the ratio of confirmed deaths to estimated infections. COVID-19 is being reported in a standard epidemic model for new diseases that measures confirmed deaths to confirmed infections. This value is always higher by orders of magnitude. The second issue has to do with testing. According to the CDC yesterday, they have performed 4069 tests for COVID-19 in the USA. That is a drop in the bucket compared to other countries like South Korea who as of 3/13/2020 had tested in excess of 250,000. Their confirmed deaths to confirmed cases is between 0.6%-0.7% as of yesterday. As I mentioned above, the confirmed rate of deaths to the estimated number of infections is orders of magnitude lower. But if we just used 1 order of magnitude (i.e. divide it by 10 – as in there are likely 10 times more cases than actually confirmed), then that ratio drops to 0.07% whereas, the flu’s estimated death rate is at least .14% which is at least twice as high. And there you have it. Fear is likely to do more damage in the USA than the actual virus.

Now, it is worth saying that I’m usually on the other side of this argument. I wish we did more to combat the flu than we do every year in the USA. But the fear that is being spread is causing economic distress that is unwarranted! What should you do? 1) Keep your head – this is not SARS or some other more deadly virus. 2) Avoid getting sick – after all you don’t want this any more than you would want the flu. 3) Dare I say invest in some stock that has dropped like a rock, it will eventually go back up. 4) What does it mean to keep your head and try not to get sick? Follow the CDC guidelines:

  • Avoid close contact with people who are sick.
  • Stay home when you are sick, except to get medical care. (My addition: If you are sick and need to go to the doctor, let them know you are coming in sick and ask them how you should proceed. They may send you to a special location that can test for COVID-19)
  • Cover your coughs and sneezes with a tissue.
  • Clean frequently touched surfaces and objects daily (e.g., tables, countertops, light switches, door knobs, and cabinet handles) using a regular household detergent and water.
    • If surfaces are dirty, they should be cleaned using a detergent and water prior to disinfection. For disinfection, a list of products with Environmental Protection Agency (EPA)-approved emerging viral pathogens claims, maintained by the American Chemistry Council Center for Biocide Chemistries (CBC), is available at Novel Coronavirus (COVID-19) Fighting Productspdf iconexternal icon. Always follow the manufacturer’s instructions for all cleaning and disinfection products.
  • Wash your hands often with soap and water for at least 20 seconds, especially after going to the bathroom; before eating; and after blowing your nose, coughing, or sneezing. If soap and water are not readily available, use a hand sanitizer that contains at least 60% alcohol. Always wash your hands with soap and water if your hands are visibly dirty.

Finally share the real store with others. Yes COVID-19 is new to the USA, but its not completely new to the world – we have reasonable data on what will happen when we act reasonably (e.g. like South Korea). Be careful – it is a virus and all viruses should be taken seriously. Protect the most vulnerable – elderly and those with diseases already. It is extremely rare for a healthy person who contracts COVID-19 to die from it (people 60 and older account for 80% of the deaths in China). By the way, CNN is reporting 6,500 deaths world wide from COVID-19. In 2018-2019 flu season we saw 56,000 deaths due to the flu world wide. Hmm. Notice also that this epidemic is worst in countries with high density populations and where people regularly ignore the above CDC guidelines.

Do you want to read some positive news about South Korea and the USA – see: https://www.npr.org/sections/goatsandsoda/2020/03/13/815441078/south-koreas-drive-through-testing-for-coronavirus-is-fast-and-free. And do note that 90% of their healthcare response to this epidemic is private and they are doing a much better job than we are doing! We should learn from that. Let’s not go down the road of government healthcare.


2019-06-12

Got a little frustrated with the IoC -> Dependency Injection stuff in ASP.NET core while trying to retrieve configuration settings and use them in the ConfigureServices method. In order to help you following along, here is the JSON:

   1 {
   2   "ConnectionStrings": {
   3     "IdentityServer4Connection": "Server=db.home.scotnpatti.com; Database=AttnClassAppIdentityServer4; User Id= is4qs; Password=ConstraintDB;",
   4     "AspNetIdentityConnection": "Server=db.home.scotnpatti.com; Database=AttnClassAppAspNetIdentity; User Id= is4qs; Password=ConstraintDB;"
   5 
   6   },
   7   "UriSettings": {
   8       "RedirectUris": [ "https://home.scotnpatti.com:5003/callback.html" ],
   9       "PostLogoutRedirectUris": [ "https://home.scotnpatti.com:5003/index.html" ],
  10       "AllowedCorsOrigins": [ "https://home.scotnpatti.com:5003" ]
  11   },
  12   "Logging": {
  13     "LogLevel": {
  14       "Default": "Warning"
  15     }
  16   },
  17   "AllowedHosts": "*"
  18 }

Here is what I learned.

It seems quite common in the constructor to save off IConfiguration and IHostingEnvironment instances for later use.

   1 ...
   2 
   3 public IConfiguration Configuration { get; }
   4 public IHostingEnvironment Environmsnet { get; }
   5 
   6 ...
   7 
   8 public Startup(IConfiguration configuration, IHostingEnvironment environment)
   9 {
  10     Configuration = configuration;
  11     Environment = environment;
  12 }

Inside of ConfigureServices (which does exactly what it says) we can configure a service related to our configuration and then use it later using dependency injection. But what if I want to use it here? How do I get the value now? That was the question that really bothered me. The prevailing internet opinion is do it using DI or noway. Almost every documentation page or stack overflow discussion centered around injecting it into a controller. There was even some prickly remarks that you shouldn't do it any other way as that is an anti-pattern.

Point 1: ConfigureServices is to configure services not consume them!

Point 2: I learned the order - Constructor first (no surprise there), ConfigureServices method second and Configure method last.

Point 3: You can use dependency injection on Startup, the constructor, and on the Configure method, but NOT ON ConfigureServices hence the saving off of the two items in the constructor above.

From point #1 above, it becomes a matter of creating a settings object and binding it to a section in appsettings.json. This can be completely accomplished by the following code in ConfigureServices:

   1 ...
   2 services.Configure<Uris>((settings) =>
   3 {
   4     Configuration.GetSection("UriSettings").Bind(settings);
   5 });
   6 ...

Of course the Uris object was defined as a Plain Old C# Object (POCO) with public properties that match the settings I want to use (yes they will match string, string[], etc.). It implements the IUris interface that will be used to access the service. This will become a little clearer in the next example, so stick with me a moment.

Then using the knowledge gained from Points #2 and #3, I injected IUris service into Configure as follows:

   1 private void InitializeDatabase(IApplicationBuilder app, IUris uris)
   2 {
   3     ...//use uris here somewhere for something
   4 }

Whew, take a deep breath. Because this framework hides so much, what is going on amounts to magic, and as a programmer magic is totally unacceptable!.

So here is another way to do it that exposes a bit of the magic to the light of day. Suppose instead that I had done the following in ConfigurationServices:

   1 //This method allows us to create a service that is the Settings Object that we want. It does not rely on the IOptions<...> class. Yahoo!
   2 //1. Loads the section in to an IConfigurationSection
   3 IConfigurationSection sec = Configuration.GetSection("UriSettings");
   4 //2. This translates the section json into the a new object of type Uris
   5 services.Configure<Uris>(sec);
   6 //3. Builds the service provider so that we can use it.
   7 ServiceProvider sp = services.BuildServiceProvider();
   8 //4. Uses the Service provider to get an object of type IOptions whose value is a Uris object built from the appsettings.json.
   9 IOptions<Uris> iop = sp.GetService<IOptions<Uris>>();
  10 //5. Get the Uris object from the iop.Value.
  11 Uris uris = iop.Value;
  12 //6. Registers a service with the Dependency Injection container using the object we retreived as the singleton. 
  13 services.AddSingleton<IUris>(uris);

If I use this code instead, it is clear what is happening.

  1. We get a section sec from appsettings.json.

  2. We configure a new service using sec and the class Uris, based on IUris.

  3. Since we are configuring services, I don't have a service provider here, so we build one.
  4. Now we can actually get the service (which uses the OptionsPattern to return our object)

  5. Finally we can actually get the settings object we created.
  6. Optionally we can create a service directly that will return us the actual object instead of the IOptions<IUris> object.

Less magic? Yes, but not the standard way to do this, just much more understandable. AND, I have a reference to the actual object that is the service in the Dependency injection container.

But, you say, I JUST WANTED A VALUE FROM THE CONFIGURATION FILE! Ok, ok, I hear you. So you still need to do the IConfiguration save in the constructor! Then just do the following anywhere you have access to it:

   1 ...
   2 string redirectUri = Configuration["UriSettings:RedirectUris"];
   3 ...


2019-05-31

Looking at the C# 8 features. See: The video presentation or see the webpage

Range calculations: Syntax gets shorter. Consider the following license plate number and state, that is then separated into two variables, plate and state.

   1 string x = "BVD789-TN";
   2 string plate = x.Substring(0, x.Length - 2);
   3 string state = x.Substring(x.Length - 2);

can become

   1 string x = "BVD789-TN";
   2 string plate = x[..^3]; //where 0 is assumed
   3 string state = x[^2..]; //where length is assumed
   4 

Property pattern: allows you to use switch more easily. Consider the following

   1 switch(vehicle)
   2 {
   3    case Car c when c.Passenger == 1;
   4       return 2.00m+0.50m;
   5    ...
   6 }

Becomes:

   1 public static decimal CalculateToll(object vehicle)
   2    => vehicle switch
   3    {
   4       Car { Passengers: 0 } => 2.00m+0.50m,
   5       Car { Passengers: 1 } => 2.00m,
   6       Car { Passengers: 2 } => 2.00m-0.50m,
   7       Car _ =>2.00m-1m,
   8 
   9       Taxi { Fares: 0 } => 3.50m + 1.00m,
  10       ...
  11       DeliveryTruck t when t.GrossWeightClass > 5000 => 10.00m + 5.00m,
  12       ...
  13       _ => throw new ArgumentException(message: "Not a known vehicle type", paramName: nameof(vehicle)
  14    };

Or even with nested switch expressions

   1 public static decimal CalculateToll(object vehicle)
   2    => vehicle switch
   3    {
   4       Car c => c.Passengers switch 
   5       { 
   6          0 => 2.00m+0.50m,
   7          1 => 2.00m,
   8          2 => 2.00m-0.50m,
   9          _ => 2.00m-1m, //Note they called the "_" the discard (symbol) which matches any.
  10       },
  11       Taxi { Fares: 0 } => 3.50m + 1.00m,
  12       ...
  13       DeliveryTruck t when t.GrossWeightClass > 5000 => 10.00m + 5.00m,
  14       ...
  15       _ => throw new ArgumentException(message: "Not a known vehicle type", paramName: nameof(...
  16    };

IAsyncEnumerable is a new type. It allows you to produce and consume realtime data. See the video above at abut 35 Minutes.

   1 private static async Task ChartTollsAsync()
   2 {
   3    await foreach (var t in TollSystem.GetVehiclesAsync())
   4    {
   5       await TollSystem.ChargeTollAsync(t.vehicle, t. time, t.inbound, t.license);
   6    }
   7 }

Default implementation in Interfaces. Allow you to have an implementation in an interface. Then you can override the interface and create the implementation, but you don't have to. Interesting.

.Net 4.8 is the last implementation of the .NET framework that will be available. (0:42 in the video). This begs the question what are the different .Net frameworks and what are they for? Where do they belong? Where should I use them?

.NET Framework vs. .NET Core vs. .NET Standard

  1. Libraries that target .NET Standard will run on any .NET Standard compliant runtime, such as .NET Core, .NET Framework and Mono/Xamarin (smaller surface area, but wider compatibility)
  2. libraries that target .NET Core can only run on the .NET Core runtime.
  3. Libraries that target .NET Framework can only run on Windows.

Ignoring libraries for a moment, the reason that .NET Standard exists is for portability; it defines a set of APIs that .NET platforms agree to implement. Any platform that implements a .NET Standard is compatible with libraries that target that .NET Standard. One of those compatible platforms is .NET Core.

To summarize:

  1. A .Net Core Class Library is built upon the .Net Standard. If you want to implement a library that is portable to the .Net Framework, .Net Core and Xamarin, choose a .Net Standard Library
  2. .Net Core will ultimately implement .Net Standard 2 (as will Xamarin and .Net Framework)
  3. .Net Core, Xamarin and .Net Framework can, therefore, be identified as flavours of .Net Standard

To future-proof your applications for code sharing and reuse , you would rather implement .Net Standard libraries (since portable class libraries are now deprecated).

Sources:


2019-02-11

Security: Installed Suricata at home today as part of pfSense. I noticed that (unamed cell company) is using IKEv2 with weak parameters... Hmmm. Turns out it is the Galaxy Note 5 (Android 7.0) that is the instigator of this particular alert. Apparently all email coming from unamed cell company goes through their hosts (even if it is using the outlook app) using outdated VPN connection configurations. The next question would be, is it hackable. Perhaps more later.


2019-02-07

I'm playing with Docker Containers. I didn't have a full concept of what it does, so I started here on youtube. This video covers high level concepts related to efficiency, performance and security.


2018-12-29

I've been playing around with several things this break and I've been able (amid being sick) to catch up on a bunch of stuff.

  1. I re-created my website using bootstrap. Don't judge to harshly, I just started playing with it. But at least now it will be visible on my phone.

  2. I updated all my infrastructure at home - updated the firewall, got backups running correctly again, updated plex etc.
  3. In an effort to create a dashboard that would monitor the various processes and backups etc, I started playing around with nodejs and express. And what did I find? A new tutorial resource that I think I'm going to love! I highly recommend taking a look at the Mozilla Developer Network tutorials at https://developer.mozilla.org/en-US/


2018-01-23

10 most in demand Prog. Languages for 2018

Java - Pervasive

Python - Web, Scientific Programming and Data Science

Javascript - Web

C++ - "C, C++ and C# will still be the most popular languages in 2018 because they power so much software"

C# - Games, Enterprise, Web

PHP - Web

Perl - glue code

Swift - Apple of course, but increasing in popularity

R - Data mining...

Rust - Systems language from Mozilla


2016-11-30

Why you can't avoid DevOps


2016-11-16

10 Tech Jobs Set For Big Pay Raises In 2017


10 Hot Programming Languages to Build Web Apps

10 Programming Languages That Will Keep You Employed

10 Hot Prog. Languages to Build Web Apps (11/14/2016)

10 Prog. Languages that will keep you employed (5/1/2015)

HTML 5.0

Java

CSS

SQL

Javascript

Python

Java

Javascript

PHP

C++

Ruby

C#

ASP.NET (C#)

PHP

Cold Fusion*

Swift

Perl*

GO*

Python

R

*These langauges seem to me to be a bit iffy for the list. Cold Fusion, may be around, but I don't see it much. Perl is aptly described in the article as "the chewing gum and baling wire of programming languages." Go seems trendy, but not popular yet.


Nine Data center tools IT Pros Should Know About

  1. OpenStack

  2. puppet

  3. CloudStack OpenStack derivative now computing with OpenStack.

  4. System Center - Microsoft

  5. OpenNebula aims at simplicity in Data Center Automation.

  6. Eucalyptus For use with AWS style services

  7. CHEF

  8. Ansible Tower is RedHat's cloud management software.

  9. git


CurrentEvents (last edited 2024-11-03 20:48:20 by scot)