khamas
khamas
Explore posts from servers
NNuxt
Created by khamas on 9/2/2024 in #❓・help
Prevent scroll of page in background of a popup
Hey, how do I prevent the div in the background of a modal popup with a higher z-index to scroll when my popup is open? when scrolling/swiping down on the popup on mobile it will lock onto the background and not scroll inside the actual modal
1 replies
CC#
Created by khamas on 3/6/2024 in #help
✅ Creating a datetime with a timezone
How do I create a DateTime with new DateTime(2010, 05, 12); and give it a specific TimeZoneInfo
35 replies
CC#
Created by khamas on 8/4/2023 in #help
❔ how do delay the process exit for a graceful shutdown in a console app?
Hey, I want to delay the app exit by a few seconds, I tried using the following but it's just exiting instantaneously
AppDomain.CurrentDomain.ProcessExit += delegate(object sender, EventArgs eventArgs)
{
GlobalState.CancellationRequested = true;
LogService.EzLogger.LogInfoAsync("[PROCESSOR] Shutting down gracefully", null);
Console.WriteLine("Shutting down...");
Thread.Sleep(TimeSpan.FromSeconds(30));
Console.WriteLine("Finished shutting down...");
};
AppDomain.CurrentDomain.ProcessExit += delegate(object sender, EventArgs eventArgs)
{
GlobalState.CancellationRequested = true;
LogService.EzLogger.LogInfoAsync("[PROCESSOR] Shutting down gracefully", null);
Console.WriteLine("Shutting down...");
Thread.Sleep(TimeSpan.FromSeconds(30));
Console.WriteLine("Finished shutting down...");
};
72 replies
CC#
Created by khamas on 6/28/2023 in #help
❔ blazor wasm host not encoding special characters in response
4 replies
CC#
Created by khamas on 5/18/2023 in #help
❔ MAUI blazor windows handle URI
4 replies
CC#
Created by khamas on 4/28/2023 in #help
✅ referencing `WebApplication` from a class library
Hey so I'm trying to create a middleware library, but I can't install Microsoft.AspNetCore.App.Ref package as it is an internal library, how can I reference WebApplication?
11 replies
CC#
Created by khamas on 4/18/2023 in #help
❔ serilog mongodb not logging extra properties
2 replies
CC#
Created by khamas on 2/12/2023 in #help
❔ publish blazor wasm app as docker image with nginx base
I create a dockerfile, and create a docker publish configuration, but it tells me that I need to enable docker support for my wasm project. Is there a way to modify the .csproj file directly to enable it? thanks
8 replies
CC#
Created by khamas on 12/23/2022 in #help
❔ MAUI Blazor not starting, giving null error
4 replies
CC#
Created by khamas on 12/11/2022 in #help
❔ How to use build directory as working directory in debug
Hey, I have a class library that has a .json file in a sub-directory, it's marked as content and copies to the output folder. I reference this class library project, it builds properly to the selected output directory and the json file is there, but it seems like the working directory for the app that references the library is that of the .csproj, and since the json file is in the other project, when running the app it cannot find the file, how do I say that I want to run the app from the build directory and not project directory? (VS 2022)
4 replies
CC#
Created by khamas on 12/10/2022 in #help
❔ postgres EF core, how to have a custom connection string config file
Hey, I have a net6 class library with a DbContext, I want to have the connection string in a separate custom config file, code below. For some reason, when I do dotnet ef database update, an error pops up:
System.ArgumentException: Couldn't set min pool size (Parameter 'min pool size')
---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. *...*

Couldn't set min pool size (Parameter 'min pool size')
System.ArgumentException: Couldn't set min pool size (Parameter 'min pool size')
---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. *...*

Couldn't set min pool size (Parameter 'min pool size')
My connection string looks like this: User ID=postgres;Password=<PASSWORD>;Host=localhost;Port=5432;Database=NetSendHost;Pooling=true;Min Pool Size=0;Max Pool Size=250;Connection Lifetime=0;
public class Db : DbContext
{
private static readonly string ConnectionString;
static Db()
{
var obj = JsonDocument.Parse(File.ReadAllText("Config/config.json"));
ConnectionString = obj.RootElement.GetProperty("PgSqlConnectionString").GetString();
}

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql(ConnectionString);
}
public DbSet<PrivateServerUser> ServerUsers { get; set; }

}
public class Db : DbContext
{
private static readonly string ConnectionString;
static Db()
{
var obj = JsonDocument.Parse(File.ReadAllText("Config/config.json"));
ConnectionString = obj.RootElement.GetProperty("PgSqlConnectionString").GetString();
}

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql(ConnectionString);
}
public DbSet<PrivateServerUser> ServerUsers { get; set; }

}
15 replies
CC#
Created by khamas on 12/4/2022 in #help
✅ bind prop or field to Entry in MAUI
Hey how do I directly bind a prop or field to an Entry or Label in MAUI? The docs aren’t clear
18 replies
CC#
Created by khamas on 11/16/2022 in #help
❔ httpclient not sending request and no exception is thrown
hey I have an httpclient post request that is just hanging there, no exception thrown or anything, I
24 replies
CC#
Created by khamas on 11/11/2022 in #help
❔ Blazor WASM PWA clear all cache and update application
My app does not update automatically on new versions (I use WASM). Since it's PWA the no-cache header does not do anything... Is there a way with JS to clear all files locally or is the service worker able to update files? if so then how? Thanks
35 replies
CC#
Created by khamas on 10/21/2022 in #help
MAUI Webview target=_blank href redirects not working on android
I have an MAUI app that is essentially a WebView that hosts a wordpress website. My problem is that whenever I try to load an external link it will simply not load the "href" redirect... It works fine on Windows and iOS devices, but not in android. EDIT: The href is a "_blank" target. Is there a specific permission I need in the manifest? In case it helps, here is the code for the page:
<?xml version="1.0" encoding="utf-8" ?>

<Grid BackgroundColor="DarkSlateGrey">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackLayout Grid.Row="0" Grid.Column="0"
Spacing="5" Orientation="Horizontal" Padding="8">
<Button Text="Go Back" TextColor="DarkSlateGray" BackgroundColor="White"/>
<Button Text="Change Language" x:Name="ChangeLangBtn" TextColor="DarkSlateGray" BackgroundColor="White"/>
</StackLayout>
<WebView Grid.Row="1" Grid.Column="0"
Source="https://example.com"
x:Name="WebView"/>
</Grid>
<?xml version="1.0" encoding="utf-8" ?>

<Grid BackgroundColor="DarkSlateGrey">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackLayout Grid.Row="0" Grid.Column="0"
Spacing="5" Orientation="Horizontal" Padding="8">
<Button Text="Go Back" TextColor="DarkSlateGray" BackgroundColor="White"/>
<Button Text="Change Language" x:Name="ChangeLangBtn" TextColor="DarkSlateGray" BackgroundColor="White"/>
</StackLayout>
<WebView Grid.Row="1" Grid.Column="0"
Source="https://example.com"
x:Name="WebView"/>
</Grid>
And here is the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="2" android:versionName="2">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true" android:label="MYAPPNAME"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="2" android:versionName="2">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true" android:label="MYAPPNAME"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
</manifest>
1 replies
CC#
Created by khamas on 10/20/2022 in #help
force 'normal' standards for parsing decimal numbers from string
I want to force my ASP.NET API to parse numbers as '102.28', currently it throws an error because it expects the format with a comma: '102,28'
13 replies
CC#
Created by khamas on 10/11/2022 in #help
Recursively compressing image as webp
long len = image.Length;
using var readStream = image.OpenReadStream();
MemoryStream tmpImageStream = null;
bool firstRun = true;
while (len > maxLen)
{
// !!!! ERROR IS HERE !!!!
using var tmpISImage = SixLabors.ImageSharp.Image.Load(firstRun ? readStream : tmpImageStream, firstRun ? new JpegDecoder() : new WebpDecoder());
var newWidth = (int)Math.Round(tmpISImage.Width / 1.35, 0, MidpointRounding.ToNegativeInfinity);
var newHeight = (int)Math.Round(tmpISImage.Height / 1.35, 0, MidpointRounding.ToNegativeInfinity);
tmpISImage.Mutate(x => x.Resize(newWidth, newHeight));

if (tmpImageStream is null)
{
tmpImageStream = new();
}
else
{
tmpImageStream.Dispose();
tmpImageStream = new();
}

tmpISImage.SaveAsWebp(tmpImageStream);

len = tmpImageStream.Length;

if (firstRun) firstRun = false;
}
}

long len = image.Length;
using var readStream = image.OpenReadStream();
MemoryStream tmpImageStream = null;
bool firstRun = true;
while (len > maxLen)
{
// !!!! ERROR IS HERE !!!!
using var tmpISImage = SixLabors.ImageSharp.Image.Load(firstRun ? readStream : tmpImageStream, firstRun ? new JpegDecoder() : new WebpDecoder());
var newWidth = (int)Math.Round(tmpISImage.Width / 1.35, 0, MidpointRounding.ToNegativeInfinity);
var newHeight = (int)Math.Round(tmpISImage.Height / 1.35, 0, MidpointRounding.ToNegativeInfinity);
tmpISImage.Mutate(x => x.Resize(newWidth, newHeight));

if (tmpImageStream is null)
{
tmpImageStream = new();
}
else
{
tmpImageStream.Dispose();
tmpImageStream = new();
}

tmpISImage.SaveAsWebp(tmpImageStream);

len = tmpImageStream.Length;

if (firstRun) firstRun = false;
}
}

4 replies
CC#
Created by khamas on 10/7/2022 in #help
Getting `Cross Origin Read Blocking` in ASP.NET web API when trying to serve an image
5 replies
CC#
Created by khamas on 8/23/2022 in #help
catching an exception in an async Task [Answered]
I can't seem to catch an exception that is thrown in an async Task, I put try/catch within the async task, when calling the task I put 'ConfigureAwait(true)', and I await it, I also have a catch in the parent method
17 replies