Is there any LAME C++ wrapper\simplifier (working on Linux Mac and Win from pure code)?

Lame really isn’t difficult to use, although there are a lot of optional configuration functions if you need them. It takes slightly more than 4-5 lines to encode a file, but not much more. Here is a working example I knocked together (just the basic functionality, no error checking): #include <stdio.h> #include <lame/lame.h> int main(void) … Read more

Assigning (instead of defining) a __getitem__ magic method breaks indexing [duplicate]

Special methods (essentially anything with two underscores on each end) have to be defined on the class. The internal lookup procedure for special methods completely skips the instance dict. Among other things, this is so if you do class Foo(object): def __repr__(self): return ‘Foo()’ the __repr__ method you defined is only used for instances of … Read more

Creating simple c++.net wrapper. Step-by-step

http://www.codeproject.com/KB/mcpp/quickcppcli.aspx#A8 This is general direction. You need to create C++/CLI Class Library project, add .NET class to it (StudentWrapper in this sample), create unmanaged class instance as managed class member, and wrap every unmanaged class function. Unmanaged library is added to C++/CLI project using linker dependencies list, and not as reference. In the Project – … Read more

How to decorate all functions of a class without typing it over and over for each method? [duplicate]

Decorate the class with a function that walks through the class’s attributes and decorates callables. This may be the wrong thing to do if you have class variables that may happen to be callable, and will also decorate nested classes (credits to Sven Marnach for pointing this out) but generally it’s a rather clean and … Read more

Is there a way to create an alias to a cmdlet in a way that it only runs if arguments are passed to the alias?

You can’t do it with an alias, because PowerShell aliases can only refer to another command name or path, and can therefore neither include arguments nor custom logic. Therefore you do need a function, but it can be a short and simple one: function which { if ($args.count) { Get-Command @args } else { Throw … Read more