Saturday, July 26, 2014

Datepickers

The tricky thing about calendar form inputs is that browsers render them in different ways. Safari on Windows for instance, I recently found out it does not render calendars as a calendar; rather it shows two buttons on the extreme right side of the textbox that when either is clicked increments or decrements the date being displayed. What's more, it displays in YYYY-MM-DD format, which is a bit difficult if your client wants you to have MM-DD-YYYY format instead.

jQuery to the rescue, I guess. I got the widget to work well, it even displays a default date thanks to help from this blog post, but I wanted to make sure the theme did not conflict with any other styles I might need to put into the site I'm working on; the jQuery UI theme should only affect select elements in my form. This should be a piece of cake since a Download Builder page is available that allows one to specify CSS scope. Except datepickers in jQuery have a quirk when used with the CSS scope; that cost me two and a half hours of trying to get it to work. 

If I may digress, what the h#ll. I mean, you create such powerful code and you can't be bothered to elaborate what's happening more clearly on your documentation? It's these kinds of bottlenecks that ruin the development experience for me. Luckily, I found this entry on stackoverflow that was a light at the end of the tunnel. It clearly stated the reason for the theme not showing up when using CSS scope, and gave a workaround. 

Here it is, for future reference:



Note: Another gotcha was how to embed JSFiddle code on blogger. Got the skinny here and here. If it weren't for these resources I would have been out of a job already...

Friday, July 25, 2014

Menus and Modals

I'm trying to create a system I can rely on so that I can create website UI's much quicker. I've written about this before here, and this time around I'll be writing about what I found with regard to menu bars and modal popups.

Everyone's familiar with menu bars, but to illustrate modal popups we have a handy demo here. My issue has always been browser compatibility; I can come up with good code on my own, but it fails when taking into account Internet Explorer, Safari on Windows, Opera, and so on.

The Gibson Research Corporation's Script-Free Pure-CSS Menuing System was a godsend to me in this regard. I experimented with it on IE's Emulator tool; while it's true it looks ok on the emulated IE 5, the hover over submenus didn't work. Also, when I replaced the images being used for the first-order menu elements with text and styling, in IE 5 the menu reordered itself vertically. I'm therefore more comfortable with saying my alters result in code that's IE 7-applicable. 

The site that I got the demo from became the basis for the modal system. It was very simple code, except that it used a lot of features older versions of IE do not support. So the gradients, border-radius, rgba opacity, and box-shadows had to go. One could presumably use hacks to get the same effects on IE, but I've tried all of them and have never gotten them to work. Besides, we need to have a handle on how fast the page runs - adding too many files would be awful on the load time.

For radial gradient effects or large linear gradients, I usually take a screenshot of the gradient on a browser that supports it. I then crop everything out, leaving only a thin sliver of the gradient. For small gradients, I use online gradient image creation tools; then we just specify on the CSS to repeat the image as a background image and we're done. That method is also how I got around the rgba opacity not being supported in old IE; in this case I use a PNG file at a certain percentage transparency (usually plain black) for the background.

Another thing I noticed is that Safari on Windows does not give a nice calendar when using Formalize CSS; I would recommend instead using jQuery's Datepicker.

Floating Point



The game is called Floating Point, and it's free on Steam. I like that it has simple mechanics that are hard to master; the levels are randomly generated and there's really no other goal aside from learning to move elegantly and gracefully throughout each level. It's the kind of game that's a step away from the usual run-and-gun.

Friday, July 18, 2014

Let's clean our backyard.


I'm sharing this, but I haven't watched it yet. I've lived to the point where I think it's fine if I refrain from watching some things. I'm never watching one scene in Malena again, and neither will I ever watch this.

I've been lurking in YouTube since before it got acquired by Google. In all that time it's grown to be something quite amazing, I think. It's changed how people see the world. It's a source of income for a lot of folks, and a vehicle for free information. 

I've grown older too, and the longer I've been in the world the more I see what selfish cruel sh*ts some people are. I've seen shallowness and people letting themselves down. Heck, I've let myself down a lot too. But I think letting down the girl above, we all who've been in YouTube are a little culpable. 

Why didn't someone reach out? 

Yesterday, sick of the crap I had to wade through at work and looking for some distraction, I found videos of people taken on the sly. They weren't really doing anything wrong, just going about their day. But the one who uploaded the drivel was trying to frame the situation in such a way that the person being recorded was doing something wrong. As if the uploader had the right, training, or authorization for that. Taking someone minding their own business, taking the situation out of context, exploiting the hive mind-cum-rage machine that is us. 

And people fall for it too. Or they willingly go with it. For the power trip it brings. 

I'm sick of this crap out in the world. I know it's not my job to swat at these flies, but I can at least do a little bit to clean up. To show the sh*ts of the world that there are consequences to their manipulations, that there is at least one person out there who won't buy into their propaganda. I reported the video; today I saw that it had been taken down. 

The feeling is cathartic. Right now I found a user uploading voyeur shots of women. There's a lot of videos on the channel and YouTube's reporting tools are cumbersome. Hunkering down...

You can join at any time.

Tuesday, July 15, 2014

Our Superhero Team: Google, Ladies and Gentlemen.

It's a brave new world we're in. Google's now being proactive about fixing problems with the Internet. There's some hope here; that in my lifetime I'll see the day when people will stop relying on governments and politicians to keep them safe, that we'll be able to grow our own wings. The dream of a Global Frequency is alive, sniff...

Monday, July 14, 2014

Haunting Music.

I fell in love with this music after I watched the "Undress Me" short film by Tatia Pllieva. Just wanted to share it here.



Sunday, July 13, 2014

Brazil and the Global Frequency

It's a fond dream of mine to have something like the Global Frequency exist in the world. This is why I am so impressed with this article about Brazil solving its problems by actually leveraging the power of the Internet. I mean, we have Tor, we have passionate activists who have genius technical abilities, and an open-source culture in full bloom. When are we going to see Miranda Zero on the news?

Friday, July 4, 2014

Draggable Elements

This was an experiment from about a year ago using Metro UI CSS and jQuery. I remember this was a b*tch to write; there were so many things to take into account. I started with a test page where you could drag an element (a name) between two areas of the page. I finished up with the second test that converted the appearance of the element to a colored box with a small image of the person (that's the black area) as well as a checkbox.

Unfortunately the project that I was doing the test pages for got temporarily shelved. Part of me still feels that I did all that research and proof-of-concept design for nothing; a bigger part feels proud I got the whole thing wired up and running perfectly. So, here's the sample code - unlike the previous one this doesn't need Visual Studio; just run it on your browser, really.

The Layout

One of the things I enjoy about web development is making the user interface. It's fun for me to make elements appear on the browser and move it around. But the thing the I really hate the most about web development is also connected to the interface - I'm talking about making the markup behave consistently across different monitor resolutions, different browsers, different devices, and different content lengths. 

This has been the bane of my work life; thankfully I've gained knowledge over the two and a half years I've been in my company. The very first thing I learned was how to keep the content centered with even margins on both sides; that's just setting margin-left and margin-right to auto, natch. The second thing I learned was to use grid systems. It's very much like the old days when people used columns to arrange the layout of their newspapers; the bonus is that a layout made with a grid system will be perfect regardless of the browser or screen resolution. I started out with the 960 Grid then Bootstrap; right now I'm leaning toward Blueprint.

For some time I came to accept that form elements have varying renders depending on the browser; and then I heard about the Formalize CSS; cue mind being blown. I checked this beast from IE 5 to 9, Chrome, Firefox, Safari - it was all the same. Uniform and consistent. Until you've tried designing across browsers, this thing might seem trivial - but I assure you it is not. With the grid system and the form normalizer in place, one can for the same amount of work make a UI that doesn't break over a ton of situations. It's amazing for productivity.

The last thing to complete this was guidance from cssstickyfooter.com. This brilliant web page provided insight into solving the thing which has plagued me ever since I was a beginner developer - how to set up a footer that expanded with the content and was always at the bottom of the viewport. I've found that different CSS systems can interfere with this fix - for example, Bootstrap needs a completely different markup. That's why my preferred styles now are Formalize and Blueprint. It's so much simpler and unobtrusive.



I've been experimenting with this setup and I'm really satisfied with how easy it is to create my own custom styles. The styles for the labels and textboxes are an example, I just lengthened the boxes' width and added the colors for the labels.

Fixing the buttons meanwhile was quite fun. Turns out the Formalize style took precedence and even if I added a class of my own my changes would be canceled out. It would work with an inline style, but that would make the markup clunky. What I did was dive in the Formalize code, find the part concerned with the link button, and copy the style. I then used this for my own class, minus the attributes I needed changed of course.


You can see that I used the :not selector starting from line 68, this was to exclude those elements with my class. Unfortunately, this caused the Blueprint link hover style to display. It was no problem though, just had to do the same thing to line 43 of the Blueprint style:


I got the tip from Mr. Dudley Storey's site. I recommend you all visit, very cool website it is. I used this for the Submit button, and I left a Cancel button with the inline style for comparison. Anyway, here's a download link to the code I was playing around with (needs 7Zip to unpack, and Visual Studio 2013 to run). The markup I got from the Formalize demo, they used tables to layout the elements and it was a bit annoying to have to translate everything to Blueprint grid. It was good practice though, so all's good.

Saturday, June 21, 2014

Power

It's a concept I've been grappling with. In lay terms power is the ability to influence the world; for example, you bump into me and I mess up your day. Or there's some law being put to vote I don't like so I make a call and poof! Several months' work and taxpayer money wasted.

In the martial arts, power is all about doing more work for less effort. So, either I kill you without breaking a sweat or I kill more people before I get winded.

Having power over your environment is a good thing, something to aspire to. It's kind of humanity's schtick, mastering our circumstances. But I can't help but think that the lay definition and the martial arts version are incompatible. See, in the first definition of power the focus is on the effect whereas in the latter the focus is on the process.

An office worker with his crew spreads a rumor about a colleague who is in an outgroup - not part of their clique. The rumor spreads, gains momentum and causes the colleague years of emotional turmoil. The guy that started it must be so powerful, huh? But for things to have turned out the way they did so many other factors had to fall in line. Just to talk about one factor,you're telling me he had a hand in the opinions of the people he was spreading the rumor to?

We save money and seek out high-paying jobs so we gain purchasing power. But if we die before we ever spend a cent, there's no difference between us and a pauper. We may be objectively rich, but effectively we're poor. It's the same with the kind of "power" a lot in our society desire in my opinion.

For another metaphor, and this I learned from an online crisis management course I took, imagine being ruined by some catastrophic, overwhelming occurrence. Say this event destroyed everything in your immediate vicinity, you don't have food or water or shelter. You're taxed physically, emotionally, spiritually even.

You find a big chocolate bar - it's still good. You're better than you were before, right? So, what do you do - do you save the chocolate, prolong your state of relative prosperity for a few more days; or do you eat it? After all, you might not find food anytime soon. It would make sense to keep what luxury you were "blessed" with as long as possible.

Except this would be wrong. Eating the chocolate would remind you of better times, and it would be to you a pleasurable treat - a high point in a situation that doesn't have much of those. It'll help get you in a calmer mindset. Eating it would also give you fuel for whatever you would need to do. Not eating now will make you hungrier and less in a rational mood; if deprivation doesn't kill you it will put you in a state where you'll make a blunder that can't be fixed by the chocolate you put off eating. 

Eating now and going hungry tomorrow is infinitely better than growing more malnourished today because eating won't fix all the conditions your body might get as a result of worsening health.

I kind of like the martial artist's definition. If I get more of the same kind of work done in the same amount of time or if I do the same work with less strain then I know I've grown. It's something that's part of me, like my arms or legs.


Thursday, June 12, 2014

Love what returns your love

This is one of those half-baked ideas I'm so fond of. It just means to dedicate ourselves to those things which pay off for us. Life is short and we can't afford to waste time and resources on anything that won't benefit us at all.

I speak of this from experience. I've aligned myself with lots of things, invested in all sorts of schools of thought and ways of living; I dedicated my time to so-called friends. All for them to betray me or not be there for me when I needed them most. I paid for that foolishness.

Magic the Gathering has been an obsession of mine. The deck for me is Red-Green Madness; however it's a sub-par deck, and I have a disappointing losing streak whenever I played - less than chance, really. I've only lost more money the longer I've dedicated to it.

Which isn't to say I haven't found gems. There have been things that have rewarded me for their dedication. The martial arts, for instance, have given me power and knowledge I did not have before. And it has also afforded me friends who are true inspirations; I feel privileged for being welcomed into their homes. 

In work, I made the choice to study IT. The sense of accomplishment I gain whenever I fix a bug or make a program work are concrete. I am able to write code that is utilized within organizations, code that is depended upon by untold number of people. The skills I struggled to learn initially are now my ticket to earning money and perhaps getting better things in life. 

Making this blog had a benefit: it made me more practiced in writing essays and has come in handy when I need to turn in an essay during the training sessions I subject myself to.

So, pay attention to those things that have a return for your money, while dropping everything else. Don't fall for the sunk cost fallacy. But my key insight regards making the distinction; after all, the hardest part is in knowing when to put more effort in and when to fold. 

For me, it seems like the cut-off is seven months. If after seven months there's no benefit, drop that crap. I am basing this off my experience in the martial arts I am practicing; it was about seven months before I gained anything. Now, the time-frame may be even less depending on the intensity of the activity; for instance, I learned jQuery and MVC in less than the five months I was assigned to a project that required them. 

Now that I've realized it, I'll be applying this criterion to other things in my life. One can always benefit from periodic weeding.

But what about optionality? Ever since I read about it I've been a fan of the concept. This extends from stock options trading, where you are able to buy or sell the right without the obligation of buying or selling something before a specific date. The key is that you can choose to exercise your right only in situations where it will profit you to do so; you don't have to buy or sell in bad conditions. You practice optionality when you think something might happen and so plan for the "just-in-case" scenario. Except this only works when you have a real, practical mastery over the odds and consequences. You also need a big enough buffer to weather any unforeseen  complications or mistakes. People in general don't have the first condition, and we don't have as much of the second condition as we would like to believe.

My point is, people tend to think they're practicing optionality when they're really not. I think it's because we're not so good with long-term forecasting/thinking. I must say though I am still working on applying optionality, so until I am able to say I am comfortable with applying the concept I would tend toward the rubric I outlined here.

Third World and First World Thinking

I've got the seed of an idea. It's not fully hashed out yet, but it has the feel of something that would quickly slip away from my mind if I don't record it. It's interesting, so here we go:

In one of the many Coursera courses I was taking, one key thing you are supposed to do in order to gain resilience and improve your career is to define your values. Before they explained what that was they image that came to my mind was of some trait or attribute, like being a hard worker. Turns out values are the things that are important to you, stuff you prioritize that make you feel good about the world when they are attended to.

This week we had a product development training session at work. The presenter started out by asking what a service is. Those who were asked to relay their idea of what a service is stated some variation of "It's something where someone serves you." The actual definition of a service that was used for the presentation was that service is a material/non-material good or invention that people can feel compelled to pay for. So, people are not really being paid to serve you at a restaurant; they are providing you with the opportunity to sample amazing dishes in a great ambiance, to make your meal an experience, and also without you toiling in the kitchen or investing to gain the skills required to make these dishes.

Values aren't stuff in your personality that can make you successful; they're stuff that inform what goals you will set for yourself, which are in turn signposts to the path of success you need to be taking. While service isn't something people do for you or to you in exchange for pay, it's about something existing in the world that you have to get in on so badly you're willing to pay for it.

It would be interesting to ask people from around the world about this, about what they think values and service mean. My idea is that people in less advantaged countries have a more entitled view about these concepts.

Saturday, June 7, 2014

Outrage Culture

I followed with interest the situation involving Josh Olin, former community manager at Turtle Rock Studios. I think it's an interesting instance of a phenomenon on the Internet.

We have to accept that people are irrational. By making comments that have a high likelihood of triggering emotions in other people, Josh Olin courted mass irrationality on himself, his work, his employers, his friends and family. He's right about an outrage culture existing, which demands that something be done.

I've got problems with this Internet trend. First of all, doing something isn't always the most advisable thing; especially when one doesn't have a clear idea if that thing to be done has an impact on the problem. At other times, doing nothing at all would be best - I am reminded of several examples, one of which came from my dentist. She said that one of her patients had a prior dentist who decided to drill holes into all of their teeth and put filling in them because it seemed to the latter that their was a risk for cavities. Said patient now has to pay astronomical bills because those fillings chip often.

My dentist when I was a child refused to drill into a molar of mine that had a black line on top of it, thinking that maybe it wasn't a cavity as would have been the most likely supposition. That tooth has been with me all my life and it has not developed anything at all. 

Or think about democratic countries where there is a chief of the executive branch of government; he has veto power, the ability to refuse to do something.

When people can't take the option to do nothing it's usually one of three things - either they are being kept by a threat of some kind from abstaining, or their emotions are stopping them from making the best choice, or they have some sort of self-centered bias that somehow makes them need to do something where in a more neutral situation they would do otherwise. Josh Olin's former company faced the first situation. The uproar would have been directed at them, and would have affected how their products fared in the future. They had to fire him because otherwise a lot of people would not have bought their wares anymore.

And this is where we see how the action produced from this outrage culture is a lot like bullying. I got this concept from Sgt. Rory Miller; in a protest there's always the implied threat that violence will start if the demands are not met. Others would argue that the threat of consequences keeps people honest - I would counter that it only makes us more cunning with our dishonesty.

For an example, let's look at this unfortunate situation. University student posts pictures of animal cruelty and gets expelled, then made to do community service. In any rational light the story should be done - kid learned a lesson and paid his debt to society. However, look at how thousands of people in the Facebook community still "refused to forgive" him. It's like high school where the cliques band together to ostracize the weird kid except now with the Internet there is no escape for the poor guy. The kid already paid his dues for the crimes he committed, and yet people are still not letting this go - a hallmark of bullying.

Second thing I have a problem with is how everyone keeps tying this to free speech. Josh Olin has said he was trying to inspire dialogue and his right to free speech was violated; his detractors say that the right to free speech only prevents government from persecuting someone for what they say and doesn't save anyone from the consequences (i.e., online threats and harassment) that would arise from his words.

(As an aside, I love how that argument frames the vitriol being rained down on Mr. Olin as somehow a logical occurrence of cause-and-effect; it's classic victim blaming right there. It's only natural that someone lose their livelihood, get death threats, be harassed, etc..) 

To that I want to say, that while it is true that the right to free speech pertains to prohibitions on government actions only, that kind of limitation was built in because monitoring and policing the statements of everyone in a country would have been impossible to implement in a fair and just manner. This does not mean that just because it isn't against the law it's not a bad thing to do. 

Like in my country right now there was a recently passed law prohibiting the production, sharing, distribution, and sale of compromising videos and photos of people who at the time of recording should have had a reasonable expectation of privacy. Before this, there was no such clear regulation that could be applied to these situations, and there was a huge bonanza of sex videos/voyeur videos being trafficked around; some of famous celebrities would even be the topic of news programs and talk shows. Said talk shows would even show these videos, with the naughty parts censored of course - but in a manner that still preserved the prurience of the content. D-list celebrities would even make one of these videos themselves to get some measure of relevance in the public eye. And some unscrupulous lovers would even record their trysts in order to blackmail their partners later on. Law or no law, these things people were doing were already bad. 

Same with the free press issue, just because no one's getting arrested doesn't mean all these people ganging up on him is acceptable. 

Also, speech comes with a hefty piece of responsibility; if you're putting yourself out there essentially you are implying that what you have to say matters, to the point that you are willing to cast attention to yourself and suffer the consequences of whatever opinion you are professing. Now what, if at all, are all of Mr. Josh Olin's detractors risking here? What are their stakes in this discussion? What do they lose - like, if they don't put Mr. Olin down do they have to be slaves at a plantation somewhere? 

Mr. Olin already paid a big price, while the great outrage machine will be moving on to another target, smug in their numbers and anonymity. That right there makes the trolls lose any credibility in my eyes. And I personally do not like being coerced into doing anything - when people try bullying tactics on me I choose to do the opposite of what they want. I would advise any such victim of outrage culture to do the same.

Wednesday, May 28, 2014

I had a huge fear inside me recently. I came into the IT world solely on a whim; I'm not originally from any institution remotely connected to computers. I am woefully behind on skills and experience with the technologies assigned to me; and prior to getting this job I had to send my resume out hundreds of times. I went to interviews almost everyday for three months before miraculously getting a choice between two jobs - one for a C++ gig, the other making mobile games. 

I screwed up the choice, and had to resign after two months due to burnout. I then had to do three more months of job searching before I got to my current position. 

I didn't go into this with a naive mindset; I took time off to study computer science concepts, several languages, and web development. I really wanted to thrive and make a good accounting of myself. It galls me that all my effort could come to naught arbitrarily. 

As of now I get assigned to projects only occasionally; to pass the time I try to practice coding or do training sessions. I volunteer for whatever and don't complain about what task is given to me, even if said task isn't really about web development. I want to do more exciting stuff, but I'm not getting assigned to the right projects for that; and my fear is that if this continues I won't be able to advance my expertise far enough to get into a better company, let alone become a key part of my current one. 

There's also the fear that the path I am on might not pay off; even though I am trying my hardest it's like I'm still getting left behind. I've been in a funk about it for the past two weeks. What finally snapped me out of it was realizing something about the martial arts I practice. I remembered that my school's grandmaster was very powerful - I've seen videos of him in action. My current teacher may not have been on the same level, but he's still very good. And I may never get to be the same level as them, but I'll still gain something from practicing. The fact that the teaching works is proven by the grandmaster and master's prowess. And my practice for the past two years has not only made me stronger, it's cured some recurring maladies that I've had since I was ten. 

I may not know if the path I am on will lead to success and contentment, but I know the path of martial arts I am on right now is real, and it has given back to me more than I expected. And so even if I look like an idiot practicing the drills in public, even if it comes to pass that I won't be able to pass on what was taught to me, I will still continue to practice. Even if I have to keep doing standing stake in a smelly restroom cubicle, I'll do it; my life belongs to the martial arts. It will help me survive even when everything else turns to shit.

My New Idol


The show above focused on Mr. Narayana Murthy, co-founder of India's third-largest IT services company. I came across him because of an assignment I needed to do for a Coursera course I am currently taking. The course is about utilizing emotional and social competencies in order to become a more effective leader; the assignment was for us to determine which competencies Mr. Murthy displays on the life experiences he recounts during this interview. 

I've never really bothered myself with the Indian scene before; I am really impressed at the kind of leadership Mr. Murthy shows during their talk. Being in the IT services field myself, I can appreciate the hardship he must have endured to get his venture off the ground. His example makes me agree that the technical skills only matter inasmuch as getting one's foot through the door is concerned; these emotional and social skills make the difference.

However, I can't quite shake the idea that this thesis mostly works for people in management positions, and probably in fields that require collaboration. For knowledge workers or people concerned with individual output the technical skill might matter more; in which case it is mastery of the field which is the decider.

Ultimately, in my opinion you need the "soft skills" to rise up and secure a good future for yourself; it is unfortunate but programming can be a dead end for generalists and specialists whose technology the world has passed by. But the kind of work you get into is still going to be determined by your skill; the better you are, the more opportunities are open to you. You have more options, and this means you are more robust - i.e., better able to thrive under less-than-ideal conditions.