Tuesday, 13 September 2016

Web Tutorial: The Browser Butterfly (Part 1/3)

Nature sometimes inspires. And at the risk of sounding like some tree-hugger wannabe, the sight of a butterfly flitting around my neighbor's potted flowers spurred me to create my own version - a browser-based version, that is.

Imagine a butterfly moving around your web page, in random directions and speeds...

Done imagining? Ponder no more; we're going to make this a reality.

This web tutorial leverages heavily on CSS3 animations, 3D transformations in particular, and JavaScript Timer functions. But in the first part of this tutorial, we're just going to concentrate on building the butterfly.

This is the initial HTML. We start off with a div tag and assign it an id of butterfly_wrapper. This is the div that will be moved around the screen, rotated and resized at random later on. It will contain the wings of the butterfly.
<html>
    <head>
        <title>Butterfly</title>

        <style type="text/css">

        </style>

        <script>

        </script>
    </head>

    <body>
        <div id="butterfly_wrapper">

        </div>
    </body>
</html>


Here's the CSS code for butterfly_wrapper. We're giving it a position of absolute because it needs to move around the page and avoid displacing other DOM objects while it does so. Width and height are set to an initial value of 150 pixels. The final product is not going to be that big, but let's set it at this size to make things clearer.
    <style type="text/css">
        #butterfly_wrapper
        {
            width:150px;
            height:150px;
            position:absolute;
        }
    </style>


To make things visually easier for us, let's add this to the code. This ensures that all divs will have a nice red border so you can see what's happening as we change the code.
        div {border:1px solid #FF0000;}

        #butterfly_wrapper
        {
            width:150px;
            height:150px;
            position:absolute;
        }


See?


Now, let's put in some placeholders for the wings. These are divs that are assigned the CSS class leftwings and rightwings, respectively.
    <div id="butterfly_wrapper">
        <div class="leftwings">

        </div>
        <div class="rightwings">

        </div>
    </div>


The CSS classes are like so. Both leftwings and rightwings take up 50% of butterfly_wrapper's width, and 100% of its height. They will adhere to the top of butterfly_wrapper. leftwings will stick to the left side of butterfly_wrapper, while rightwings will stick to the right side.
        div {border:1px solid #FF0000;}

        #butterfly_wrapper
        {
            width:150px;
            height:150px;
            position:absolute;
        }

        .leftwings,.rightwings
        {
            position:absolute;
            width:50%;
            height:100%;
            top:0;
        }

        .leftwings
        {
            left:0;
        }

        .rightwings
        {
            right:0;
        }


So far, this is what you should see.


OK now, for leftwings and rightwings, we include two divs in each of them, with a CSS class of perspective. This will be necessary for 3D transformations later on.
    <div id="butterfly_wrapper">
        <div class="leftwings">
            <div class="perspective">

            </div>
            <div class="perspective">

            </div>
        </div>
        <div class="rightwings">
            <div class="perspective">

            </div>
            <div class="perspective">

            </div>
        </div>
    </div>


The CSS class for perspective is like so. They'll take up the full width of their parent divs (which in turn are 50% of butterfly_wrapper's width) and only 50% of the height. That's because  the butterfly's wings are segmented into upper and lower wings.
        .leftwings
        {
            left:0;
        }

        .rightwings
        {
            right:0;
        }

        .perspective
        {
            position:relative;
            width:100%;
            height:50%;
        }


So far so good?


Now add a div inside each of these divs. These divs will have two classes each. This is deliberate as the classes have overlapping style elements. We could simply style each wing individually, but that would entail a fair bit of unnecessary repetition.
    <div id="butterfly_wrapper">
        <div class="leftwings">
            <div class="perspective">
                <div class="upperwing upperwing_left">

                </div>
            </div>
            <div class="perspective">
                <div class="lowerwing lowerwing_left">

                </div>
            </div>
        </div>
        <div class="rightwings">
            <div class="perspective">
                <div class="upperwing upperwing_right">

                </div>
            </div>
            <div class="perspective">
                <div class="lowerwing lowerwing_right">

                </div>
            </div>
        </div>
    </div>


Pay close attention - this next part could be tricky. The CSS classes upperwing and lowerwing determine the sizes of the upper and lower wings. This is true for both left and right wings. Upper wings are larger, and lower wings smaller. This is reflected in the width and height values. lowerwing has top set to 0 in order to keep the upper and lower wings from looking disjointed. This may not be strictly necessary, but good to have.
        .perspective
        {
            position:relative;
            width:100%;
            height:50%;
        }

        .upperwing
        {
            position:absolute;
            width:100%;
            height:100%;
        }

        .lowerwing
        {
            position:absolute;
            top:0;
            width:80%;
            height:80%;
        }


Starting to look a mite complicated, isn't it?


Now, we shape the wings based on their positions. You may want to refer to this documentation on the border-radius property.
        .upperwing
        {
            position:absolute;
            width:100%;
            height:100%;
        }

        .upperwing_left
        {
            border-top-left-radius: 10%;
            border-top-right-radius: 80%;
            border-bottom-right-radius: 0%;
            border-bottom-left-radius: 30%;
        }

        .upperwing_right
        {
            border-top-left-radius: 80%;
            border-top-right-radius: 10%;
            border-bottom-right-radius: 30%;
            border-bottom-left-radius: 0%;
        }

        .lowerwing
        {
            position:absolute;
            top:0;
            width:80%;
            height:80%;
        }

        .lowerwing_left
        {
            right:0;
            border-top-left-radius: 30%;
            border-top-right-radius: 0%;
            border-bottom-right-radius: 80%;
            border-bottom-left-radius: 10%;
        }

        .lowerwing_right
        {
            left:0;
            border-top-left-radius: 0%;
            border-top-right-radius: 30%;
            border-bottom-right-radius: 10%;
            border-bottom-left-radius: 80%;
        }


Ah yes, starting to take shape!


Now add this code. This styles both upperwing and lowerwing classes with a nice radial pattern I shamelessly generated from colorzilla. Feel free to apply your own colors!
        .perspective
        {
            position:relative;
            width:100%;
            height:50%;
        }

        .upperwing,.lowerwing
        {
            background: #FF4400; /* Old browsers */
            background: -moz-radial-gradient(center, ellipse cover, #FF4400 0%, #FFEE00 50%, #FF4400 100%); /* FF3.6-15 */
            background: -webkit-radial-gradient(center, ellipse cover, #FF4400 0%,#FFEE00 50%,#FF4400 100%); /* Chrome10-25,Safari5.1-6 */
            background: radial-gradient(ellipse at center, #FF4400 0%,#FFEE00 50%,#FF4400 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
            filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#FF4400', endColorstr='#FF4400',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
        }

        .upperwing
        {
            position:absolute;
            width:100%;
            height:100%;
        }


Getting warmer...


Do this to your code. This will remove the red border.
    div {border:0px solid #FF0000;}


Damn, that's pretty.


We've created the basic shape of the butterfly. But it's cold and lifeless as a fossil. Soon, we'll be emulating Mary Shelley's Frankenstein and injecting some life into it!

Next

Animating the wings!

Tuesday, 6 September 2016

Social Media Mishap

Last year around this time, I was employed in an SME as an in-house web developer. How that came about is a tale for another day. This story is about an ex-colleague. My colleague was dismissed from her position. And how it happened will be a good bit of food for thought.

Things had been a little tense between the CEO and her lately, with her being very vocal about her displeasure as to how things were transpiring. It all came to a head one fateful evening when she posted an epic rant on Facebook, not naming any names, but using very colorful language and leaving no doubt, to those in the know, as to whom she was referring to. As it happened, the HR Manager was on her Friends List, and saw it. This was escalated to the COO, who in turn made it known to the CEO that this employee was dissing him on Social Media. There was an enquiry, which took place over some conversation where my now ex-colleague was asked to explain herself, after which she voluntarily resigned.

Tendering.

That's not being dismissed...

Splitting hairs a bit here, aren't we? Technically, yes, she was not dismissed and thus she had no grounds to sue for unfair dismissal. But if she had not resigned, things would have gotten very unpleasant. In spirit, there's not much difference there.

There have been several incidences of employees being dismissed due to something they posted on Social Media, such as Twitter, Facebook and Instagram. So many that I won't even bother to link you to an example. Just do a Google search.

That sucks!

Sure it does. It's a crappy thing to happen to anyone. But allow me to explain my position here.

My ex-colleague's a nice lady. Sure, she's a little dramatic and hot-tempered. So she isn't perfect. But we do get along and I wish her no ill. That said, I harbor no sympathy for her in this situation. She had it coming.

Look, bosses are only human. They have their biases, their flaws and their insecurities. Some bosses prefer to hire and promote pretty young things in skirts. Some bosses have hare-brained ideas that they will defend even in the face of all evidence to the contrary. Some bosses, plainly speaking, need to grow the hell up. But generally, even the most mature, understanding and enlightened boss will not take kindly to being ticked off in public for the world to see, especially when he has control over the employment status of the one doing the ticking off. What, you think that sounds unfair? Spoiler: No one claimed life was fair.

What she did wrong

Other than piss off someone who had the power to fire her?

Here goes - she added the wrong people to her Friends List. That was HR, for crying out loud. My ex-colleague complained bitterly that HR had backstabbed her in the entire debacle.

Wait, what?

As far as I'm concerned, HR did more or less what one should expect of HR. Between the company and you, whose side does one realistically expect HR to take? Here's a clue - not yours. Not unless it's a legal matter - in which case HR, while not on the company's side, is still not on your side. She's on her own side, in military lingo, covering her own ass. And if you believe otherwise, if you harbor any hope of surviving in the corporate world at all, you need to have that oh-so-endearing naivete slapped out of your head ASAP. You are a cog in a machine, no more. Does a mechanic concern himself with a cog, or the machine?

Repeat after me - HR is not your friend. In fact, this applies to your colleagues as well. They are not your friends. Sure, HR is supposed to be personable and friendly. HR is supposed to make you feel that you can confide your problems at work, in her. HR is supposed to act like she is your best buddy in the company. But if you believe her, how do I put this delicately - nah, screw it - you're a fucking idiot.

But HR is really my friend. We've known each other since kindergarten...

In that case, as a friend, you should jolly well not put HR in the position where she has to choose between friendship and professional duty. Rant on Facebook if you must, but filter her from the post. She can't possibly be expected to report what she doesn't see, right?

Didn't see
a thing!

My colleague put HR in a position where it was clear some action had to be taken. Sure, HR could have taken her aside and advised her to take the post down, without escalating it. But the only thing that is clear is that HR had to do something. It's unfortunate that the route most ruinous to my ex-colleague was taken, but here's the thing - what in the blue hell was HR doing on her Friends List anyway?

Honestly, had I been the CEO, I would have gotten rid of that ex-colleague too. Not because I can't man up and take criticism. But because anyone who is stupid enough to add HR to their Friends List and then bitch about the company on Facebook, can't be trusted to work for me. I mean, if you can't even exercise that little bit of common sense, what can you do?

Get fired up, but don't get fired.
T___T

Friday, 2 September 2016

WhatsApp and the Great Privacy Controversy

There are many, many users upset with WhatsApp right now. And that's being generous. As the weeks go by, some of these users have started moving over to rival messaging services. The noise on Twitter has been deafening.
Et tu, WhatsApp?

And it's all down to WhatsApp's latest controversial decision, announced on 25th August - to share collected user phone numbers with its parent company, Facebook.

Back when Facebook acquired WhatsApp, founder Jan Koum reassured the current user base that WhatsApp was as committed to data privacy as ever. The users, rightly or wrongly, see this move as betrayal. Even users who don't have a Facebook account (and therefore aren't affected) don't seem to approve much of this.

Maybe it's the principle of the thing, eh?

WhatsApp has mitigated the blow by offering an opt-out to users who wish to keep their WhatsApp and Facebook accounts separate, though if you want to do so, you'd better hustle. There's a 30-day window to do it, and the window's closing by the day. Not that I think it'll make an ounce of difference. According to some news sources, WhatsApp will still be sharing information with Facebook, for, y'know, better integration.

What's with all the angst?

I'm looking upon all this outrage with bemusement. Sure, I get it. Privacy is important. Sure, this could be considered a dick move. And yes, I'm not exactly thrilled about the turn of events. And I'm aware that Facebook and WhatsApp face some kind of legal inquiry from the Federal Trade Commission over this very issue.

But can anyone honestly tell me this wasn't expected? Come on.

From the day WhatsApp gave up its autonomy to Facebook, this was always par for the course. I've said this before here, and I'll say it again: Facebook is not a charity. It is a business entity. The purpose of its existence is not to provide us with free apps for life. There's a catch. There's always a catch.

Know how much Facebook paid to acquire WhatsApp back then? A whopping 22 billion USD.

How much did we pay for our Facebook accounts? How about our WhatsApp accounts? I don't know about you, but to date, I've paid a big fat zero. And you know what they say about free lunches. (Hint: They hail from the same hometown as Santa Claus) Facebook doesn't charge us to have an account, or to use WhatsApp. But it does have to make some kind of profit, and in this case, it will probably come in the form of advertising dollars as the data is shared with marketers who wish to push their products.

But Jan Koum said...

Yes, I'm aware of what he said. In fact, I'll reproduce it below.

"If partnering with Facebook meant that we had to change our values, we wouldn’t have done it. Instead, we are forming a partnership that would allow us to continue operating independently and autonomously. Our fundamental values and beliefs will not change. Our principles will not change."

This was said two years ago. What's happened since then? JavaScript came up with several exciting new frameworks. Tech companies rose and fell. Yahoo and LinkedIn are being sold. Windows 10 emerged on the market. Should I go on? The thing is, in the tech business, change happens all the damn time, and happens at a scary rate. You adapt or die. Do we really want to hold Koum to something he said two entire years ago?

Other messager apps

Don't like it? Still miffed? Want to stick to those principles? There are always other messaging services. Or you could simply delete your Facebook account to make a point. You'll live.

Good chat, folks. Ping you again sometime.
T___T

Tuesday, 30 August 2016

Pokémon Go Fever

A new cringe-worthy craze has taken Singapore by the scruff of her neck for the past month, and consumed the hearts and minds of Singaporeans of all ages, from all walks of life. My Facebook feed and WhatsApp chats are filled with screenshots.

No, it ain't the Rio Olympics. It's a mobile app, and goes by the name of Pokémon Go.

And no, this is not an app review. That would involve me installing and playing it. Hell will freeze over before I install this sucker of memory and battery life on my mobile.

This hellishly addictive app.

Pokémon Go is an augmented reality game created by Niantic, who created the excellent Ingress  years earlier. While Ingress is also an augmented reality game and enjoyed a certain amount of success, its reach wasn't as mainstream as Pokémon Go. The cuteness of the monsters and the success of the original Pokémon franchise might have something to do with it, because for the life of me, I can't see what objective there is other than hunt, capture, and hunt some more.

As far as augmented reality games go, Pokémon Go certainly isn't the first. As mentioned earlier, it was preceded by Ingress. One of the earliest forerunners of the genre was SpecTrek which I've tried, but won't be reviewing either. Worthy mentions include Zombies, Run! (which I have installed) and Night Terrors which is next on my install list. Now, those might be worth reviewing. Watch this space!

From the day it was announced that Pokémon Go would be in Singapore, all hell has broken loose. Stories of near-accidents in traffic, vandalism and gangsterism are running riot through cyberspace. And it isn't just confined to Singapore, either. In fact, globally, it gets worse. Robberies have been reported, with the robbers making use of the app to lure unsuspecting victims. Actual accidents have happened.

In the startup I'm currently working for, the tech lead takes us out on Pokémon hunts during lunch break. Oh, the Pokémonity. Other companies aren't as generous, though, with some of my friends reporting that HR has sent out memos explicitly forbidding staff to play the game during their shift.

I recently went out for supper with the guys, and was absolutely flabbergasted when they started showing me their collection. You know things have gotten really sad when a bunch of 40 year olds whom you're supposed to be lepaking with over coffee, now take you on slow drives around the island to find gyms and hunt down these cute little bastards.

I remember the days where my buddies would irritate the living heck out of me by constantly sending me pictures of naked women, or videos of them performing assorted sex acts, through WhatsApp. Not because I have anything against porn - it's a lovely industry and creates jobs! - but because this crap occupies my storage until I take the trouble to painstakingly delete them. Those days are gone and I mourn them - because these same clowns have started sending me Pokémon pics instead. Some are even sending me Pokémon porn pics!

NSFW


Seriously dudes, what the fuck?!

The Silver Lining

It looks like Pokémon Go has at least gotten people to get off their arses and go for brisk walks under the blazing sun to hatch those Pokémon eggs (call me back when this stops sounding weird), though their posture and situational awareness still leaves a lot to be desired.

Some enterprising folks have actually started up businesses riding on the popularity of the game. From luring players to retailers and food stops, and even hiring out transport to visit Pokéstops.

And that's not even mentioning the sales from Pokémon merchandise such as toys, trading cards and accessories! While I'm on that, check out the Pokeburgs by Hashtag Burgers from the Land Down Under!

The marketing behind the phenomenon is worth a study. We have senior citizens playing this shit, for Chrissake.

When will Pokémon Go... away?
T___T

Friday, 26 August 2016

Film Review: Nerve

With much of the world tuned in to Social Media and mobile apps, it was a matter of time before a movie was made about an app. Nerve is one such movie. More precisely, Nerve is one such novel, written by Jeanne Ryan, and the movie is based off it.



This movie has been compared to Unfriended for its focus on Social Media. However, unlike Unfriended, it's less about cyberbullying and more about how unpleasant people can be when
they're behind a veil of online anonymity.

Warning - mild spoilers ahead

There are a few decent twists in the tale, and let's leave it at that. Nothing particularly clever, but significant enough that revealing them here would ruin the plot.

The Premise

Nerve is a mobile game that promises to be "Truth or Dare, without the Truth". The game is centered around dares. Users of the app choose to be either Watchers or Players. Watchers pay a fee to well, watch the Players carry out dares within a time limit. Players accept online monetary transactions to carry out dares, and have to be filmed doing it. They lose if they give up, or fail to carry out the dare within the stipulated time limit. On a more sinister note, if any user attempts to contact the authorities and warn them about this app, they are punished.

Nerve cannot be shut down because there is no single server - every Watcher is a server unto themselves, and thus as long as even one Watcher is logged on, the game is online.

"Truth or Dare, without the Truth" turns out to be misleading - while the app does deal primarily in the "Dare" part, there's plenty of "Truth" involved as well. The app gathers personal information of the Players such as addresses, bank accounts and relatives, and uses it against them.

The frenetic tale revolves around a student named Vee who becomes a Player for the first time, and another Player known as "Ian", as they embark on an increasingly dangerous and outrageous series of dares orchestrated by the Watchers.

The Characters

Emma Roberts as Venus "Vee" Delmonico. Much has been said about Emma Roberts being too hot to play shy nerd Vee. Don't know about that, I think she did a pretty decent job, though her thick eyebrows were kind of distracting. The sight of her cavorting around in her underwear with "Ian" wasn't exactly repulsive, but "too hot" wasn't really the first thing that came to mind.

Dave Franco as "Ian", looking suave and oozing the kind of charm his older brother James is known for, he was good in the role. The awkward goofiness he exhibited in Now You See Me and Now You See Me 2, and even more pronounced in Unfinished Business, was absent. In one of the scenes where he and Vee clowned around on a carousel, this was quaintly reminiscent of his turn as Jack Wilder in Now You See Me.

Emily Meade as Sydney, Vee's trampy best bud who seems to really enjoy strutting around without her underwear. She played the role magnificently. The facial expressions, ranging from concern to jealousy to fear, to outright bitchiness - she nailed them all.

Miles Heizer as Tommy, Vee's friend, web tech geek and a cautious presence in her newfound recklessness, delivering rather trite truisms such as "we're using only ten percent of the web". Has a not-so-subtle crush on her, and his tech skills feature prominently throughout the movie.

Machine Gun Kelly as Ty, the tall scary-looking white dude who comes off as a total psycho Player. Really hammed it up and stole the show in the scenes he was in.

Samira Wiley as Azhar. Gorgeous, and cool as hell. One of the adult tech geeks in Miles's crew who eventually save the day. Maybe it's just me, but her vibe wasn't very techie.

Juliette Lewis as Nancy, Vee's mom - possibly the cast's most billable actress. Haven't seen her since Strange Days and Enough, and my, how she's aged. Still a dependable actress though, as she pulls off businesslike bedside manner as a nurse and frantic concern as Vee's mother with aplomb. Didn't have much to do otherwise.

Kimiko Glenn as Liv. There was something endearingly earnest about this Asian as she played one of Vee's friends in the group.

The Mood

Started out with a dull and mundane environment. As the action heated up and the thrills started, most of the story took place at night amid the bright lights of the city. It was dark and gritty in places, but not overly done.

What I liked

The atmosphere was refreshingly "normal" when required. Nothing glitzed up, no teen supermodels posing as students in the school. They even had chubby cheerleaders. Imagine that!

Even the techie scenes were tastefully done. No over-the-top special effects other than clever camera angles that make the viewer feel like they are the computer interacting with Vee, or the various mobile screens interacting with the Watchers.

Vee delivered an awesome monologue as she and Sydney had a confrontation. The intensity of that scene has to be seen to be believed.

What I didn't

Nerve got a little preachy at times, with Miles and Vee delivering lines (monologues in the latter's case) that were less awesome and more superfluous. I mean, we geddit already. Online anonymous trolls are evil. Don't give out your personal information on the web. Yadda yadda.

Can we get back to the movie please?

Conclusion

Nerve is a cautionary tale against putting too mch personal information online. Or, at least, it tries to be. As a thriller, thrill it certainly does. It's a charming low-budget production, and lots of fun.

My rating

8 / 10

Go watch this flick. I dare you.
T___T