Skip to content

Instantly share code, notes, and snippets.

View bddckr's full-sized avatar

Christopher-Marcel Esser bddckr

View GitHub Profile
@gpeal
gpeal / ContributesApiCodeGenerator.kt
Last active February 12, 2024 20:10
Anvil Code Generator
package com.tonal.trainer.anvilcompilers
import com.google.auto.service.AutoService
import com.squareup.anvil.annotations.ContributesTo
import com.squareup.anvil.compiler.api.AnvilContext
import com.squareup.anvil.compiler.api.CodeGenerator
import com.squareup.anvil.compiler.api.GeneratedFile
import com.squareup.anvil.compiler.api.createGeneratedFile
import com.squareup.anvil.compiler.internal.asClassName
import com.squareup.anvil.compiler.internal.buildFile
@elizarov
elizarov / ReentrantMutex.kt
Created April 23, 2021 09:59
ReentrantMutex implementation for Kotlin Coroutines
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
@silverl
silverl / download-nuget-licenses.ps1
Last active May 16, 2023 16:51 — forked from haacked/download-nuget-licenses.ps1
A PowerShell script to download your NuGet package licenses as first seen in http://haacked.com/archive/2015/03/28/download-nuget-package-licenses/
Split-Path -parent $dte.Solution.FileName | cd
New-Item -ItemType Directory -Force -Path ".\licenses"
@( Get-Project -All | ? { $_.ProjectName } | % { Get-Package -ProjectName $_.ProjectName } ) | Sort -Unique Id | % { $pkg = $_ ; Try { (New-Object System.Net.WebClient).DownloadFile($pkg.LicenseUrl, (Join-Path (pwd) 'licenses\') + $pkg.Id + ".html") } Catch [system.exception] { Write-Host "Could not download license for $($pkg.Id)" } }
@davidfoster
davidfoster / GpuDetection.cs
Last active May 22, 2020 05:14
GPU Detection and Auto Quality Designation in Unity
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
[InitializeOnLoad]
#endif
@Serivy
Serivy / getfirstitem.targets
Created May 10, 2017 13:52
Gets the first item from an item group.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="GetFirstItem" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<Items ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<FirstItem ParameterType="System.String" Output="true" Required="false" />
</ParameterGroup>
<Task>
<Using Namespace="System.Linq"/>
<Code Type="Fragment" Language="cs">FirstItem = Items.First().ItemSpec;</Code>
@dcolthorp
dcolthorp / Ref.cs
Last active October 5, 2020 18:19
Ref and Store redux-like implementation for c#
public delegate TResult RefFunc<TState, TResult>(ref TState current);
public delegate void RefAction<TState>(ref TState current);
public delegate void RefAction<TState, TEvent>(ref TState state, TEvent action);
namespace Framework
{
public static class RefPublishStrategies
{
@kalineh
kalineh / MeshCombinerHelper.cs
Last active September 11, 2016 00:01
Combine multiple meshes into single mesh
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
[InitializeOnLoad()]
class MeshCombinerHelperTag
{
@kalineh
kalineh / PrefabStatusHelper.cs
Last active September 8, 2016 08:23
Show icon next to items that are prefab root objects.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
[InitializeOnLoad()]
class PrefabStatusHelper
{
@juanarzola
juanarzola / ChangeType.cs
Last active October 6, 2016 08:44
UniRx observable wrappers for Entitas entity and group events
using System;
namespace Entitas {
/** Used in the *AnyChangeObservable methods to observe multiple change types */
[Flags]
public enum ChangeType : short{
Addition = 1 << 0,
Replacement = 1 << 1,
Removal = 1 << 2,
@mzaks
mzaks / Entitas-BT.cs
Last active September 5, 2022 11:55
Sketch for Entitas-CSharp Behaviour Tree implementation
// Based on http://www.gamasutra.com/blogs/ChrisSimpson/20140717/221339/Behavior_trees_for_AI_How_they_work.php
public enum NodeStatus
{
Success, Failure, Running
}
public interface IBehaviorNode
{
NodeStatus Execute(Entity entity);