PrintScreen on Windows running on MacBook Pro

I haven’t been very successful in capturing screen shots efficiently on Windows running on my MacBookPro, however found a convenient way to get PrintScreen button going. It’s by using on screen keyboard.

The idea is to launch On-Screen Keyboard application in Windows and press PrintScreen button – not optimal (you can anyway trim the image later on) but better than nothing and installing some utility program from internet. I wanted to capture some tool-tips which won’t go very well with Snip – else I would have preferred it over anything else on Windows.

Anyway this is how it looks:

Print Screen on Windows running on MBP

Print Screen on Windows running on MBP

Sharing Options:

screen recording on Mac OS X

Recently I was participating in a training session over the web and wanted to capture the video and audio stream to create training videos for reference material for in house training. Appshare is a very good screen sharing tool, but won’t allow for audio streaming. So I used my google voice number to call in. Thus I had both video and audio streaming on my laptop.

Capturing should be easy now(?), but I hit several snags. First of all, there was this problem where output from speaker would again feedback into mic of laptop and there by creating a hell lot of noise. After trying out enough I realized what I wanted was an aggregate device where I tell system to choose which devices contribute which kind of streams.

Recently I happened to purchase a license to Boom device and must say it’s quite impressive, for others looking for a free sound driver soundflower is good choice. For this post I will stick with Boom.

To create an Aggregate device search for Audio MIDI Setup in spotlight. This is what it looks like for me before creation of aggregate device. At the bottom-left click + button and create a new aggregate device:

Continue reading →

Sharing Options:

C++11 constexpr: computing exp at compile time

While trying out constexpr I was wondering what else can I get compiler to compute. I can pretty much do any integral computation with both C++ Template Metaprogramming and constexpr, but can I do some floating point computations? It appears I can!!

So I set out to compute exp(z), using Taylor series implementation for exp:

//  can't deal with negative powers!!
//
constexpr double pow(double x, int y)
{
    return y == 0 ? 1.0 : x * pow(x, y-1);
}

constexpr int factorial(int x)
{
    return x == 0 ? 1 : x * factorial(x-1);
}

constexpr double exp(double x)
{
    return 1.0 + x + pow(x,2)/factorial(2) + pow(x, 3)/factorial(3)
        + pow(x, 4)/factorial(4) + pow(x, 5)/factorial(5)
        + pow(x,6)/factorial(6) + pow(x, 7)/factorial(7)
    + pow(x, 8)/factorial(8) + pow(x, 9)/factorial(9);
}

int main()
{
    constexpr double exp1 = exp(1.0);
    return 0;
}

In here I have pow function to compute powers of a floating point number, mine is bit limited as it can do integral powers only; factorial is pretty straight forward. exp function function goes to 10 component evaluation. With exp(1) I do see value of 2.7182815255731922 in debug window while cout prints it to be 2.71828. Since this is floating point value I can’t do static_assert.

Now what’s the proof that it was all compile time rather than runtime evaluation, the only way to confirm is to look at what is executed by processor, that’s right assembly:

Continue reading →

Sharing Options:

C++11: polymorphic function objects

C++ supports various styles of programming and functional is one of them, however functions are not first class concept in C++ and static typing makes it almost impossible to mix or interchange callable entities of different types to be bound to same variable or to form a list of such entities based on calling semantics.

Being creative and industrious, we C++ programmers have used/abused various features of language to accomplish this, with either doing away with types completely or (mis)using inheritance and virtual functions to accomplish callbacks or delegates.

Lambdas were supposed to solve some of these problems by making it easier to define functions in-place and provide for capturing the environment, managing lifetime of captured variables defining environment is still onto the programmer though, but they are kind of typeless. Thus the variables to capture lamdas have auto type deduction. All lambdas have is calling semantics and thus the need for polymorphic function objects that don’t care about types, but just the calling semantics. There by being the “one type to rule them all” callable entity.

Continue reading →

Sharing Options:

libcxxabi __dynamic_cast & random strings

While doing some performance profiling I ran into dynamic_cast being one of the hogs. I do know that dynamic_cast does typeid and string comparison on windows and it sucks. However on gcc it seems quite fast (haven’t checked the implementation there), became curious how is it implemented in libcxx in Clang.

Will do a separate post covering my findings soon, this post is about some random strings disassembler showed in XCode, as you can see there are some references to “Adobe Illustrator” and “Adobe Photoshop CS5″, wonder if this is just garbage..

Anyway..

libcxxabi __dynamic_cast disassembly in XCode

libcxxabi __dynamic_cast disassembly in XCode

I think this code snippet from file, makes is quite clear why dynamic_cast can be so slow on Windows (things can become more fun when you have templates – they can generate very long symbol names for types):

// On Windows, typeids are different between DLLs and EXEs, so comparing
// type_info* will work for typeids from the same compiled file but fail
// for typeids from a DLL and an executable. Among other things, exceptions
// are not caught by handlers since can_catch() returns false.
//
// Defining _LIBCXX_DYNAMIC_FALLBACK does not help since can_catch() calls
// is_equal() with use_strcmp=false so the string names are not compared.

#ifdef _WIN32
#include <string.h>
#endif

namespace __cxxabiv1
{

#pragma GCC visibility push(hidden)

#if _LIBCXX_DYNAMIC_FALLBACK

inline
bool
is_equal(const std::type_info* x, const std::type_info* y, bool use_strcmp)
{
    if (!use_strcmp)
        return x == y;
    return strcmp(x->name(), y->name()) == 0;
}

#else  // !_LIBCXX_DYNAMIC_FALLBACK

inline
bool
is_equal(const std::type_info* x, const std::type_info* y, bool)
{
#ifndef _WIN32
    return x == y;
#else
    return (x == y) || (strcmp(x->name(), y->name()) == 0);
#endif
}

Sharing Options: