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
<!--
Write a WPF program in C#, the main window should be divided into two columns;
The first column contains 7 checkboxes stacked vertically.
the second column has a button named btnImport (labelled 'Import'), and a textbox named tbOutput below the button to write any output messages from the import process.
Bard:: ==>
Sure, here is the WPF program in C# that you requested:
using System;
using System.Windows;
@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 / Entity-Framework-DOTNETCORE-notes.txt
Last active July 22, 2023 16:18
Entity-Framework with DOTNETCORE Scaffolding
I am annoyed as fck there is no point-and-click UI to do this;
Hence these notes as a reminder;
FIRST INSTALL via NuGet in YOUR project (NB: you may have multiple projects in the solution!)
a) 'Microsoft.EntityFrameworkCore.Tools'; choose same Framework version that your project will target;
b) 'Microsoft.EntityFrameworkCore.SqlServer'; choose the PROVIDER you want to use in the Scaffold-DbContext command.
++++++++
0) Open the (Nuget) package manager console: Tools /NuGet PM / PM Console
1) **EXAMPLE**: (all on one line)
@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 / 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 / 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 / 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 / photos-data.json
Created October 9, 2019 01:42
instagram sample data as json
// this is a giant JSON object you have received back from the Instagram API
// Use it for good, solely on the front end, to create a photo gallery widget!
const instagramResponse = {
"meta": {
"code": 200
},
"data": [
{
"attribution": null,