Skip to content

Instantly share code, notes, and snippets.

View profesor79's full-sized avatar
:octocat:
creating new.... ideas?

Grzegorz Bernas profesor79

:octocat:
creating new.... ideas?
View GitHub Profile
@profesor79
profesor79 / 2.js
Created March 10, 2023 06:15
nice for human, bad for CPU
public void HumanFriendlyCode(string testString)
{
var dt = $"{DateTime.UtcNow}:MMM-yy";
var period = string.IsNullOrWhiteSpace(testString)
? dt
: $"{dt} {testString}";
}
@profesor79
profesor79 / 3.js
Created March 10, 2023 06:10
format and reduce interpolation
public void EffectiveCode(string testString)
{
var dt = DateTime.UtcNow;
var period = string.IsNullOrWhiteSpace(testString)
? $"{dt:MMM-yy}"
: $"{dt:MMM-yy} {testString}";
}
@profesor79
profesor79 / 1.js
Created March 10, 2023 05:42
lazy brain
public void OriginalCode(string testString)
{
var dt = DateTime.UtcNow;
var period = string.IsNullOrWhiteSpace(testString) ? $"{dt:MMM}-{dt:yy}" : $"{dt:MMM}-{dt:yy} {testString}";
}
@profesor79
profesor79 / 1.js
Last active March 8, 2023 04:35
Don't waste your time for commits
rem a simple commiter every 5 secons
:start
@echo off
timeout 5 > NUL
echo %time%
git add *
git commit -am "%time%"
goto start
@profesor79
profesor79 / 4.js
Last active March 7, 2023 03:23
Zip an LINQ extension
public void Zip()
{
// An int array with 7 elements.
IEnumerable < int > numbers = new []
{
1, 2, 3, 4, 5, 6, 7
};
// A char array with 6 elements.
IEnumerable < char > letters = new []
{
@profesor79
profesor79 / 8.js
Created March 5, 2023 19:35
An actor that works as a buffer collection and bulk reqeuests sender
using Akka.Actor;
using Akka.Event;
using ASimpleApiwithActor;
using System.Text;
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development";
var builder = WebApplication.CreateBuilder(args);
builder.Configuration
.AddJsonFile("appsettings.json")
@profesor79
profesor79 / 5.js
Created March 5, 2023 16:45
An async actor operations and a classic class async as well
using Akka.Actor;
using Akka.Event;
using ASimpleApiwithActor;
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development";
var builder = WebApplication.CreateBuilder(args);
builder.Configuration
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{environment}.json", optional: true)
@profesor79
profesor79 / 4.js
Created March 5, 2023 08:47
Now we have an actor and a class with buffering, Still not perfect. but working as good as possible
using System.Diagnostics;
using Akka.Actor;
using Akka.Cluster.Hosting;
using Akka.Event;
using Akka.Hosting;
using Akka.Routing;
using Akka.Remote.Hosting;
using ASimpleApiwithActor;
using Microsoft.EntityFrameworkCore;
using System.Collections.Concurrent;
@profesor79
profesor79 / 2.js
Last active March 4, 2023 23:59
An code base changes when we switch from text file as a storage to a database. Context classes are out of scope as they are not important
using System.Diagnostics;
using Akka.Actor;
using Akka.Cluster.Hosting;
using Akka.Event;
using Akka.Hosting;
using Akka.Routing;
using Akka.Remote.Hosting;
using ASimpleApiwithActor;
using Microsoft.EntityFrameworkCore;
@profesor79
profesor79 / allinone.js
Last active March 4, 2023 17:30
A class and an actor comparision
using System.Diagnostics;
using Akka.Actor;
using Akka.Cluster.Hosting;
using Akka.Event;
using Akka.Hosting;
using Akka.Remote.Hosting;
using ASimpleApiwithActor;
using Petabridge.Cmd.Cluster;
using Petabridge.Cmd.Cluster.Sharding;
using Petabridge.Cmd.Host;