Skip to content

Instantly share code, notes, and snippets.

View mfdeveloper's full-sized avatar
🕹️
Creating games and mobile apps, every day!

Felipe Michel mfdeveloper

🕹️
Creating games and mobile apps, every day!
View GitHub Profile
@mfdeveloper
mfdeveloper / instance-loader.ts
Created January 6, 2018 16:16
Creating TypeScript Classes Dynamically - Totally based on Steve Fenton solution
/**
* Creates a dynamic instance of a specific class/prototype.
* Minor changes from initial solution shared by **Steve Fenton**
*
* WARNING: This solution don't works on Angular applications,
* using JIT (because the webpack don't compiles classes into window object)
* or AOT (js minification for production build) compilation.
*
* @see https://www.stevefenton.co.uk/2014/07/creating-typescript-classes-dynamically/
*/
@mfdeveloper
mfdeveloper / TaskCompletionSourceDictionary.cs
Created October 27, 2023 19:50 — forked from GeorgeTsiokos/TaskCompletionSourceDictionary.cs
TaskCompletionSourceDictionary - key is generic, value can be any result, with runtime type check to ensure producer and consumer type parity
[DebuggerDisplay("Count = {" + nameof(Count) + "}")]
public sealed class TaskCompletionSourceDictionary
{
private readonly TaskCompletionSourceDictionary<Type> _dictionary = new TaskCompletionSourceDictionary<Type>();
public int Count => _dictionary.Count;
public bool TryGetValue<T>(out TaskCompletionSource<T> taskCompletionSource) =>
_dictionary.TryGetValue(typeof(T), out taskCompletionSource);
@mfdeveloper
mfdeveloper / CancelListener.kt
Last active January 30, 2023 15:53 — forked from kasparsj/CountUpTimer.java
Java pooling: An infinite timer
package com.example.services.timers.listeners
/**
* Functional interface to allow use SOLID [Interface segregation principle](https://en.wikipedia.org/wiki/Interface_segregation_principle)
* from any Java class
*/
fun interface CancelListener {
/**
* "Event" triggered when [android.os.CountDownTimer.cancel] is called
*/
@mfdeveloper
mfdeveloper / StringExtensions.cs
Created May 17, 2022 23:45
Unity: C# string extension to allow use string templates in Unity Editor inspector, like: {gameObject.name}, {transform.parent.name} ...
using System.Collections.Generic;
using UnityEngine;
namespace AudioGame.UnityExtensions
{
public static class StringExtensions
{
public static Dictionary<string, string> BuildTemplateTokens(GameObject gameObject)
@mfdeveloper
mfdeveloper / README.md
Last active April 13, 2022 16:06
Unity: Singleton pattern implementation

Unity: Singleton

Unity Singleton Monobehaviour component, that can be attached to Game Objects. You can use SingletonPersistent to persist the instance among scenes or just Singleton class to use the same instance on the only one scene.

Main use cases

  • Managers that should use the same instance among scripts (e.g GameManager, ScoreManager, InputManager...)
  • When you need use any component that depends of a Game object in the scene (e.g access AudioSource inside of an singleton)
@mfdeveloper
mfdeveloper / .gitignore
Last active May 1, 2021 18:41 — forked from Matheus-Felipe-C/lista de 50 questoes.c
Project for 50 question list resolution with a menu to navigate in between them
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
@mfdeveloper
mfdeveloper / requirements-dev.txt
Created March 11, 2021 16:09
Python: Creating packages using setup.py legacy/old style. Prefer use the PEP 517 most updated style, using setup.cfg + pyproject.toml files
# Install required dependencies from setup.py "install_requires" param
# Reference: https://caremad.io/posts/2013/07/setup-vs-requirement
--index-url https://pypi.python.org/simple/
.
@mfdeveloper
mfdeveloper / README.md
Created March 4, 2021 12:03
Capture the output console stdout/stderr from a c++ shared library to a variable
@mfdeveloper
mfdeveloper / dynamic-method.ts
Last active January 1, 2021 16:58
This is a example of a dynamic class method on Typescript. Until here, is not possible access class properties inside the overrided/new method
/**
* Typescript dynamic class method example
*
* REFERENCES:
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html
* @see https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Mixins.md
* @see http://blog.brillskills.com/2013/09/exploring-javascript-prototypes-via-typescripts-class-pattern
* @see https://github.com/Microsoft/TypeScript/wiki/%27this%27-in-TypeScript
*
* For this example, using IONIC 2/3 Toast component to override a method
@mfdeveloper
mfdeveloper / profile
Created October 26, 2020 09:07
Android: Setup environment variables to compile and run android apps from CLI
# Android
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export JAVA_HOME=$HOME/android-studio/jre
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin
export PATH=$PATH:$JAVA_HOME/bin
# Install Gradle cli with sdkman
# PS: On Android Studio 4.1+, the gradle CLI is not found in the studio folder :(
# See https://sdkman.io/install