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 / 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 / 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
@mfdeveloper
mfdeveloper / CMakeLists.txt
Created May 7, 2020 16:47
Add support to GoogleTest library for unit tests on C++ Cmake projects
# This commands/functions bellow is to allow Cmake C++ projects to use GoogleTest library to TDD (unit tests)
# The package gtest is compatible with built-in CMake targets:
enable_testing()
find_package(GTest CONFIG REQUIRED)
target_link_libraries(main PRIVATE GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)
add_test(AllTestsInMain main)
@mfdeveloper
mfdeveloper / record_ios_simulator.sh
Created April 10, 2020 16:31
Record the IOS Simulator screen using command `xcrun simctl`
# Copy + paste the function below into your
# ~/bash_profile or ~/.zshrc file
#
# Based in links below:
# [](https://www.avanderlee.com/workflow/capture-ios-simulator-video-app-preview/)
# [Error to find simctl](https://stackoverflow.com/questions/29108172/xcrun-unable-to-find-simctl)
## Starts recording the simulator.
recsim() {
echo -n "Use CTRL+C to stop recording";