Showing posts with label vbscript. Show all posts
Showing posts with label vbscript. Show all posts

Friday, 28 November 2025

Tech skillsets: Go deep or go wide? (Part 2/2)

There are plenty of reasons, though, to choose to generalize rather than specialize. And by that, I mean good reasons, not things like a lack of focus or a limited attention span.

The case for generalizing over specializing

It's dangerous to put all your eggs in one basket. An extreme example is if programmers specialized in VBScript to the exclusion of all else. The probability of those programmers having a job as of 2023, are approaching zero. I love VBScript, but it is what it is. Professionally, I cut my teeth on ASP and VBScript back in the 2000s. But what would have happened had I stubbornly refused to branch out? The thought makes me shudder.

Speaking of branching out, what makes it relatively easy for me to pick up new programming languages and frameworks is that I've been doing it repeatedly over the years. Instead of focusing on one specific thing to get good at, I identified certain things one new area had with the one I already knew, and worked from there. Got my fingers in as many related pies as possible. And as I learned more new stuff, my frame of reference only got stronger. All the stuff I learned, fed into each other. It's unclear just how good I would be at picking up new stuff if I had specialized instead.

Fingers in many pies.

The other advantage being a generalist gave me, was that I got plenty of attention from cheapskate financially strapped employers who saw the wisdom of getting me to do many different things at once, because I was decent at all those things. And often, for small startups, that's just what they need. The end result was that even in poor economic times, I rarely had trouble finding employment. I did not have to apply only for front-end jobs, or back-end jobs. I could apply to all of them.

Back in the day, I had been working for a law firm and maintaining their corporate website as one of my many duties. When I eventually left for greener pastures, the guy they hired to replace me was a more accomplished network infrastructure guy. More specialized, I would say. I went on to ply my trade as a web developer, but occasionally I would check back on my former company's corporate website to see what was shaking. Imagine my surprise one day when I went to the ABOUT US page where the hotshot attorneys were presented, and found a whole bunch of distorted profile photos! And that was after waiting a good couple minutes for all these images to load.

Apparently my replacement not only did not understand optimizing images for the internet, he also did not know about resizing images to fit the HTML img tag placeholders. He had simply taken the photographs he had been presented with, and used them as-is.

Was that his fault? No, not at all. My then-Manager had specifically wanted a network specialist, as opposed to me, a web developer who could follow simple network instructions. And his wish had been granted. But specialization comes at a cost. Things like image optimization for the web, just weren't covered in the guy's extensive networking knowledge. In the job, not only had I needed to help with network and infrastructure, I'd had to develop web applications and maintain websites, and my skillset had grown accordingly. These were the things the company had learned to take for granted where my position was concerned.

Ultimately...

Let me just say it again - the industry needs both specialists and generalists. Without generalists, specialists would have trouble plugging all the other technical gaps that their very specific skillsets do not cover. Hiring specialists for every area just isn't practical. On the other hand, without specialists, it would be devilishly hard for just generalists to raise the quality of the product to its optimal level.

Most of all, it would be really difficult to be a specialist in a world without generalists. And vice versa. Not only are both needed, the two need each other.

Specially for you,
T___T

Monday, 29 April 2024

What's the best programming language for beginners?

What should be a programmer's first language?

Often, this is not a deliberate choice, more a matter of circumstance. Perhaps a programmer started on QBasic as a kid. Perhaps, like me, the programmer picked it up in school and was made to learn C++ or Java. I would even venture to say very few programmers start out saying I'm going to begin my programming journey with the best, most modern language out there! To begin with, how would they know what constitutes the "best" programming language, or what even is a good programming language? You don't know what you don't know, after all.

Let's learn!

Also, how suitable a programming language is for your purposes also really depends on what your purpose is. Do you want to crunch data? Write games? Build web portals?

So, obviously, before we can sort out what the "best" programming language is, perhaps it is more useful to figure out what a programmer's first programming language should be. After all, this choice opens different doors.

For that, we should probably look at a few factors. I can only draw upon languages I've coded in before. as examples, obviously.

Syntax

For this, we look at simplicity of writing code in that language. How intuitive the syntax is, and how few extra keystrokes needed to get something done.

For this, my obvious picks would be Python or Ruby. Less of the semi-colons and curly brackets. Anyone picking either Python or Ruby as a first language, I suspect, would be less likely to give up out of frustration.

Code syntax.

C# and Java is probably among the worst for this. Too many namespaces. Overly verbose syntax. I haven't had many projects that needed to be done in either of these languages, and for that I'm truly grateful.

But the one that takes the proverbial cake, in terms of being cumbersome, would be PHP. The function calls structures are wildly inconsistent, and in addition to semi-colons and curly brackets, it also requires a dollar sign preceding every variable name.

As far as syntax goes, the group of programming languages with visually similar styles - PHP, Java, JavaScript, C and its variants - is such that if you pick one up, the learning curve for the others, at least for the simple stuff, isn't so great. Thus, even if PHP is hideously cumbersome in parts, it benefits from being visually similar to other languages mentioned.

Transferable skills

This measures underlying principles or skills that one will pick up while programming in a certain language, that will be useful when transitioning to another stack. It could be something as simple as similar syntax (as mentioned earlier) or strong data typing.

Or it could be something so ubiquitous that no matter what stack you're in, you're almost certainly going to encounter it. A great example of this would be SQL. No matter what kind of programming you go into, the chances of you needing to access a database at some point, are pretty good. I wouldn't go so far as to say that this makes SQL the number one choice for a programmer's first language, but it makes a great case for being a programmer's second, at least.

Data processing.

For a similar reason, if one wanted to go into web development, it's almost impossible not to have to deal with HTML, CSS and JavaScript, but learning JavaScript as a first language just for that, is questionable. As a second language, definitely.

Strongly-typed, class-based languages such as Java and C# would be good choices as a first programming language for learning concepts such as Object-Oriented Programming. (PHP and JavaScript kind of implement OOP as well, but in a way that's a little odd). Python would be the choice if one wanted to have a strong foundation in data structures. However, Python's lack of strong typing might work against it as a first language.

Ease of setup

One of the most daunting tasks of learning a language is setting up the environment for it. Java requires the JRE (Java Runtime Environment). PHP requires an Apache server. Python and Ruby, well, you get the idea.

For this, the most fuss-free option has to be JavaScript, hands down.

All major browsers
run JavaScript.

JavaScript runs on all major browsers. You don't need to install anything you probably don't already have. If you're reading this, unless you're reading it on your phone, you have a desktop browser which you can run JavaScript in. It's almost zero setup. Just write your code, and run it in the browser.

For a Windows environment, VBScript is also almost zero effort. All you need to do is write your script, save it with extension "*.vbs" and you can run it by double-clicking it! Unfortunately, I'm not sure how useful knowing VBScript is.

In essence, in the cases of both JavaScript and VBScript, the environment has already been set up for the programmer.

Popular support

No developer plies their trade without consulting a reference of some sort. Textbooks are a valid source, but for the most updated material, we turn to the internet. Portals and forums provide most of these, with each language having large communities of programmers ready to provide support.

Learn by reading, or
by community.

Which programming language has the largest, or best, communities?

That's hard to say. All communities have their fair share of toxic losers who waste little time being condescending and acting like gatekeepers. At the same time, each community also boasts genuine people. I'm not going to waste time detailing how large each programming language's community is relative to others. Suffice to say, they're all (OK, mostly) large enough to be useful.

Generally, the longer they have been around, the larger they tend to be.

Conclusion

Whatever the choice turns out to be, ultimately, there will be benefits to that choice. That is because no matter what language someone chooses for their first programming experience, the fact remains is that they are still engaging in the activity of programming. It's a start. Some starts are better than others, sure, but it's a step. And hopefully the first of many.

Mind your (first) language!
T___T

Tuesday, 22 January 2019

Web Tutorial: The Zombies Run Voiceover

Following several years of playing Zombies, Run!, an urge to duplicate the in-game voiceover hit me. You know the voice that informs you of what you've collected every now and then? Yeah, that one.

Perhaps it was acute boredom or professional curiosity, but that itch would not go away... and today's web tutorial is the result. I really got a kick out of this piece of work, and hope you do too. It's basically a lot of string concatenation in conjunction with the VBScript code I wrote a while back.

So, the objective is to have a program that will say random things like...

"Collected a toolbox."

"Collected a toolbox and an overcoat."

"Collected a toolbox, a box of lightbulbs and two spades."

"Collected a toolbox, a sports bra, three books, five footballs and four handfuls of money."

Hold on, what does this actually do?

Nothing useful, I'm afraid. It's an utterly trivial task. I'm like a kitten with a ball of wool at this point.

Without further ado...

Let's begin with the speech code and a randomizer function. Simple enough, right? Upon running it, you get a voice that says "Collected a", and that's it.
Dim speech

Function getrandomno(min, max)
    Randomize
    getrandomno = (Int((max - min + 1) * Rnd + min))
End Function

speech = "Collected a "

Set VObj = CreateObject("sapi.spvoice")
VObj.Speak speech


Now, you'll want to actually have the voice tell you what items you picked up. Declare two more variables, item and item_name. Then declare an array, items, with four elements. Each of these will be an object you picked up.
Dim speech
Dim item, item_name
Dim items(4)
items(0) = "spade"
items(1) = "toolbox"
items(2) = "sports bra"
items(3) = "shotgun"

Function getrandomno(min, max)
    Randomize
    getrandomno = (Int((max - min + 1) * Rnd + min))
End Function

speech = "Collected a"

Set VObj = CreateObject("sapi.spvoice")
VObj.Speak speech


Finally, set item to a random number between 0 and 3. Then set item_name to the string inside the array items, defined by item. Remember to add a space before it! After that, concatenate item_name to speech. Now the voice should say stuff like "Collected a toolbox" or "Collected a spade", randomly!
Dim speech
Dim item, item_name
Dim items(4)
items(0) = "spade"
items(1) = "toolbox"
items(2) = "sports bra"
items(3) = "shotgun"

Function getrandomno(min, max)
    Randomize
    getrandomno = (Int((max - min + 1) * Rnd + min))
End Function

item = getrandomno(0, 3)
item_name = " " & items(item)

speech = "Collected a"

speech = speech & item_name

Set VObj = CreateObject("sapi.spvoice")
VObj.Speak speech


Yep, give yourself a pat on the back. You've just created the core of what is to be our totally spectacular (but still utterly useless, heh heh) program. Now, not everything is prefaced with "a". You can have "a spade" or "a shotgun", but not "a overcoat". It's simply not something you can take for granted, the English language being what it is. With that in mind, some changes are required.

Change items to a two-dimensional array. The first element is the item name, and the second is the "a" or "an".
Dim items(4)
items(0) = Array("spade", "a")
items(1) = Array("toolbox", "a")
items(2) = Array("sports bra", "a")
items(3) = Array("shotgun", "a")


Let's add a new item to the array items.
Dim items(5)
items(0) = Array("spade", "a")
items(1) = Array("toolbox", "a")
items(2) = Array("sports bra", "a")
items(3) = Array("shotgun", "a")
items(4) = Array("overcoat", "an")


Declare a new variable, quantity, that will hold either "a" or "an".
Dim speech
Dim item, item_name, quantity


Also ensure that you now get a random number from 0 to 4 instead. And set quantity to the first element of the array element in items referenced by item!
item = getrandomno(0, 4)
quantity = items(item)(1)


Change the following lines. Now instead of just referencing one array element from items, we derive item_name from the first array element of that array element, and quantity! And we remove the hardcoded "a" from speech. So now, sometimes we'll get "Collected an overcoat"!
item_name = " " & quantity & " " & items(item)(0)

'speech = "Collected a"
speech = "Collected"


Let's take this further. What if sometimes we want a collective item instead of singular? Like, "a box of lightbulbs" or "a handful of money"?

Simple. We extend the items array, by making each item an array of four elements instead of two. The third element is the collective noun, and the fourth is the "a" or "an". In the latest two elements we've added, the second element is always an empty string. With singular items, the third and fourth elements are always empty strings.
Dim items(7)
items(0) = Array("spade", "a", "", "")
items(1) = Array("toolbox", "a", "", "")
items(2) = Array("sports bra", "a", "", "")
items(3) = Array("shotgun", "a", "", "")
items(4) = Array("overcoat", "an", "", "")
items(5) = Array("lightbulbs", "", "box", "a")
items(6) = Array("money", "", "handful", "a")


Add a new variable, unit.
Dim speech
Dim item, item_name, quantity, unit


Make sure the random number is now between 0 to 6. unit is initially an empty string.
item = getrandomno(0, 6)
quantity = items(item)(1)

unit = ""


Now, if the third element of the array element is not an empty string, that means it requires a unit. In this case, set unit to the value of that third element and concatenate " of" to it. Set quantity to the fourth element instead of the second.
item = getrandomno(0, 6)
quantity = items(item)(1)

unit = ""

if items(item)(2) <> "" then
    unit = " " & items(item)(2) & " of"
    quantity = items(item)(3)
end if


Then concatenate unit between quantity and the item name (ensuring there are spaces between them as well), to get item_name! Now you should occasionally get "Collected a box of lightbulbs" or "Collected a handful of money".
item = getrandomno(0, 6)
quantity = items(item)(1)

unit = ""

if items(item)(2) <> "" then
    unit = " " & items(item)(2) & " of"
    quantity = items(item)(3)
end if

item_name = " " & quantity & " " & unit & " " & items(item)(0)

Now for something trickier...

What if you wanted plural items? Like "spades" instead of "spade"? Not every plural simply has an "s" appended to the end. "Boxes" and "Hippopotami" are strong examples.

For this, we'll need to modify the items array again. This time, each element should be an array of five elements instead of four. The fifth element (here's looking at you, Bruce Willis!) will hold the plural form of the item name, or the plural form of the collection.
items(0) = Array("spade", "a", "", "", "spades")
items(1) = Array("toolbox", "a", "", "", "toolboxes")
items(2) = Array("sports bra", "a", "", "", "sports bras")
items(3) = Array("shotgun", "a", "", "", "shotguns")
items(4) = Array("overcoat", "an", "", "", "overcoats")
items(5) = Array("lightbulbs", "", "box", "a", "boxes")
items(6) = Array("money", "", "handful", "a", "handfuls")


Then we set quantity to a random number between, say, 1 to 5.
item = getrandomno(0, 6)
quantity = getrandomno(1, 5)


At the If block, we add an Else condition, and surround the entire block with another If block.
if quantity = 1 then
    if items(item)(2) <> "" then
        unit = " " & items(item)(2) & " of"
        quantity = items(item)(3)
    else
        quantity = items(item)(1)
    end if
else

end if


quantity is singular, so we'll replace the value of quantity with the appropriate "a" or "an". item_name is, quite naturally, the first element of the array.
if quantity = 1 then
    if items(item)(2) <> "" then
        unit = " " & items(item)(2) & " of"
        quantity = items(item)(3)
    else
        quantity = items(item)(1)
    end if

    item_name = items(item)(0)
else

end if


If quantity is more than 1, we use the plural form (the fifth element). And instead of "a" or "an", we use the number! So, no changes to quantity.

If the item is collective, we use the plural form of the collective noun. If not, we simply use the plural form of the item.

Now, you're going to get stuff like "Collected 5 shotguns" or "Collected 3 boxes of lightbulbs", in addition to the ones you already have!
unit = ""

if quantity = 1 then
    if items(item)(2) <> "" then
        unit = " " & items(item)(2) & " of"
        quantity = items(item)(3)
    else
        quantity = items(item)(1)
    end if   

    item_name = items(item)(0)
else
    if items(item)(2) <> "" then
        unit = " " & items(item)(4) & " of"
        item_name = items(item)(0)
    else
        item_name = items(item)(4)
    end if
end if


For the final trick...

What if you wanted different items in different quantities? Like, "a spade and three boxes of lightbulbs"? This one gets a bit more complicated, so I'll need you to pay attention.

First, we need a new variable, no_items.
Dim speech
Dim item, item_name, quantity, unit, no_items


Then we need two new arrays, collections and used. We'll arbitrarily assume that the largest number of different item types will be 5.
Dim speech
Dim item, item_name, quantity, unit, no_items
Dim collections(5), used(5)


After the getrandomno() function, we're going to set no_items to a number between 0 and 4.
Function getrandomno(min, max)
    Randomize
    getrandomno = (Int((max - min + 1) * Rnd + min))
End Function

no_items = getrandomno(0, 4)


Now, wrap all that code we wrote earlier, in a For loop iterating from 0 to no_items. The steps will be there - we're just going to repeat it i number of times.
no_items = getrandomno(1, 4)

for i=0 to no_items step 1
    item = getrandomno(0, 6)
    quantity = getrandomno(1, 5)

    unit = ""

    if quantity = 1 then
        if items(item)(2) <> "" then
            unit = " " & items(item)(2) & " of"
            quantity = items(item)(3)
        else
            quantity = items(item)(1)
        end if   

        item_name = items(item)(0)
    else
        if items(item)(2) <> "" then
            unit = " " & items(item)(4) & " of"
            item_name = items(item)(0)
        else
            item_name = items(item)(4)
        end if
    end if

    item_name = " " & quantity & " " & unit & " " & item_name
next


At the end of it, set the current element of the collections array to the value of item_name.
no_items = getrandomno(1, 4)

for i = 0 to no_items step 1
    item = getrandomno(0, 6)
    quantity = getrandomno(1, 5)

    unit = ""

    if quantity = 1 then
        if items(item)(2) <> "" then
            unit = " " & items(item)(2) & " of"
            quantity = items(item)(3)
        else
            quantity = items(item)(1)
        end if   

        item_name = items(item)(0)
    else
        if items(item)(2) <> "" then
            unit = " " & items(item)(4) & " of"
            item_name = items(item)(0)
        else
            item_name = items(item)(4)
        end if
    end if

    item_name = " " & quantity & " " & unit & " " & item_name

    collections(i) = item_name
next


After setting speech to "Collected", instead of concatenating one item_name to speech, we add all the strings from the collections array. Use a For loop to iterate from 0 to no_items.
speech = "Collected"

for i = 0 to no_items step 1

next

'speech = speech & item_name


If we're not at the end of the list of items, concatenate the value of the current element of collections and a comma to speech.
for i = 0 to no_items step 1
    if i < no_items then
             speech = speech & collections(i) & ","
    else

    end if
next


If we're at the end of the list, there are two possibilities. One, there is only one item type in the collections array, i,e, i is 0. The other is that there are multiple item types and we're at the end.
for i = 0 to no_items step 1
    if i < no_items then
             speech = speech & collections(i) & ","
    else
        if i = 0 then
       
        else
       
        end if
    end if
next


If it's the former, just concatenate the value of the current element of collections to speech. If there were more than one item and we're at the end, concatenate to speech the string " and" (take note of the space!) followed by the value of the current element of collections.
for i = 0 to no_items step 1
    if i < no_items then
             speech = speech & collections(i) & ","
    else
        if i = 0 then
            speech = speech & collections(i)
        else
            speech = speech & " and" & collections(i)
        end if
    end if
next


Now try it!

For the most part, you'll get beautifully constructed speeches like "Collected a sports bra, three spades, two boxes of lightbulbs and a handful of money". But wait... there's a problem. Once in a while, the randomizer repeats itself. So sometimes you may get something like "Collected a spade and two spades". That's not what we want at all, so...

Here, the used array will store all the unique numbers that have been generated.

Remember the line to randomize what item you get? Well, wrap that in a Do-while loop. It should execute at least once. And keep executing while the returned value of the inuse() function with item passed in as an argument, is true. So if the loop is exited, item is guaranteed to be unique within the used array.

And then set the current element of the used array to item.
for i = 0 to no_items step 1
    do while inuse(item) = true
        item = getrandomno(0, 6)
    loop

    used(i) = item

    quantity = getrandomno(1, 5)


Then let's write the inuse() function. This basically tells you if item is already taken.
Function getrandomno(min, max)
    Randomize
    getrandomno = (Int((max - min + 1) * Rnd + min))
End Function

Function inuse(num)

End Function


The parameter is num. Declare dupe as a variable and set it to false. At the end of the function, return dupe.
Function inuse(num)
    Dim dupe

    dupe = false

    inuse = dupe
End Function


Run a For loop that iterates through no_items. If at any point the value of the current element of used matches num, dupe is set to true.
Function inuse(num)
    Dim dupe

    dupe = false

    for j = 0 to no_items step 1
        if used(j) = num then
            dupe = true
        end if
    next

    inuse = dupe
End Function


There, you've got it!

Just for shits and giggles, let's add a whole lot more stuff into the items array!
Dim items(15)
items(0) = Array("spade", "a", "", "", "spades")
items(1) = Array("toolbox", "a", "", "", "toolboxes")
items(2) = Array("sports bra", "a", "", "", "sports bras")
items(3) = Array("shotgun", "a", "", "", "shotguns")
items(4) = Array("overcoat", "an", "", "", "overcoats")
items(5) = Array("lightbulbs", "", "box", "a", "boxes")
items(6) = Array("money", "", "handful", "a", "handfuls")
items(7) = Array("axe", "an", "", "", "axes")
items(8) = Array("trousers", "", "pair", "a", "pairs")
items(9) = Array("food", "", "tin", "a", "tins")
items(10) = Array("book", "a", "", "", "books")
items(11) = Array("fuel", "", "can", "a", "cans")
items(12) = Array("pain meds", "", "bottle", "a", "bottles")
items(13) = Array("football", "a", "", "", "footballs")
items(14) = Array("radio", "a", "", "", "radios")


Don't forget to change the random number generator code!
item = getrandomno(0, 14)


Have fun with your program! Better yet, if you haven't already, check out Zombies, Run!.

Collected a thank-you, good-bye and a see-you-again!
T___T

Saturday, 19 August 2017

Web Tutorial: Text to Speech

Hey...

You know how, in those science fiction movies, the computer always talks to its user? Like, literally? Well, a close approximation of this is possible if you're using Windows and you know VBScript. You need to write the script and save it in the correct directory.

Today, I'm going to show just how.

Create a text file and save it with the extension of ".vbs". For the moment, save it anywhere you like. Double-clicking on it should execute it, if you're on a Windows computer. If not, tough shit.

First, declare a variable named speech. Then assign something pronounceable for the computer to speak.
Dim speech

speech="Hello world"


Next, create an object VObj by calling the CreateObject() function, passing in the argument "sapi.spvoice".

That ensures that the object you create is a voice activated object.
Dim speech

speech="Hello world"
Set VObj=CreateObject("sapi.spvoice")


Finally, use this object to run the Speak() method, and pass in the variable speech. You hear that? Depending on your settings and Windows version, you should be hearing either a deep male voice or a (equally deep) female voice.

Dim speech

speech="Hello world"
Set VObj=CreateObject("sapi.spvoice")
VObj.Speak speech

But you know what? "Hello world" is boring. Let's add a bit of zing to it. Let's make the voice greet you according to the time of the day.

Declare a second and third variable, greeting and currenthour.
Dim speech,greeting
Dim currenthour

speech="Hello world"
Set VObj=CreateObject("sapi.spvoice")
VObj.Speak speech


Set the variable currenthour to the, well, current hour, using the Hour() function, passing in the Now() function as an argument. You'll get a number from 0 to 23.
Dim speech,greeting
Dim currenthour

currenthour=Hour(Now())

speech="Hello world"
Set VObj=CreateObject("sapi.spvoice")
VObj.Speak speech


Now, using multiple If conditionals, set the greeting variable according to the time of the day.
Dim speech,greeting
Dim currenthour

currenthour=Hour(Now())

if currenthour<=12 then
    greeting="Good morning, "
end if

if currenthour>12 and currenthour <=18 then
    greeting="Good afternoon, "
end if

if currenthour>18 then
    greeting="Good evening, "
end if

speech="Hello world"
Set VObj=CreateObject("sapi.spvoice")
VObj.Speak speech


Next, concatenate the greeting variable to your name, and set it to the variable speech. Run your code. Does the computer give you a nice greeting?
Dim speech,greeting
Dim currenthour

currenthour=Hour(Now())

if currenthour<=12 then
    greeting="Good morning, "
end if

if currenthour>12 and currenthour <=18 then
    greeting="Good afternoon, "
end if

if currenthour>18 then
    greeting="Good evening, "
end if

speech=greeting & ", Teochew Thunder."
Set VObj=CreateObject("sapi.spvoice")
VObj.Speak speech


Let's make things even more interesting. Make the computer say random things according to the time of the day. For that, we'll create a randomizer function, and define more variables - max, min, randomno and randomstatement. Set max to 3 and min to 1. That's because we're only going to have three random statements for each time period.
Dim speech,greeting,randomstatement
Dim currenthour
Dim max,min
Dim randomno
max=3
min=1

Function getrandomno(min,max)
    Randomize
    getrandomno=(Int((max-min+1)*Rnd+min))
End Function

currenthour=Hour(Now())

if currenthour<=12 then
    greeting="Good morning, "
end if

if currenthour>12 and currenthour <=18 then
    greeting="Good afternoon, "
end if

if currenthour>18 then
    greeting="Good evening, "
end if

speech=greeting & ", Teochew Thunder."
Set VObj=CreateObject("sapi.spvoice")
VObj.Speak speech


Now, we're going to set randomno to a rand0m number generated by the function getrandomno(), then set the randomstatement variable to the result, using a Select Case block. I've set the  different phrases, but feel free to make your own!
Dim speech,greeting,randomstatement
Dim currenthour
Dim max,min
Dim randomno
max=3
min=1

Function getrandomno(min,max)
    Randomize
    getrandomno=(Int((max-min+1)*Rnd+min))
End Function

currenthour=Hour(Now())

if currenthour<=12 then
    randomno=getrandomno(min,max)
    Select Case randomno
        Case 1
    randomstatement="You're looking sharp today."
        Case 2
    randomstatement="Rise and shine!"
        Case Else
    randomstatement="Had your coffee yet?"
    End Select

    greeting="Good morning, "
end if

if currenthour>12 and currenthour <=18 then
    randomno=getrandomno(min,max)
    Select Case randomno
        Case 1
    randomstatement="Hard at work, I see."
        Case 2
    randomstatement="Lovely weather!"
        Case Else
    randomstatement="I love your hair."
    End Select

    greeting="Good afternoon, "
end if

if currenthour>18 then
    randomno=getrandomno(min,max)
    Select Case randomno
        Case 1
    randomstatement="Isn't it a little late?"
        Case 2
    randomstatement="Time for bed!"
        Case Else
    randomstatement="The moon's out tonight."
    End Select

    greeting="Good evening, "
end if

speech=greeting & ", Teochew Thunder."
Set VObj=CreateObject("sapi.spvoice")
VObj.Speak speech


Next, concatenate randomstatement to speech. And run your code. Multiple times. Does it say something different each time?
Dim speech,greeting,randomstatement
Dim currenthour
Dim max,min
Dim randomno
max=3
min=1

Function getrandomno(min,max)
    Randomize
    getrandomno=(Int((max-min+1)*Rnd+min))
End Function

currenthour=Hour(Now())

if currenthour<=12 then
    randomno=getrandomno(min,max)
    Select Case randomno
        Case 1
    randomstatement="You're looking sharp today."
        Case 2
    randomstatement="Rise and shine!"
        Case Else
    randomstatement="Had your coffee yet?"
    End Select

    greeting="Good morning, "
end if

if currenthour>12 and currenthour <=18 then
    randomno=getrandomno(min,max)
    Select Case randomno
        Case 1
    randomstatement="Hard at work, I see."
        Case 2
    randomstatement="Lovely weather!"
        Case Else
    randomstatement="I love your hair."
    End Select

    greeting="Good afternoon, "
end if

if currenthour>18 then
    randomno=getrandomno(min,max)
    Select Case randomno
        Case 1
    randomstatement="Isn't it a little late?"
        Case 2
    randomstatement="Time for bed!"
        Case Else
    randomstatement="The moon's out tonight."
    End Select

    greeting="Good evening, "
end if

speech=greeting & ", Teochew Thunder. " & randomstatement
Set VObj=CreateObject("sapi.spvoice")
VObj.Speak speech


OK, enough playing. Let's set it so that your computer greets you every time it starts up. Save this file to the C:\Users\[your user name here]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup directory. I'm currently using Windows 8.1 on this machine, and the startup folder may be somewhere else depending on your Windows version.

Once that's done, restart your computer and stand by!

Doesn't this code just speak to you?
T___T

Monday, 8 May 2017

How I Learned Bootstrap (Part 2/2)


After doing the required reading on Twitter Bootstrap and getting a feel of how it was used, it didn't seem so damn hard. That was because Bootstrap is what a wheelchair is to a double amputee. You can't walk, but it will still get you from Point A to Point B by leveraging on a different set of tools, i.e, your hands. In the case of Bootstrap, the user does not have to understand Responsive Design - he just needs to leverage on HTML. The CSS files provided will do the rest.

More action

And then it was time to wade in further. Playtime was over.

Time to go deeper.

I accepted a commission from a friend to build a site. I charged him a shamefully low price for my services, but on one condition - I was to be allowed to use Twitter Bootstrap even though I had no professional experience in it. For months, I slaved over the look and feel. Money wasn't the issue here. I wanted to produce something using Bootstrap, something that would actually be put on public domain. With each UAT, each iteration, I grew stronger. Sure, I wasn't exactly becoming a guru in Responsive Design. But learning to use Twitter Bootstrap was a good first step.

And then I discovered something strange.

When I viewed the source of my HTML, it now looked suspiciously familiar. In fact, it was pretty much identical to what my colleague was doing. She had been using Bootstrap, and the clueless noob that was my CEO had bought into the narrative that this made her the expert in Responsive Design. Although at his level, I'm pretty sure it made no difference whatsoever. The end result was there.

Now, this is not meant to be a criticism of my ex-CEO. There's plenty to criticize, but that's neither here nor there. No, this is basically how the average layman thinks. They see the end result, but they're not privy to the process and they have no clue what differentiates a tool-user from a real expert. Resenting it would not make an iota of difference. Instead, I resolved to take full advantage of it.

How?

Performing "magic".

I quit my job. And then I left that company for another company full of the same clueless noobs, and presented my newfound skills in Bootstrap as mastery in Responsive Design. It worked like a charm. They had wanted Responsive Design, and what I gave them was a whole lot of shameless Bootstrapping. They never understood the difference.

Why did I quit the company?

That's the burning question. Some of my ex-colleagues, due to the timing of my departure coinciding with the promotion of my new colleague over me, thought I left out of bitterness. That's their opinion, but I think they were projecting a fair bit. I didn't care about the promotion. Being a "Senior" or a "Manager" has never mattered to me, especially when said title is being bestowed by some clueless jackass.

So why did I want to leave? After all, I'd already overcome my front-end handicap. There was no longer a need to leave, right?

Wrong.

You see, biases run deep. I had been hired by a Manager who had been on his way out. In fact, his last day was the day I joined. My new colleague had been hired by the CEO himself. When push came to shove, I knew whose side he would be on. It's just human nature.

Also, the sensation of coming in every morning to a workday filled with endless grunt work was... unpleasant. It wasn't the volume of work that I minded. It was the complexity, or lack thereof. Seriously, I was a web developer. Why would I want to spend another year coping with EDMs, writing registration forms and performing maintenance work that an intern could do? The money was good, but this was ultimately career suicide. I was a diesel truck doing the work of a horse cart.

On top of all that, was knowing that I was working for a guy who did not rate me, and was simply looking for an excuse to get rid of me. If not the front-end excuse, eventually some other thing. I could have tried harder to prove myself, but I simply did not see the need to prove myself to a dude who didn't know jackshit. What was the point?

Learning Bootstrap did not eliminate the need to leave. Rather, it facilitated my desire to leave.

The Takeaway

You may think this sounds utterly cynical, and on a certain level, it sure as hell is. But there's a lesson (or a few) to be learned in all this. Sometimes it makes no sense to beat them, when you can simply join them. The result of this was that I picked up a few new skills to add to my ever-growing toolbox.

The first, obviously, was Twitter Bootstrap.

The second, not so obviously, was that sometimes being an expert is too much work when you can just fool people into thinking you're an expert.

The third, if I do say so myself, is that I'm pretty good at turning lemons into lemonade.




I guess we could call this a... re-boot?
T___T

Monday, 27 March 2017

The Myth of Tech Meritocracy

The Android vs iOS debate has been raging on for years, with no end in sight. In each camp, you have devout followers that swear (sometimes very loudly) by their chosen platform.

I have a friend who's a bit of an Apple fanboy, and he absolutely despises Android technology. And I remember one day he was telling me how Android ought to die because its tech is shit.

Die, Android, die!

My opinion was that he wasn't being entirely rational about this - in fact, I was quite positive that he was looking at this from a very emotional point of view. Because things don't work that way in technology. Don't get me wrong - this isn't a debate about which technology is better. Even if, for arguments' sake, I agreed with him that Android technology is shit; Android is not going away. And for his own sake, my buddy should pray that it remains so.

Android, at this point in time, enjoys the largest market share worldwide next to Apple's iOS. What if my friend's wish comes true and Android disappears from the market forever? The void left by Android would not be readily filled, and Apple would reign supreme.

King of the hill

Sounds like a fanboy's wet dream, eh? Just wait - it goes downhill from here.

I think we can all agree that Apple isn't some benevolent mobile tech Santa giving us awesome products for the sheer joy of it. No, like all credible tech companies, Apple is a business, and is motivated by desire for consumer dollars. And its great innovations in recent years was a direct consequence of having to constantly up its game in the face of stiff competition from Android. What happens when that stiff competition is no longer present?

This is what I think happens...

Apple halves its workforce because the amount of talent on their payroll is no longer required.

Apple products slowly become shit, because Apple are now just about the only game in town and if they feel like feeding you shit, you'll eat it and like it.

Apple begins its inevitable decline.

Just a little
competition.

What I'm trying to say is - competition keeps businesses honest. But again, this isn't about Apple or Android - it's about the myth of tech meritocracy.

Let's talk about meritocracy, shall we?

The professional world isn't a perfect meritocracy. Higher management positions could be filled by people who don't deserve to have a job, much less a high-paying one. Less capable and driven folks may get that promotion simply by kissing up to the right people. Pretty girls may get ahead simply because the fellow in charge is a hum sup lou. Less qualified staff could remain employed simply by being better at keeping their jobs rather than actually doing their jobs. The lower echelons of the workforce could be teeming with a serious case of Crouching Tiger, Hidden Dragon.

There's nothing intrinsically wrong with any of that. This is simply how the world works.

Likewise, technology isn't a perfect meritocracy. Tech doesn't die simply because it's inferior. Tech rises to prominence for a variety of reasons, not just quality. And once that tech has entrenched itself as part of the ecosystem, removing it poses several problems, some of which may adversely affect that rival tech you're such a huge sucker for.

More examples

Remember classic ASP, written in VBScript? It was supposed to have been replaced by ASP.NET back in 2003. Where is it now? It's still residing on servers powering legacy systems - huge legacy systems - all over the world. It's not exactly thriving, but until Microsoft's IIS stops supporting classic ASP, no company in its right mind is going to spend money to rewrite a working system to leverage off new and (relatively) untested technology. So classic ASP stays.

Or, hey, look at JavaScript. For many years since Netscape shared it with the world, JavaScript was the only game in town, at least where client-side scripting was concerned. VBScript was client-side scripting too, but it  belonged to Microsoft and ran only on IE. By most yardsticks, JavaScript wasn't a great language. It had its warts, and I'm being generous when I say that. But decades on, it has become so pervasive that its use has expanded to frameworks, libraries and even server-side scripting. Uprooting JavaScript now would be a Herculean task.

For that matter, why are Pascal, FORTRAN and COBOL still around?

In technology, new things catch on fast. But older tech takes a while to go away if it has already entrenched itself - by being introduced at the right time, or filling some niche uncontested.

See how long HTML5 took to become a browser standard? Sure, it's starting to come into its own now, but XHTML is still alive. Because while HTML5 is superior and fixes many of the problems that came with HTML4.0 and XHTML, its introduction cannot undo decades of XHTML-based content overnight.

Such is the tech ecosystem

Tech ceases to grow when people stop using it to make new stuff. But it only truly dies when... well, almost never.

Besides, why should a piece of tech die just because some people (or several) don't like it and think it's rubbish? Technology is a vibrant and multifaceted world because of the variety, not in spite of it.

That's all for now. (ad)iOS!
T___T