Skip to content

Instantly share code, notes, and snippets.

View DarkStoorM's full-sized avatar

Bartosz Sieprawski DarkStoorM

View GitHub Profile
/*
JavaScript function to check whether if user clicked a specific region
on given element
Example <div>
<style>
#example {
width:500px;
height:500px;
@DarkStoorM
DarkStoorM / ObjectPooler.cs
Last active October 15, 2018 15:26
Unity Simple Object Pooler
/* Based on Unity Tutorials, a bit modified */
using System.Collections.Generic;
using UnityEngine;
public class ObjectPooler : MonoBehaviour {
[Header("DRAG OBJECT PREFAB HERE")]
/// <summary>
/// Main object, that will be pooled.
/// </summary>
[Tooltip("Main object, that will be pooled.")]
@DarkStoorM
DarkStoorM / ExecutionTimeMeasurement.php
Last active July 8, 2021 09:51
measure PHP code execution time
<?php
/*
|--------------------------------------------------------------------------
| Execution Time Measurement
|--------------------------------------------------------------------------
|
| Requires PHP 8
|
| This is a simple execution time measurement class for blocks of code and callables

Disclaimer

This is not a Documentation format. This is a very close transcription of Academind's video: "TypeScript Course for Beginners 2021 - Learn TypeScript from Scratch!", which was a part of my learning process. I highly recommend watching the entire 3 hours course available on Academind's YouTube channel.

This is not a 1:1 transcription (roughly 90:100) - do not rely on these notes as some parts of the video were skipped and it contains some self-interpreted content.

GitHub anchors might not work, sadly ¯_(ツ)_/¯


@DarkStoorM
DarkStoorM / DictionaryExtensions.cs
Created May 16, 2021 23:03
[C#] Merge two Dictionaries together
using System.Collections.Generic;
using System.Linq;
public static class DictionaryExtensions
{
/// <summary>
/// <para />Merges this dictionary with another dictionary
/// <example>
/// <code>
/// Dictionary&lt;string, int&gt; dictionary = dictionary.MergeWith(otherDictionary);
@DarkStoorM
DarkStoorM / laravel-route-separation.md
Last active June 27, 2021 13:48
Laravel Route Separation experiment

Laravel Route Separation

After poking around with route separation, I found this (a bit messy and ugly) way to keep routes in separate files without touching the RouteServiceProvider at all - the only update is to change the web namespace to 'routes/web/main.php' since this will be the definitions file for all routes.

This is more of an experiment, not a recommended way of doing this. You could also do this in RouteServiceProvider in a loop with glob.

First thing to do will be moving routes to a new directory: routes/web, which will only contain main.php and index.php files - main being the definitions file which will register route groups all together .

Let's assume we have a website, where we can edit our profile and change some private account settings. The structure would be something like the example below (not ideally of course, it's just a quick example, no one would structure a page like this):

@DarkStoorM
DarkStoorM / mixins.ts
Last active October 31, 2021 20:45
TypeScript Inject Mixins from multiple classes
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/**
* Applies the implementation of baseConstructors to the derived constructor - injects methods into
* the given class.
*
* @param {{ new (): T }} derivedConstructor Class we want to inject mixins into
* @param {{ new (): unknown }[]} baseConstructors Array of classes we want to take mixins from
*/
export function ApplyMixins<T>(

TypeScript - infer type of second argument based on the first argument inside classes

class Selector<Interface> {
  public where<Key extends keyof Interface>(
    key: keyof Pick<Interface, Key>,
    value: Interface[Key]
  ) {
    // [implementation]
  }

Convert VSCode theme to Visual Studio 2022

You have probably stumbled upon this video, which explains how to convert your favorite VSCode theme to also be usable in Visual Studio 2022. Well, it's not entirely correct, it still applies, but there has to be some clarification.

As the video lacks some information, I will try to make it as easy as possible.

Table of Contents: