Skip to content

Instantly share code, notes, and snippets.

View Manuel-S's full-sized avatar

Manuel Schweigert Manuel-S

  • Karlsruhe, Germany
View GitHub Profile
@Manuel-S
Manuel-S / AudioFileTagReader.cs
Created December 2, 2021 10:52
Read tags set by windows 10 explorer on audio files using taglib nuget package
/// DISCLAIMER: This is a hacky reverse engineering, I have no idea what the actual syntax is or how it works
/// will probably break in some cases, but so far has worked for a couple hundred different files for me
/// Line 27 is a sanity check for this hack, if you use special characters in your tags it will alert you
using System;
using System.Linq;
using System.Collections.Generic;
using TagLib;
static class AudioFileTagReader
@Manuel-S
Manuel-S / browser bookmark
Created March 15, 2021 21:33
Add this as a bookmark to download an extension from chrome web store
javascript:location.href='https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&prodversion='+(navigator.appVersion.match(/Chrome\/(\S+)/)[1])+'&x=id%'+'3D'+(document.querySelector('a[href^="https://chrome.google.com/webstore/report/"]').pathname.match(/[^\/]+\/*$/)[0])+'%'+'26installsource%'+'3Dondemand%'+'26uc';
@Manuel-S
Manuel-S / Application.exe.config
Created January 16, 2021 19:35
How to inject into any .net application (unless AoT compiled)
<configuration>
<runtime>
<appDomainManagerType value="LauncherPatcher" />
<appDomainManagerAssembly value="LauncherPatcher, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</runtime>
</configuration>
@Manuel-S
Manuel-S / GetTags.cs
Created January 16, 2021 19:31
WIP: Read the windows-tags from audio files using TagLib#
static IEnumerable<string> getCategories(TagLib.File file)
{
var ubox = (List<TagLib.Mpeg4.IsoUserDataBox>)file.GetType().GetProperty("UdtaBoxes", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(file);
return getCategories(ubox);
}
static IEnumerable<string> getCategories(List<TagLib.Mpeg4.IsoUserDataBox> userDataBoxes)
{
foreach (var dbox in userDataBoxes)
foreach (var result in recursiveExplore(dbox))
ls -recurse *.flac | % {ffmpeg -i "$_" -c:a aac -b:a 320k -y -c:v copy "$($_.Directory.FullName + "\" + $_.BaseName).m4a" }
@Manuel-S
Manuel-S / CompiledPropertyAccessor.cs
Created September 3, 2018 15:52 — forked from filipw/CompiledPropertyAccessor.cs
removed unnecessary classes
using System;
using System.Linq.Expressions;
using System.Reflection;
using WebApi.Delta;
namespace Hst.Deals.API.Infrastructure
{
internal class CompiledPropertyAccessor<TEntityType> : PropertyAccessor<TEntityType> where TEntityType : class
{
private Action<TEntityType, object> _setter;
@Manuel-S
Manuel-S / constant-strings.cs
Created March 16, 2018 16:52
A good way to save constant identifier strings in C#
using System;
using System.Runtime.CompilerServices;
public class Program
{
public static readonly string IdString = CallerName();
public static readonly string IdString2 = CallerName();
public static string CallerName([CallerMemberName]string name = default)
=> name;
@Manuel-S
Manuel-S / markdown.tex
Last active June 25, 2018 19:40
Add markdown environment to latex files using pandoc cli
\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
\PassOptionsToPackage{hyphens}{url}
\pdfstringdefDisableCommands{%
\def\\{}%
\def\newline{}%
\def\texttt#1{<#1>}%
}
\newcounter{MarkdownId}
@Manuel-S
Manuel-S / FastChannel.cs
Created March 9, 2018 16:37
Fast Shared Memory Remoting by Joseph Albahari
using System.Threading.Tasks;
using System.IO.MemoryMappedFiles;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
async Task Main()
{
using (var channel = DemoServer())
@Manuel-S
Manuel-S / ParameterizedSql.cs
Created March 4, 2018 15:15
Parameterized Sql
// Copyright 2017 Jon Skeet. All rights reserved. Use of this source code is governed by the Apache License 2.0, as found in the LICENSE.txt file.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using static System.FormattableString;
namespace StringInterpolation
{
class ParameterizedSql