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 / 1.js
Last active February 21, 2023 18:55
code review pain
public List<AShityLongClass> HandleNullValue(List<AShityLongClass> some_Results)
{
if (some_Results[0].P1 == null)
some_Results[0].P1 = 0;
if (some_Results[0].P11 == null)
some_Results[0].P11 = 0;
if (some_Results[0].P12 == null)
some_Results[0].P12 = 0;
if (some_Results[0].P13 == null)
some_Results[0].P13 = 0;
@profesor79
profesor79 / 2.js
Created February 21, 2023 19:06
code review pain killer
public AShityLongClassModel HandleNullValueWithModel(List<AShityLongClass> some_Results)
{
var r = some_Results[0];
var model = new AShityLongClassModel
{
P1 = r.P1.HasValue ? r.P1.Value : 0,
P11 = r.P11.HasValue ? r.P11.Value : 0,
P12 = r.P12.HasValue ? r.P12.Value : 0,
P13 = r.P13.HasValue ? r.P13.Value : 0,
P14 = r.P14.HasValue ? r.P14.Value : 0,
@profesor79
profesor79 / 3.js
Last active February 21, 2023 19:12
code review pain killer
// so we can transform this crap :D
if (some_Results[0].P1 == null)
some_Results[0].P1 = 0;
// to something less aggressive
some_Results[0].P1 = some_Results[0].P1.HasValue ? some_Results[0].P1 : 0;
.
@profesor79
profesor79 / 4.js
Last active February 22, 2023 00:48
code review pain killer
public AShityLongClassModel HandleNullValueWithModel(List<AShityLongClass> some_Results)
{
var result = some_Results[0];
var model = new AShityLongClassModel
{
P1 = result.P1.HasValue ? result.P1.Value : 0,
P11 = result.P11.HasValue ? result.P11.Value : 0,
P12 = result.P12.HasValue ? result.P12.Value : 0,
P13 = result.P13.HasValue ? result.P13.Value : 0,
P14 = result.P14.HasValue ? result.P14.Value : 0,
@profesor79
profesor79 / 5.js
Created February 22, 2023 00:50
code review pain killer
public AShityLongClassModel GetValueOrDefaultWithModel(List<AShityLongClass> some_Results)
{
var r = some_Results[0];
var model = new AShityLongClassModel
{
P1 = r.P1.GetValueOrDefault(),
P11 = r.P11.GetValueOrDefault(),
P12 = r.P12.GetValueOrDefault(),
P13 = r.P13.GetValueOrDefault(),
P14 = r.P14.GetValueOrDefault(),
@profesor79
profesor79 / 1.js
Created February 25, 2023 21:01
bigStorySmallResults
public class Email
{
static string TemplateStart = "Hi,<br/><br/> Click on below given link to Reset Your Password<br/> <a href=";
static string TemplateEnd = ">Click here to change your password</a><br/>";
static string Template = "Hi,<br/><br/> Click on below given link to Reset Your Password<br/> <a href= __callbackUrl__>Click here to change your password</a><br/>";
static string TextToBeReplaced = "__callbackUrl__";
public void Was()
{
@profesor79
profesor79 / 1.js
Created February 26, 2023 08:17
when your mom wants to evict you
public static class LivelinesHelper
{
public static string CGroupMemoryFilePath = "/sys/fs/cgroup/memory/memory.usage_in_bytes";
public static string ReadinesFilePath = "/somePathThatKubeCanAccess/readiness.probe";
public static bool KeepConnection = true;
public static int CheckIntervalMiliSecs = 5000;
public static int MemoryThreshold = 1024 * 1024 * 1024; // 1GB
public static void StartMonitoring()
{
@profesor79
profesor79 / 1.js
Last active February 27, 2023 15:43
Akka.Streams example processing TCP connection
using Akka.Streams.Dsl;
using Akka.IO;
using Tcp = Akka.Streams.Dsl.Tcp;
using Akka.Actor;
using Akka.Streams;
var Sys = ActorSystem.Create("example");
IMaterializer materializer = Sys.Materializer();
Source<Tcp.IncomingConnection, Task<Tcp.ServerBinding>> connections =
Sys.TcpStream().Bind("127.0.0.1", 8888);
@profesor79
profesor79 / 2.js
Created February 27, 2023 18:26
A tcp load for stream testing
void Main()
{
Connect();
}
static void Connect()
{
var client = new TcpClient("localhost", 8888);
var message = @"make it large long big and fat, so the buffer will be filled fast
";
@profesor79
profesor79 / 10xDeveloper.js
Last active February 28, 2023 23:15
secure coding example
public class UCanHave10YearsExperienceCounted1x10_or_10x1
{
public void Shit(string docNumber)
{
int documentNumber = 0;
if (int.TryParse(docNumber, out documentNumber))
{