Skip to content

Instantly share code, notes, and snippets.

View joe-oli's full-sized avatar
💭
what the flock? no status to report, i am not a facebook junkie.

joe-oli

💭
what the flock? no status to report, i am not a facebook junkie.
View GitHub Profile
@joe-oli
joe-oli / WinService-Bard.cs
Last active July 23, 2023 16:23
Windows Service - via ChatGPT and Bard (needless to say, Bing-Chat is HOPELESS most of the time as at July /2023)
/*
Sure, here is the code for a Windows Service with the Microsoft.Extensions.Hosting.BackgroundService:
*/
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Configuration;
using Microsoft.EntityFrameworkCore;
namespace MyService
{
@joe-oli
joe-oli / default-keyword-in-CSharp.cs
Created July 23, 2023 07:23
Keyword default! in C# 10
//Q: explain the meaning of default in
private DispatcherTimer timer = default!;
/*
Bard::
Sure. The default keyword in the code private DispatcherTimer timer = default!; means that the timer variable will be initialized with the default value for a DispatcherTimer object. In this case, the default value is a DispatcherTimer object that is not running and has a Interval of 0 milliseconds.
The default! syntax is a new feature in C# 10 that allows you to explicitly specify that the default value should be used. This is useful for preventing the compiler from inferring the wrong type for the variable. In this case, the compiler could have inferred that the timer variable is a Nullable<DispatcherTimer> object, but the default! syntax prevents this from happening.
Here is a breakdown of the code:
• private - This keyword specifies that the timer variable is private. This means that it can only be accessed by other members of the class in which it is declared.
@joe-oli
joe-oli / Bard-EntityFramework-2.cs
Last active July 20, 2023 09:54
Ask bard.google.com to design me a schema
/*
Show sample code for MyDbInitializer()
=>
Sure, here is a sample code for MyDbInitializer():
*/
public class MyDbInitializer : DbInitializer
{
public override void Seed(DbContext context)
{
/* how to use the CHECK constraint to enforce the data type and length of the AgentCode column in the Agent table: */
CREATE TABLE [dbo].[Agent](
[AgentID] [int] IDENTITY(1,1) NOT NULL,
[AgentCode] [char](8) NULL,
[Invalid] [bit] NULL,
[ExtSysAgentGuid] [uniqueidentifier] NULL,
[BusinessName] [nvarchar](200) NULL,
...
CONSTRAINT [CHECK_AgentCode] CHECK ([AgentCode] IS NULL OR [AgentCode] LIKE '____-____')
@joe-oli
joe-oli / data-fruits.json
Last active July 16, 2023 07:33
Data - 1) sample of words which are nouns; 2) sample of fruits. NOTE- this gist contains two files.
[
{
"name": "Apple",
"color": "Red",
"taste": "Sweet"
},
{
"name": "Banana",
"color": "Yellow",
"taste": "Sweet"
@joe-oli
joe-oli / Git-Notes-3.txt
Last active March 26, 2024 22:28
Git notes #2
The command to create and checkout a branch with a single step is:
```
git checkout -b <branch_name>
```
Here's a breakdown of the command:
* `git checkout`: This is the command used for switching branches.
* `-b`: This flag tells `git checkout` to create a new branch if it doesn't already exist, **and** switch to the newly created or existing branch.
@joe-oli
joe-oli / WPF.Demo.cs
Created July 14, 2023 04:55
WPF Demo Code
var dialog = new FolderBrowserDialog();
dialog.ShowDialog();
folderpathTB.Text = dialog.SelectedPath;
@joe-oli
joe-oli / recover_sa_pwd
Created May 7, 2023 11:30
Recover SQL Server 'sa' password
#1 Change the DB to single-user mode;
e.g. in SQL Configuration Manager, SQL Server services / <Your Server> / Properties / Startup Parameters
-f (Add, Apply)
RESTART (or stop, start)
#2
C:\Users\Administrator>SQLCMD -H $localhost
1> CREATE LOGIN newSA WITH PASSWORD = 'Pass@123'
2> go
1> ALTER SERVER ROLE sysadmin ADD MEMBER newSA
@joe-oli
joe-oli / Git-Notes.txt
Last active July 17, 2023 02:33
Git notes
List ALL branches
>git branch
LIST branches by wildcard
>git branch --list "122160*"
======================
CLONE A SINGLE BRANCH
======================
@joe-oli
joe-oli / GetNextSeqNbr.sql
Created December 7, 2022 11:56
Get Next Sequence Number
declare @result int
SET @result = (NEXT VALUE FOR dbo.auto_seq)
select @result