Friday, September 18, 2015

On Everyone's Need For Acceptance/Validation

The need to be accepted/loved comes third in the Maslow hierarchy, but given that these days in the developed/developing world at least people don't have problems with levels 1 and 2, we can safely assume the need for acceptance is also basic.

There would be no arguments on this need itself, however, what struck me in recent days, is that people want to satisfy this particular need from one particular subset alone. For example, we want our peer group alone to think that we are cool. We want people whom we consider to be cooler than us to think that we are cool too. If people whom we consider to be less cool than us hold us in high esteem, it is of no concern to us. If a person is loved by a lot of people, but is not given attention by just one person they care about, this whole need of theirs goes unsatisfied! They are almost crippled emotionally. Spurned lovers, or people who have been on the other side of the "its not you, its me" should be able to readily relate to this.

In cases of skills/talents the selection of a sub group from which we seek acceptance or validation makes a lot of sense, and indeed a failure to do so should be considered foolishness even. However, when the subset selection is a bit more artificial or when it is from the heart and not the brain - it would do a world of good to consciously recognize that one has chosen to validate oneself from a sub selection of options they have. That they are indeed worthy of love and respect, and that other people continue to value them.

But, one can argue on the lines of  ‘What if sometimes there is no choice about what to love? What if the temple comes to Mohammed? What if you just love? without deciding? You just do: you see her and in that instant are lost to sober account-keeping and cannot choose but to love?’ (David Foster Wallace). What if we don't get to choose who we think are cool? What if we want just that special someone to pay us attention or love us back?

I don't really have an answer, but I can continue the quote - ‘Then in such a case your temple is self and sentiment. Then in such an instance you are a fanatic of desire, a slave to your individual subjective narrow self’s sentiments; a citizen of nothing. You become a citizen of nothing. You are by yourself and alone, kneeling to yourself.’ (DFW)

I bet its harsh, but such is life. It goes on. 'In three words I can sum up everything I've learned about life: it goes on.' (Robert Frost). There's a new normal, you cannot get back the old normal, but there is a new normal. Check this. It is a failure of imagination to think that there is only one special someone who can or needs to love/accept/validate you. So move on, there's a world out there.


Thursday, July 18, 2013

How to decide?

Decision making is always tough, and after reading a few things on that topic,  I have learned the following,
  • Minimizing pain is more important than maximizing pleasure
    Over time we get used to good things, but things which are a pain continue to be painful, and may in fact get worse. And just to be clear, this doesn't mean you should be risk averse - risk is entirely different from pain.

    For example, if you have to choose between a large house which is far from where you work, vs a smaller one nearby - choose the smaller one that is nearby because as time passes, you'll get used to the larger house, that is, the largeness of the house will cease to be a source of joy, while the pain of commuting will only get worse. The smaller house has no pain, and no initial joy - but it never gets worse. The larger house has a good start, but progressively gets worse on the happiness factor it'll eventually fare worser than the smaller one.

  • Don't decide with your brain if you are going to live with your heart ;-)
    The heading is cheeky but it simply means - don't base your decisions on metrics that don't really matter.

    It has been found that people who buy cars emotionally are more happy with their cars few years down the road compared to people who buy cars rationally comparing every single metric they know about. This is probably because small differences in the engine's horsepower are not going to matter unless one is racing while the comfort, aesthetics etc., ie. factors which might have an influence on one's daily ride. The same principle can be applied when one chooses between phones, headphones and so on. One can reliably leave the decision making to the gut when there are but small differences on a couple of metrics.

  • Decision making state should be similar to decision execution state
    When you decide on a future course of action, make sure that you are in a state that is as similar to the one you'll be in when you execute that decision.

    For example, if you are planning to join a gym and you plan to go in the mornings, try waking up early for a week before committing to the plan. Save yourself the trouble of joining the gym on a relaxed evening and then find yourself wishing you didn't on a harried morning.

  • Compare dis-similar items
    This idea is bastardized from an old Seth Godin blog post. This logic is to be used when the decision making process involves just a single item, for example, deciding whether to buy a car or not, and if so the price range.

    Lets assume the problem is in setting the range between INR 600,000 vs INR 700,000. Instead of seeing the difference of INR 100,000 only in terms of a car, like more horsepower etc., deciding will be easier when its thought of as a home entertainment system/ gaming system/ lazy boy chairs etc. In other words, do you prefer a cheaper car plus a home entertainment system or just a costlier car alone. The rational part of the brain can then compare whether the extra horsepower is worth giving up the entertainment system or not.

  • Toss a coin
    When all else fails - fix your outcomes to the toss of a coin. Toss it high and if you find yourself wishing that heads or tails show up - go for it, that's what you really want!

Friday, June 14, 2013

On The Facebook Spammy App Which Tags All You In A Stupid Photo - the how and the why - Part 1

I have blogged about facebook spam app before. Quite some time has passed without me noticing anything other stupid spam in my feed, but recently I've been seeing quite a lot of activity from one particular app which tags a lot of people in a naughty picture which appears to be a video.

So if you were tagged in a stupid spammy picture recently read on to see how your perverted friends got fooled. (And fix your privacy settings - you share part of the blame too)

The picture appears to be a youtube clip, and the thumbnail signals the viewer that they might get to see something, y'all know...

The hapless pervert clicks on it, and off we go this page (http://tbszam.ap01.aws.af.cm/?52533520?cid=51b0144660dd6/?cid=51b0144660dd6)

(Ok now I should not have been so judgmental earlier, the words here seem fine :P )

Once again the player is just a picture. It looks like a flash player, but it isn't. Now your friend has clicks on the play button, again..



 A tiny new window opens, and the original page is updated with instructions to copy the URL from the other window, and then comes the shocker,


Its freaking asking you to paste the URL - ctrl + C and ctrl + V, goodness great, and people still do it??? (Two of my friends did - I'm never going to trust them with anything on the internet, ever)

What just happened was - they just granted the app the permission to tag their friends - just by proving that they are, human (no, I disagree, they are monkeys).

Here is the URL they pasted view-source:https://www.facebook.com/login.php?api_key=139682082719810&skip_api_login=1&display=popup&cancel_url=http%3A%2F%2Fm.facebook.com%253Fsdk%253Dios%26error_reason%3Duser_denied%26error%3Daccess_denied%26error_description%3DThe%2Buser%2Bdenied%2Byour%2Brequest.&fbconnect=1&next=https://m.facebook.com/%2Fdialog%2Fpermissions.request%3F_path%3Dpermissions.request%26app_id%3D139682082719810%26client_id%3D139682082719810%26redirect_uri%3Dhttps://www.facebook.com/connect/login_success.html?display%3Dpopup%26type%3Duser_agent%26perms%3Doffline_access%26fbconnect%3D1%26from_login%3D1%26rcount%3D1&rcount=2


You can find -

the app's API key - 139682082719810,
skip_api_login=1

In the &next= you can see the facebook URL for requesting permission.

If you want to see what's going on under the hood please go on to part 2.

Thursday, June 6, 2013

On Reviving This Blog

Quite some time has passed since I posted anything. But, today Seth Godin published his 5000th post (!!!) and I read this - "Before Seth Godin was Seth Godin", and boy am I inspired.


I know that none of you read my non-technical posts - this blog is slowly inching towards 20000 page views in total :( (phew), and the majority of this views are from just 3 - 4 technical blog posts which continually get traffic from Google.

But still I want this to be in public - I'm going to start blogging daily... The journey starts again..

Current Stats

Total posts = 53
Total pageviews > 19000
Pageviews per month averages around 1000 (thanks to four old blog posts).

See you in five years, bye.  :-)

Wednesday, February 13, 2013

Searching for someone this valentines day, huh?

A random conversation with a friend facing a dilemma, a little inspiration from "59 seconds: Think a little, Change a lot", and some awful lot of time....


This Valentine's day lets inject some science to the crazy world of love. My goal in this post is to give you a couple of simple, clear, and practical tips based on psychological studies I'm aware of. I've also linked to as many sources as possible, so read on, be enlightened ;)

Being a programmer, I have to start with how we generally approach the problem, but you may happily skip the next two paragraphs if you want to. We have the Stable Marriage Problem, and the fussy suitor problem. These are rightly well known - Shapely got a Noble prize in 2012 for the first one, and they have a lot of cool applications in other areas not related to love.

The secretary problem teaches us to never settle down quickly, keep looking it says, fix an upper limit, say, 27 dates. Date the first 10 (27/e = 10 approx) and no matter how good they are, break up with them. Evaluate them on whatever metric you want to and keep that scorecard handy. Now start dating whoever comes in your way, and settle down with the first person who comes in your way, they're pretty much the best you'll find.

The stable marriage problem teaches us to create a ranked list of people you want to be with. Start by proposing to the person ranked one. If rejected ask the next one. And remember never propose twice. Its in the algorithm, seriously!

And now on to what current psychology research tells us - 
Psychological Fact 1 - We get used to good things - see Hedonic treadmill. TLDR - If there are any positive traits in a person, and you admire those qualities, after a few years you'll not be valuing those qualities anymore. So as far as your brain is concerned, the value of those qualities decreases over time.

Psychological Fact 2 - We never get used to pain. They become more painful over time. If there is anything that pisses you off today, boy, it'll drive you crazy tomorrow.

In other words, our goal should be to minimize pain more than maximizing good stuff, because after some time the good stuff doesn't matter much anyway. With this key idea in mind, lets take a look at some traits.

  • Narcissism - If there is one thing you remember in this post, remember this, avoid narcissistic people. That's obvious, so, the real question is how do we find out whether someone is narcissistic or not? Thank facebook!
  • Smiles - Prefer people who smile more often, and who have a wider grin. Smiles or rather the lack of it is directly linked with divorce. This makes the task very easy for us. Just see their profile pics, and photos and see how often and how heartily they are smiling.  Source - http://www.livescience.com/culture/090414-smile-marriage.html
  • Assertiveness - The previous two cases were easy - black and white, maximize one, and minimize the other. Assertiveness, however, needs balance. Its hell to live with people who want their way. Every. Single. Time. On the other hand there are people who are too soft. Its easy being around them because you feel that you are the boss. But, the problem is they keep piling up all the crap you throw at them unawares (since they are too timid to point it out) and they feel victimized and in due time they reach a tipping point, and when you wake up one fine morning you find yourself being considered as a heartless bully. By the time the volcano erupts, its too late already. So save yourself some heart ache, walk in the middle on this one.  All in all the goal here is to be a couple who tackle problems calmly - http://www.psychologytoday.com/articles/200910/what-makes-marriage-work
  • Shared Hobbies - Found someone who shares a hobby? Don't look further. Shared hobbies promote a sense of being a team, and you get spend more time together that's fun for both. Research shows that couples who tackle challenges together, tend to love each other more. The old tribe tendencies kick in - its you the couple together vs the problem/goal/whatever. (I'll update sources soon).
So there they are - simple stuff to look for. Search for someone who is not narcissistic, who smiles and laughs a lot, who is confident but not too aggressive, who has a shared hobby or two. If you think this is impractical, well *you* work on this list. Be less narcissistic, smile more, don't push too hard, or allow yourself to be pushed around, have an interesting hobby, someone cool might read this blog of mine, and come searching for you!!!

At the end of the day, as an old poet said,

The mind has a thousand eyes,
And the heart but one;
Yet the light of a whole life dies,
When love is done. 
- Francis_William_Bourdillon 

Sunday, July 29, 2012

Life Before Templates

Recently functional languages are exploding on the scene. Old languages are slowly but steadily gaining new features. C++ 11 has a whole lot of new stuff. But, in this post I want to go back to some good old code. Code that was probably written when I was crawling as a toddler. C++ templates were introduced in mid-80s, so how did programmers code before that? Pre-processor

Have a look at http://docs.libreoffice.org/svl/html/svarray_8hxx.html It contains a lot of macros which create whole classes! (If you have time, see where each macro is being called, and do the whole stuff on your own to get the final class, and you'll appreciate the ingenuity of the programmers of old).

I have never used complex macros since in C and C++ since use of macros are kindaa frowned upon, so I decided to post a small and ugly use of these macros.

If I had been a programmer before C++ had templates, this is what I'd have done to add ;)

#define ADD_FUNC(ret,typedesc) \
typedesc add##ret(typedesc a, typedesc b){\
        typedesc c; \
        c = a + b; \
        return c;\
    }

The above code can be used by the following macro calls,
ADD_FUNC(int,int);
ADD_FUNC(float,float);


This would get me two neat functions for addition - addint(int,int), addfloat(float,float)

I can use these functions directly as,
cout<<addint(4,5)<<endl;
cout<<addfloat(4.3,5.2)<<endl;

Note that the above macro is very different from a normal macro function like,
#define MACRO_ADD(a,b) (a+b)

The first macro *creates new functions* which are then called directly by name. The second macro will be called differently,
cout<<macro_add(1,5)<<endl;
cout<<macro_add(2.2,3.1)<<endl;


Here is a full file to make everything very clear,

In LibreOffice code, you'll find that the calls to the macro generated functions/classes are themselves created using other macros. However all the old stuff is now being replaced by STL containers, so hurry you might miss some beautiful/ugly old code. (Its ugly in 2012, but it shows the ingenuity of the programmers of old! So that's the jackassery that was going on there!

Tuesday, July 17, 2012

So you clicked on the menu, huh?

Menu Dropdown
I put a breakpoint at libo/vcl/source/window/winproc.cxx:2405, at the case SAL_EVENTMOUSEDOWN, to see
what happens when I click a mouse.
I clicked on File Menu, it hit the breakpoint. Then off it goes to calls ImplHandleSalMouseButtonDown ()
with the following details stored in pEvent and pWindow.
pEvent
    mnTime = 78764380 //Time
    mnX = 18 //x co-ordinate
    mnY = 9 //y co-ordinate
    mnButton = 1 //left button, 4 for right click, 2 for clicking with the scroller
    mnCode = 0 //to find whether click is part of some select etc.
pWindow - the window object.
    
The ImplHandleSalMouseButtonDown () function is in ./libo/vcl/source/window/winproc.cxx:2068, it checks
whether shift, ctrl or alt keys were pressed in 2076, and then calls ImplGetMouseButtonMode () with pEvent
(function is at ./libo/vcl/source/window/winproc.cxx:2030) to get further details of whether it is a simple
click event or whether it is part of select, multi (ctrl+click?) or range select, using pEvent's mnCode
variable.
The ImplGetMouseButtonMode () function returns nMode as 3. The first two if statements were true, ie.
MOUSE_SIMPLECLICK and MOUSE_SELECT. Once, this returns, ImplHandleSalMouseButtonDown () calls the function
ImplHandleMouseEvent (), with
    - the window object - pWindow
    - nSVEvent = 1 (EVENT_MOUSEBUTTONDOWN)
    - bMouseLeave = False
    - x,y co-ordinates
    - time of the event nMsgTime
    - nCode = 1, to indicate status of shift,ctrl keys
    - and mode of click , nMode = 3
The function then does the following,
    - gets the details of the frame
    - checks the previous location of the mouse.
    - updates the frame data with the latest details
    - checks whether the mouse has left or entered (?).
    - finds the window
    - after finding the window
        - it checks whether the window was disabled
    - it comes to line 666 (after several if conditions turned out to be false), for the mouse click event
        - here it checks for double click.
        - it then updates the details in the child window object
    - It creates the MouseEvent object at line 709
    - It notifies the child window of the event. Off to the next function.
    - In the next call, first the constructor of ImplDelData is called (maybe due to some
        inheritance) ImplDelData::ImplDelData () at /home/jesso/Downloads/libreoffice/libo/vcl/inc/
        svdata.hxx:424, this is there to protect against the window from getting destroyed.
    - The NotifyEvent object is created.
    - It then checks whether it should bring the window into focus, if it previously didn't have focus,
        close context menus etc.
    - ImplCallPreNotify function
        - calls long Application::CallEventHooks () at ./libo/vcl/source/app/svapp.cxx:1657
        - that function returns 0
        - so it gets the PreNotify () method on the window object in the event object.
    - Finally it calls the MouseButtonDown() method on the pChild pointer, which happens to be
          MenuBarWindow::MouseButtonDown () at ./libo/vcl/source/window/menu.cxx:5366
The MenuBarWindow::MouseButtonDown () then does the following,
    - It first finds the entry on which the action happened.
    - It then calls ChangeHighlightItem (which needs to be refactored, btw)
    - This decides whether to update the focus etc
    - It then finally creates the pop up in line 5477