Friday, October 31, 2014

Two things that make me hate visual studio less

After many years of doing only theory, I joined a large C++ programming project 4 months ago,
working in Microsoft visual studio. The frustration I had from the difficultyof the most basic tasks - e.g. adding a class to the project,  (just use add new Item *don't dare using add class or the class wizard or you'll never see the end of it!*)
lead me to write this facebook post:


 think Microsoft was cursed by a witch. Maybe she was once in love will Bill Gates and he broke her heart. She cursed him like this: "Although you will have a multi-billion Dollar software company, with the smartest people in the world working for you, you will only be able to make one program that works well - and it will be called `notepad'". I had these thoughts before, but thought maybe I was wrong cause I did not know Microsoft's more serious software. But recently starting to write C++ on Microsoft Visual Studio, I see how bad it is. Join me in installing ubuntu

 Well , I did install Ubuntu, but not really using it. I guess when you are spoiled and used to an IDE that takes care of everything for you, it's hard to start dealing with makefiles and stuff..
I owe a big thanks to Idan Elad for helping me out with doing things the `right way' in Visual studio after seeing my facebook post.

Anyway here are two really cool features that made me think life isn't so bad at Microsoft:


Peek Definition:

You are browsing in your code and want to see a function definition - answerConsistencyChecks_p0p1 in the picture below.
Everybody seems to know that pressing F12 with the cursor on the function name
will take you to the file with the definition.



But at least I didn't know for a while that pressing Alt-F12 instead will just `peek'
the definition as in the picture below.
   


This way you can just see the definition without getting out of the workflow you were in at the current file.



Seeing the stack-hierarchy - especially when error\exception has occurred.

Say you're running your program...


and then an error occurs:


Till recently, I would try to put breakpoints in a `binary search' way, and keep
rerunning until I pinpointed the precise line where the bug occurred.
Here is the smart way, that saves the time of this search and multiple reruns:
Instead of pressing `Abort' above, press `Retry'.

Now MSVS will ask you if you want to Break or Continue:


Press `Break'. Good chance the breaking point is somewhere that doesn't tell you much:


Now press Ctrl + Shift + ` , (or right click and select Show Call Stack on Code Map)

You will see on the right the entire stack of calls that lead to the error!.
More than that if you double click one of the methods on this stack,
you see on the left by the green arrow precisely the place, or just the place after, where the run is
at this stack level.


And even better: If you go to `locals' you can see the value of all variables at this level of the stack,
so a lot of rerunning and couts for debugging purposes are saved.




Monday, October 27, 2014

I just love Google they make life so easy! Say you wanted to write a program that automatically retrieves text from your emails and automatically sends reply mails according to that text.
You would fantasize `wouldn't it be great if I could just go to some website, maybe a good name for it would be `script.google.com', and just start writing something that looks like gmail and I would get suggestions about script commands that can do what I want'
Well , this fantasy is a reality

Wednesday, October 15, 2014

A cool thing I just discovered .
Google has an awesome programming language that
let's you mainpulate it's apps automatically.
I discovered it cause I need to program something that sends an automatic
ack email whenever someone donates through paypal to the Israel Vipassana center.

This simple program creates a google doc called Hello World, and sends you an email
with a link to it.. very cool!
Mark Zucerkberg is an interesting guy,
but forced to be boring because of being responsible to shareholders of a something billion dollar company.
I really enjoyed this lecture of his from earlier times.

One nice quote (not precise words) from the Q&A part:

`It's better to get things done and say sorry later, than to worry about dotting all your i's and not get things done'


https://www.youtube.com/watch?v=WA_ma359Meg


I know this question will make me unpopular in the tcs community, on which my future livelihood may depend , and I know it's probably a sensitive, possibly even offensive to some people, question ... but it seems to me odd that while this issue has received so much attention, I had not seen this obvious question addressed once. Does it really pay off for microsoft to hire pure theory researchers?
I talked to a friend who is in msr - but in computer vision. His opinion was:
- The theory part of msr was started as part of Bill Gates's philantropic project, not as a strategic business decision of Microsoft.
- If a researcher at msr theory comes up with an amazing revolutionary idea that is worth implementing and publishes it, Microsoft could implement it just the same after he publishes it if he was not from msr, and
then wouldn't have to pay his salary all those years.
(I agree that the suddenness of the layoffs, to people whose options are in academia and can't hop to the next IT company the month after, has an ugly element)


http://thmatters.wordpress.com/2014/10/14/letter-re-closing-of-microsoft-research-silicon-valley/

Tuesday, October 14, 2014

How can you every be happy without her, you think.
Is life just this miserable game where you are chasing someone,
and someone else is chasing you? Everybody trying to get somewhere?

Life forces you.. `Now it's your lesson'
Now it's time to just sit and feel the emotion.
Now it's time to learn not to be a slave of your emotions,
just let them pass through you, not to fear them.

And sometimes they come strongly.
One after the other, and not the nice ones.
Despair, anger , sadness,...

You go deeper into them instead of fighting them.

For a moment you feel the peace underneath,
and then another one comes.
Like waves in a stormy ocean, with brief interludes between them

Perhaps there is no shortcut. This is the way to dissolve you karma.
If there is a shortcut, looks like nobody has found it,
or at least not advertised it.

Otherwise there would not be so much conflict in the world.

Technology develops, but the world is not a better place,
just a different place.
Cause technology is just a set of tools, and humans use any tool
equally for good and bad, perhaps even more for bad.

If you could only know she is just another person,
not a goddess that can take you out of this life.

But you don't know that, she is just a perfect image in your mind.
And she is not coming to your rescue anytime soon..
all there is to do, is to sit and feel the emotion.

Sunday, September 21, 2014

The present and future of brain-computer interfaces: Avi Goldberg at TED...

Writing music by hearing it in your head.

Communicating by telepathy rather than facebook.

Maybe real sometime soon.

Any tool can and will be used for good and bad.

Because technology advances, but human nature does not.

Mind control will become a bigger concern than rape or murder.





Friday, September 19, 2014

Playing with your phone. In these modern times every moment there's a chance , something will come to take you out of this hard long day. Parents would keep there child alive when he cannot breathe.
I would keep a dead body rotting in my living room and watch it everyday for the once or twice a year some latent nerve reaction makes it move.
This is what we call hope, and we prefer it to the long day in front of us .

Sunday, September 14, 2014

Potential revolution

We are fooled by easy tricks.
Growing up I learned how traditional societies thought of sex as bad\dirty,
and we that are more liberal\enlightened are more open to sex.
It seems sometimes ridiculous that this idea enables you to think of yourself
as liberal\enlightened\intellectual because you are obsessed with perverse sexual ideas.

What would really be revolutionary is perhaps the idea as it is in Buddhism,
that sexuality is actually a source of suffering.
Whether this is right or wrong, if it were true and I would really see this truth,
it is clear that it really would be a revolution.

A freedom, especially for men, from constant stress.

The stress, for most single guys, well at least for me, is unending.

Like in these reality shows like `the voice' , an endless sequence of tests to pass.
After each one a short moment of relief and exhilaration, and then coming back to the same stress.

-Will she be nice to me if I talk to her?
- Will she give me her number?
- Will she answer my message?
- She wants to meet for lunch, I can't make it to lunch. Will she want to meet at 16:30 instead?
Or is it ruined forever cause I can't make it to lunch?
- Will we actually meet at 16:30 or will something get delayed and we'll have to cancel?
Will that meeting I have before get prolonged and then I won't make it and then this chance will be lost forever?
..
..

..
..


50 tests later if miraculously they all passed.. you are having Sex!

If you knew that the end prize was nothing more than tension in your body,
getting you more and more addicted to this endless chasing, where if you look with a magnifying glass, there is not one actual moment of `making it', not one actual moment of contentment and satisfaction..

Then you would know it is not the end of the world if you meet today or tomorrow,
or in 2 weeks. It is not a matter of life and death If you kiss now, or in a month, or never.
cause in any case `success' is getting more addicted to this sexuality that is just a pair of handcuffs limiting your peace of mind, limiting your ability to enjoy life.

It would even the playing field. You can act around the hottest women like you do around your friend that is nice to get together with, but that you don't care much whether you meet today or next month.

But it seems like the male brain works in a way that you always feel, once I fulfill the sexual fantasy that is in my mind right now I will transition from this state of frustration to real lasting satisfaction.

Monday, September 08, 2014

std::move makes things f**kable

After spending sometime figuring out C++ 11 move semantics,
I wanted to write some semi-formal intuitions about it,
for anyone encountering bugs related to it.

(Google will bring you to more precise, thought-out descriptions than this one for sure)

The most important thing:
std::move(A) does not actually move A! it just tells the compiler - from now on
you can fuck with A.

How does it do this?
It turns A into the most insignificant type of creature in the world of C++.
The type of creature that does not even have a name...
This creature is called - an rvalue. r stands for `right' - not as in correct , but as in the opposite of left.

What are rvalues?
Think of the expression
i = 5;

any programmer is aware that i is something that exists, there  is a place in the memory
that the computer calls i, and that place can store a value.

But what about the 5 on the right hand side?
where was it before it got put into i?
It was in some temporary place in the memory that does not even have a name.
A place that the computer feels free to treat like shit.
Will the 5 still be there after it is put into i?
Nobody gives a fuck.
Nobody's looking out for that place.

This is what it's like being an rvalue.

Sadly, in the world it sometimes pays off to treat people, or variables, like shit.

Suppose you had an expression

A=B;

The compiler would probably decide this means it has to copy all the data stored in B
and store this copy in A.

Suppose we don't care that much about what will happen to B after running this line.
We can tell the compiler - feel free to ruin B while running this line if it pays off.
e.g. if B contains a pointer to some large object, it would be very efficient
to have A point to the same object, and set B's pointer to null, rather than making
a copy of the large object.

writing
A= std::move(B);
will encourage the compiler  to do this.

How does this actually happen?

I like to think of it like this.
Suppose you have a prison named `operator ='

In this prison the are 3 wards -
One for the rich prisoners where they can be sure nothing bad will happen to them.
One for the regular prisoners where, bad things may happen to them, but no one will intentionally
try to screw them over,
and one for the prisoners someone had it in for, and wanted to make sure they would really get screwed.

The entrances of the wards look in C++, respectively, like this

1.operator=(const object& B)
2.operator=(object& B)
3.operator=(object&& B)


The double && is a way to tell C++ - B is an insignificant little worm! (that is, an rvalue). Feel free to tear him apart while running this operator!

The well-known `const' on the other extreme is a way of saying -
don't you dare touch B!

using move can become crucial when dealing with the specie in C++ 11 that's on top of the food chain - the guy nobody can touch.. the Unique Pointer.

A unique pointer in a way, is even tougher than the untouchable const object.
As the name suggests, you cannot even make a copy of a unique pointer.
(This turns out to be extremely useful for preventing memory leaks)

The big mess is that, not only the unique pointer itself, but consequently any thing
containing a unique pointer cannot be messed with. For example, a vector of unique pointers
to String.

For unique pointers, std::move is a way for the gang leader (i.e. the programmer)
to tell the gang's representative in the prison (i.e. the compiler)
`This guy no longer has my protection, you can make him your bitch'

The thing is, the gang representative will hesitate about messing with the unique pointer
if he is not constantly reassured by the gang leader that the u.p really does not have his protection any more.
This hesitation will cause compiling errors.

For example,
Suppose you have a method containing a line
A=B;
where B is a u.p the method got as a parameter.
You may think if I call the method with std::move(B) everything will be fine.
(cause a u.p cannot be copied, but it can be moved)
but that is not enough!Cause by the time you get into the method the compiler will hesitate
whether he can really mess with B,
and you will have to reassure him by writing again
A=std::move(B);

This is worst when calling constructors, where for reasons I do not fully understnad
you need to use std::move(B) in the initializer list - by the time you reach the
start of the method it's too late to mess with B. (well this last part is not completely correct,
but I'm tired and it's late)

Tuesday, September 02, 2014

LIFT

The weird list of 4 things that throughout years has consistently shown to have
a boost on my mood if I do them daily

-Avoid video - TV, youtube, ect.
-Avoid Masturbation.
-Hit on beautiful girls (oddly, this in itself has a more positive effect on my mood,
than having sex with them (in the rare occasions it ends up that way))
-Meditating 2 hours a day

I've been confused by this list.. cause there seems to be some kind of a contradiction between 3 and 4.
Cause it's kind of like taking one step in the direction of eliminating desire,
and one step in the direction of igniting desire.

Related to that , an analogy I had on tantra:
Think of 2 scenarios
1. You go into mcdonalds sweating in the middle of the day in shorts and a t-shirt
and get a Big-Mac

2. You go to a fancy restaurant, dressed perfectly, for a candlelight dinner, with
a wonderful woman who is also dressed amazingly. There is classical music in the background
and you have a wonderful view of the city from a window.
You are enjoying a tender steak of very high quality cooked by a gourmet chef.

You could say the second experience is more `spiritual' than the first,
but both experiences have at their core something that is non-spiritual  - eating meat.


Similarly, Tantric breathing exercises, postures, ect. can enhance the sexual experience,
and  given that you are going to have sex, why not indeed make it a special experience and a bonding experience with your partner;
but to say it is a spiritual practice when at it's core it's based on sexual desire -  the precise thing that spiritual practice is supposed to gradually dissolve, is misleading in my opinion.


btw If I had choose to #5 on this list it would probably be physical exercise , something I am only doing once a week lately, specifically Pilates in the last few weeks.

Anyway I digressed.
As for #2 on the list, for a long time I could keep it under control using a combination of meditation,
and this website http://www.stickk.com/
where you can define goals and even put money on the line.
But at a certain point I began to not take what I wrote on the site too seriously
(the credit card # I gave them also expired by the time I stopped meeting the goal, so didn't lose money)
But recently, Tim Ferriss created a community of guys trying to meet the no M goal -
actually he defined it as NOBNOM - no booze no masturbation, but I haven't been into alcohol for many years anyway -
turns out a lot of guys find this having tremendous positive effect.
This community of guys holding each other accountable has helped finally get back on the wagon
in the M category.
I recommend looking at the lift site.
This concept of choosing a few things that have positive effect,
and seeing the accumulative effect of doing the consistently (even ,say 85% consistently)
for months or years is simple and poweful..
and so different from the one I feel I was raised on by the media..
where most of the time it doesn't matter what you do,
but there are just a few critical moments, e.g., in Back to the Future where Marty's dad punches Biff
that determine everything.

Subconciously, this encourages us to spend most of our time doing nothing cause we think
all there is to do is watch TV and wait for that fateful moment when we open a car door and a guy is getting rough with the girl of our dreams, and we have to save our energy for that one punch we'll have to deliver.

I really like the phrase `Luck is when preparation meets opportunity'


Monday, September 01, 2014

I try to build a whole world from a few words you've given me.
 I'm hanging on a distant echo trying to hear what seemed so pure and right.
 And no matter how much time passes, when I start to listen a huge wave comes towards me. One particle containing the whole universe.
Poking at it, thinking it is small and weak now, it answers back, almost screaming:
You cannot deny this bond!!
It's power hasn't gone anywhere, just because you tried to forget it.

About Me

My Photo

Hi! I am a computer science postdoc. For some reason google is not finding my new homepage so I added a link from this profile