Skip to content

Instantly share code, notes, and snippets.

@esersahin
esersahin / PasswordManager.cs
Last active January 9, 2024 13:59
Password Manager and Tests
using System;
using System.Security.Cryptography;
using System.Text;
public class PasswordManager
{
public string HashPassword(string password)
{
using (SHA256 sha256 = SHA256.Create())
{
@esersahin
esersahin / Generate Class Create Instance.cs
Created January 17, 2024 13:14
Generate Class Create Instance.cs
using System;
using System.CodeDom.Compiler;
using System.Reflection;
class Program
{
static void Main()
{
string code = "public class Person { public int Id {get; set;} public string UserName {get; set;} }";
@esersahin
esersahin / ConnectionSelectors.cs
Created January 17, 2024 14:01
ConnectionSelectors.cs
do
{
Console.WriteLine("Which database do you want to use? (1 for SQL Server, 2 for PostgreSQL, 3 for Sqlite)");
var readKey = Console.ReadKey();
Console.WriteLine();
Console.WriteLine();
if (readKey.KeyChar == '1')
{
ConnectionStrings.Current = ConnectionStrings.SqlServer;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using TbdFriends.WaterDrinkWater.Data.Contexts;
namespace TbdFriends.WaterDrinkWater.Data.Extensions;
public static class MigrationExtension
{
public static void ApplyMigrations(this IServiceProvider services)
{
@esersahin
esersahin / postgres.sql
Last active March 1, 2024 16:00
schema database access for user
DO $$
DECLARE
user_name text := 'your_username'; -- Değiştirmeniz gereken kullanıcı adı
user_schema text;
BEGIN
-- Kullanıcının bağlandığı semayı al
SELECT current_schemas(true) INTO user_schema;
-- Kullanıcıya şema erişim yetkisi ver
EXECUTE 'GRANT USAGE ON SCHEMA ' || user_schema || ' TO ' || user_name;