30 days of code : Day 1

https://www.hackerrank.com/domains/tutorials/30-days-of-code
Reviewing and brushing up my c# skills via HackerRank's 30 days of code challenge.

int i = 5;
double d = 5.0;
string s = "TestString";

// Read and save an integer, double, and String to your variables.
int intVar = Convert.ToInt32(Console.ReadLine());
double doubleVar = Convert.ToDouble(Console.ReadLine());
string stringVar = Console.ReadLine();

// Print the sum of both integer variables on a new line.
Console.WriteLine(i + intVar);

// Print the sum of the double variables on a new line.
Console.WriteLine((d + doubleVar).ToString("F1"));

// Concatenate and print the String variables on a new line
// The 's' variable above should be printed first.
string concatString = s + stringVar;
Console.WriteLine(concatString);

c# environment variable testing

I’ve used AWS Secret Manager in the past, but no the free solution of environment variables. Super simple console test I did.

First you have to add your desired environment variable.
And then you could just enter the Env Var and get your results.
You MUST restart Visual Studio in order to reflect any updated environment variables, or you’ll find no output as the value will be null.

    internal class Program
    {
        static void Main(string[] args)
        {
            string GetKey(string key)
            {
                string keyRequest = Environment.GetEnvironmentVariable(key);
                return keyRequest;
            }

            Console.Write("Enter key name: ");
            string envVar = Console.ReadLine();

            Console.Write("The key value is: ");
            Console.WriteLine(GetKey(envVar));
            Console.ReadLine();
        }
    }

Small fixes/updates for NanisuruApp

Fixed a few things on my on-going project NanisuruApp.

Problem#1) To-Do items have the date added and completion date saved in Database as UTC. Stored, retrieved, and displayed as UTC. For a bigger scale app with many users, it is natural to have a user preference saved, and the TimeZone for each specific user kicks in to display the correct time.
I decided to simply hard code this for now, as this is an App used by 2 people…

DateTime adjustedAddedDateTime
{
    get => todoItem.Added.AddHours(9);
    set => todoItem.Added = value;
}

DateTime adjustedCompletedDateTime
{
    get => todoItem.Completed.AddHours(9);
    set => todoItem.Completed = value;
}

Problem#2) When the user adds a link with the To-Do item, if the string is missing http:// or https://, Blazor Uri directs the link to a non-existent location. I thought of messing with the root Uri in the project, but instead I countered this problem by using this code in the razor page.

 @if (!string.IsNullOrEmpty(todoItems.Url))
 {
     @if ((!todoItems.Url.StartsWith("http://", StringComparison.OrdinalIgnoreCase)) && (!todoItems.Url.StartsWith("https://", StringComparison.OrdinalIgnoreCase)))
     {
         modifiedUrl = "http://" + todoItems.Url;
     }
     else
     {
         modifiedUrl = todoItems.Url;
     }
     <a class="text-primary-blue" href="@modifiedUrl" target="_blank">
         <i class="fas fa-link me-3 fa-2x" title="URL"></i>
     </a>
 }

//// Code section
string modifiedUrl;

Guardians of the Galaxy Vol. 3

The hype was real! My anticipations were up there, and the result? What an entertaining movie. I didn’t think this was the last of the series… I had some mixed emotions after finding out. (At least that’s what I read online, last of THIS group’s gathering) There’s just something special when compared to the other Marvel hero movies.
Next movie on the list for this year is probably Mission Impossible.

Nanisuru Webapp updates ウェブアプリ更新

Updated my on-going Blazor Webassembly & Asp.net API to version 2.0 today.
Minor updates that shouldn’t be worthy for a whole step up to 2.0, but 2.1 will have the push notification which is a pretty big deal to me and the app.
– Added auto resizing with image uploading for completed items on the ToDo list.
– Added URL option to reference whatever the action item is.

なにするウェブアプリの更新。一気に2.0にアプデしたけれど、今回のアプデは大した内容ではないけれど、2.1では初めてのプッシュ通知を導入する予定。
今回の更新は:

-画像添付機能を追加 (自動リサイズ後、アップロード)
-URLの貼り付けオプション追加
-編集・完了リストからの画像拡大 (Blazored Modal)
-なにするリストの表示順を上から最新へ変更
-スマホで”まだのリスト”と”完了リスト”のボタンを押すと、文字が黒くなる事象を修正

Focusrite Scarlett 4i4 g3 for loopback

I previously owned a Scarlett 2i2 2nd gen, but I was unsatisfied about the device not having loopback ready options. Instead, I’d have to install some 3rd party virtual rerouting to loopback. This was a pain especially when you want to record Ableton Live, with OBS.
SO, now that I hooked up the new 4i4, recording Ableton Live is an easy task.

ここ数年Focusrite Scarlett 2i2第2世代を使っていたけれど、OBSでAbleton Liveを録画するとき、Loopbackで録音が出来ないため色々ツールをインストールしてやりくりしないといけなかった。Loopbackは4i4第3世代からは標準装備となっていることを知り、さっそくアップグレード。出力・入力の数やLoopbackぐらいの違いしかスペック的にはないけれど、2i2はメルカリで売るとしてアップグレードの価値はあったかな。

Blazor wasm: IBrowser resize file after selection

Today’s progress on my webapp.
Working on adding a feature to attach one image to each complete ToDo item.
This way, you could look back and get a glimpse of your memory be it eating or doing some sort of activity.
I’m setting an upload limit of 16mb because my file storage approach is directly storing into Binary with Mongodb.  MongoDB only supports a max of 16megs per Binary.  You could upload bigger files if you use MongoDB’s GridFS.  Besides, I don’t think a photo taken with your smartphone will exceed 16megs anytime soon.

    public async Task HandleFileSelected(InputFileChangeEventArgs e)
    {
        isDisabled = true;
        selectedFile = e.File;

        // Resize the selected image
        resizedFile = await  selectedFile.RequestImageFileAsync(selectedFile.ContentType, 960, 540);

        // Save updated image to byte
        buffer = new byte[resizedFile.Size];

        // Update resizedFile's stream with buffer
        await resizedFile.OpenReadStream().ReadAsync(buffer);

        // Force UI update
        await InvokeAsync(StateHasChanged);
    }


    async void SaveItem()
    {
        if (selectedFile != null)
        {
            if (selectedFile.Size < maxFileSize)
            {

                var ms = new MemoryStream();
                todoItem.FileName = selectedFile.Name;
                await resizedFile.OpenReadStream(maxAllowedSize: 1024 * 1024 * 16).CopyToAsync(ms);
                todoItem.BinFile = ms.ToArray();
            }
            else
            {
                // Alert if file exceeds the limit
                await Swal.FireAsync("ファイルが大きすぎます(最大16mb)", "");
                return;
            }
        }

Work in progress: Vocal Trance Track


I started working on an original Vocal Trance Track.  This was one of my goals for 2023.  I’ve produced remixes of existing vocal tracks, but no originals.
In order to draft the vocals, I decided to use Miku (Vocaloid4) which I purchased last year.  First time using the vsti, time to get my hands dirty.

4ヶ月ぶり?の曲作りをプログラミングの合間の息抜きで始めた。(息抜きに正直なってないような気もするけど)今までボーカルを使った曲はリミックスだったので、今回は初めて完全オリジナルを作る予定。ボーカリストを雇う前にどんな感じになるのか伝えやすくもするために、初音ミクを初めて使うことに。ボーカロイドの曲も作りたいと思って、去年買っておいたやつを起動。さぁ、どうなることやら。楽しみが半分、そして毎回ミキシングとマスタリングのストレスがな。