Skip to content

Instantly share code, notes, and snippets.

@farukcan
farukcan / Notion.cs
Created November 3, 2022 14:41
Fast DotNetCore Notion Integration
using Notion.Client;
namespace NotionQuickBlog.Data
{
public static class Notion
{
public static string? Token => Environment.GetEnvironmentVariable("NOTION_TOKEN");
static NotionInstance? instance;
public static NotionInstance Instance => instance!=null ? instance : (instance=new NotionInstance());
public static NotionClient Client => Instance.client;
@farukcan
farukcan / gist:3631cc0024953b1d4c1e6a5448f36562
Created February 19, 2023 17:46
C# Action, Func and Task
Action : Gets parameters. (x) => {} . Action , Action<int>
Func : Gets parameters and returns value. (x) => y or (a,b) => { return y; } . Func<int,int> . (last generic is return value type)
Task : Gets parameters, works async, may return value. async (x) => {...await y()...} , or async (x) => await y(x). async Task<int>.
@farukcan
farukcan / info.md
Last active February 23, 2023 22:19
Postgres Dotnet Core
  • Auto create Context by Visual Studio. (Connected Services -> Add -> PostgreSQL)
  • Install NuGet package : Microsoft.EntityFrameworkCore
  • Install NuGet package : Npgsql.EntityFrameworkCore.PostgreSQL
  • Add code :
builder.Services.AddDbContext<LocationAppContext>(options =>
    options.UseNpgsql(System.Environment.GetEnvironmentVariable("POSTGRESQL_STRING") ?? throw new InvalidOperationException("Connection string 'LocationAppContext' not found."),
    options => options.EnableRetryOnFailure().SetPostgresVersion(new Version(9, 6))
    ));
@farukcan
farukcan / git.json
Last active February 28, 2023 19:51
Git Commands - Visual Powershell Repository
{
"Name" : "Git Commands",
"Author": "farukcan",
"Website" : "https:/farukcan.net",
"Commands" : [
{
"Name" : "🚀 Initialize folder",
"Scripts" : ["git init"]
},
{
@farukcan
farukcan / package.json
Last active February 28, 2023 19:35
Main Visual PowerShell Package
[
"https://gist.github.com/farukcan/930ae86c1516371cd6e33028a470031d",
"https://gist.github.com/farukcan/ebfe20cef43d119ebef0ad2e5758db1a",
"https://gist.github.com/farukcan/4dbd669a37dc1bc9d7d9df38c85981ca",
"https://gist.github.com/farukcan/06cd5bf587bcdd807f0a9b6d4d7945b2",
"https://gist.github.com/farukcan/54d4f13ac334981d47efe4efc708553c",
"https://gist.github.com/farukcan/390cb44bebef103fbc0779c74abef58e",
"https://gist.github.com/farukcan/65ad160041838b7dea6d57d8f2d78340"
]
@farukcan
farukcan / repo.json
Last active March 28, 2023 15:23
VisualPS Test Dialog Types
{
"Name": "Test & Examples",
"Author": "farukcan",
"Website": "https://farukcan.net",
"Commands": [
{
"Name": "🖹 Text Dialog",
"Scripts": [
"echo \"Your message is {text:Message}\""
]
@farukcan
farukcan / FilesAndFolders.json
Last active February 27, 2023 21:25
Visual Powershell Files and Folders
{
"Name": "Files and Folders",
"Author": "farukcan",
"Website": "https://github.com/farukcan/visualps",
"Commands": [
{
"Name": "🔍📁 List Workspace",
"Scripts": [
"ls"
]
@farukcan
farukcan / restapi.json
Created February 27, 2023 23:10
Visual Powershell - Useful Rest APIs
{
"Name": "Useful Rest APIs",
"Author": "farukcan",
"Website": "https://farukcan.net",
"Commands": [
{
"Name": "Currency Converter",
"Scripts": [
"Invoke-RestMethod \"https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/{text:Currency From (3 character format,lower case)}/{text:Currency To}.json\""
]
@farukcan
farukcan / dotnet.json
Last active February 28, 2023 14:09
Visual Powershell .NET Core Commands
{
"Name": ".NET Core",
"Author": "farukcan",
"Website": "https://farukcan.net",
"Commands": [
{
"Name": "🆕 New Project (with Template)",
"Scripts": [
"dotnet new \"{text:Template (short-name)}\" --name \"{text:Project Name}\" {text:Extra parameters (optional)}"
]
@farukcan
farukcan / chocolatey.json
Last active February 28, 2023 17:50
Visual Powershell - App Installer (Chocolatey)
{
"Name": "App Installer (Chocolatey)",
"Author": "farukcan",
"Website": "https://farukcan.net",
"Commands": [
{
"Name": "⚠️Run Visual PS as administrator",
"Scripts": [
"echo \"This command requires Adminisrator rights. Right click the Visual PS and open as administrator\""
]