Skip to content

Instantly share code, notes, and snippets.

@citizenmatt
citizenmatt / stats.ps1
Last active February 1, 2023 08:50
Unity YAML file stats
# Count of .cs.meta files. Prefab, scene and asset file counts can be inferred from file lists
# Yeah, this is ugly. Don't care, you're only going to run it once
Write-Output "*.cs.meta: $((Get-ChildItem -recurse -filter *.cs.meta).Count)"
# Individual sizes of .unity, .prefab and .asset files
$results = Get-ChildItem -recurse | where {$_.extension -in ".unity", ".prefab", ".asset"} | Select-Object Name, Extension, Length
$results | Sort-Object -Property Extension | Out-Host
# | Out-File $destination
@citizenmatt
citizenmatt / .ideavimrc
Created September 4, 2019 19:23
.ideavimrc file
" See runtime/defaults.vim
" vim 8.0+ adds runtime/defaults.vim that gets loaded if there is no .vimrc
set history=200
set scrolloff=5
set incsearch
set nrformats-=octal
" vim-sensible settings that work in IdeaVim
@citizenmatt
citizenmatt / UdpTest.cs
Created May 20, 2019 18:53
Unity UDP broadcast listener
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Text;
namespace UdpTest
{
internal class Program
@citizenmatt
citizenmatt / grammar.md
Created January 5, 2018 18:47
YAML Grammar
title
YAML Spec

  1. c-printable ::= ...
  2. nb-json ::= #x9 | [#x20-#x10FFFF]
  3. c-byte-order-mark ::= #xFEFF
@citizenmatt
citizenmatt / easyhttp-rx.kt
Created March 25, 2014 10:40
RX + Kotlin
fun get(url: String, headers: Headers = Headers()): Observable<Response> {
//return getWithExplicitClass(url, headers)!!
//return getWithAnonymousClass(url, headers)!!
//return getWithInlineUsingObsoleteSubscribeFunc(url, headers)!!
return getWithFailingInlineFunction(url, headers)!!
}
fun getWithFailingInlineFunction(url: String, headers: Headers = Headers()) : Observable<Response>? {
// This fails. Looks like a bug in Kotlin: http://youtrack.jetbrains.com/issue/KT-4598
@citizenmatt
citizenmatt / Whatever.sln
Last active June 24, 2016 13:58
Sample solution and .xproj file for .net core RC2
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.0.0
MinimumVisualStudioVersion = 10.0.0.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Whatever", "Whatever\Whatever.xproj", "{A2B3B3E1-6D88-4BF8-A709-4F2F3296E21E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@citizenmatt
citizenmatt / cc.cs
Created April 22, 2016 10:58
Cyclomatic Complexity testing
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CyclomaticComplexityTest
{
class Result
{

Keybase proof

I hereby claim:

  • I am citizenmatt on github.
  • I am citizenmatt (https://keybase.io/citizenmatt) on keybase.
  • I have a public key ASAtfaQASdAEkt3Is_SoaicG6Ws2-pcbM_VWR5yFATcx4wo

To claim this, I am signing this object:

@citizenmatt
citizenmatt / deduplicate_references.proj
Created January 19, 2016 11:14
De-duplicate msbuild references
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- For some reason, msbuild will sometimes duplicate all references in @(ReferencePath),
which, given a particularly meaty nuget package (*cough*JetBrains.ReSharper.SDK*cough*),
can overwhelm the command line. This little hack will de-duplicate references to
reduce the pressure, but it's still going to hurt at some point...
I'd really like to figure out why msbuild is duplicating. Given a simple test with
just e.g. nunit, it works as expected. Perhaps it's something to do with the ReSharper
SDK nuget, but I can't see it -->
<PropertyGroup>

ReSharper 8 extensions get automatic loading of settings + annotations from within the package. VS2008+R#8 doesn't support extensions OOB, since extensions are nuget based, and that requires .net 4. VS2008+R#8 can still load plugins, but then they have to manually load settings and annotations. Here are two ways to do it. Which is best?

The first file re-implements the settings and annotations loaders. Annotation loading is dead easy thanks to a simple interface. This can easily be hand written. Settings requires more legwork to add a file to the Extensions layer (provided by ReSharper 8). This would probably be a bit of copy and paste from the plugin devguide.

The second file implements a custom extension provider, in the same way as ReSharper implements the nuget package support. It creates an extension based on the loaded plugin, and publishes it to the system in the same way the nuget implementation publishes nuget package extensions. So the default annotation and settings loaders then ask the extension