*How to get available disk space to check if server still has free disk space?
// -----------------------------------------------------------------------------------------------------
// Function: getDiskSpace
// Purpose: Return available space in the server drive
// Arg(s): (String) commandLine - command to be executed
// Return(s): (String) freeBytes - free disk space
// -----------------------------------------------------------------------------------------------------
function getDiskSpace(commandLine)
{
var output = Clib.system(commandLine); //to be tested (can't share the function I used here originally due to security issues)
var splitRes = output.split(' ');
if (!splitRes)
{ //print or log or alert error
return false;
}
var freeBytes = parseStringBytes(splitRes);
if(!freeBytes)
{
//print or log or alert error
return false;
}
else
{
//print or log or alert error
return freeBytes;
}
}
// -----------------------------------------------------------------------------------------------------
// Function: parseStringBytes
// Purpose: Return parsed free space string to a float
// Arg(s): (String) splitRes - string free bytes
// Return(s): (String) numBytes - float free bytes
// -----------------------------------------------------------------------------------------------------
function parseStringBytes(splitRes)
{
var freeBytes = "";
for (var i=0; i< splitRes.length; i++)
{
var str = splitRes[i];
if (str === "bytes")
{
freeBytes = splitRes[i-1];
}
}
var numBytes = parseFloat(freeBytes.replace(/,/g, ""));
return numBytes;
}
===========================================================
*where commandLine = 'dir|find "bytes free"';
Friday, August 26, 2016
Thursday, August 11, 2016
Javascript Sorting Algo
Javascript Sorting Algo
var arrObj = new Array(); // or [];
var temp = new Object();
temp.num = 3.58;
arrObj.push(temp); //add more of this; can loop through array of objects
....
arrObj.sort(sortByObjNumber);
function sortByObjNumber(a, b)
{
var a = parseInt(a.num);
var b = parseInt(b.num);
if(a < b)
{
return -1;
}
else if(a == b)
{
return 0;
}
else
{
return 1;
}
}
var arrObj = new Array(); // or [];
var temp = new Object();
temp.num = 3.58;
arrObj.push(temp); //add more of this; can loop through array of objects
....
arrObj.sort(sortByObjNumber);
function sortByObjNumber(a, b)
{
var a = parseInt(a.num);
var b = parseInt(b.num);
if(a < b)
{
return -1;
}
else if(a == b)
{
return 0;
}
else
{
return 1;
}
}
Thursday, May 7, 2015
How to compute BIR Withholding Tax?
1. Here's a very good site where you can compute your withholding tax:
http://birtaxcalculator.com/calculators/bir_withholding_tax_computation_2014
2. Another good site is from Rappler. Here's the link:
5 Life Lessons I Learned from Playing Candy Crush
1. Never give up.
No matter how hard it may seem, don't ever give up 'coz you'll eventually overcome it.
2. Stay cool.
Don't let the frustration of winning get into your emotions esp. when you're just one candy away from completing.
3. Be strategic
Every step you make affects your succeeding actions. No matter how tempting it may seem to get more points from one move but would freeze your move after, then don't do it.
4. Stay focus.
Always remember the goal for that level. You may get more points from doing other combinations but if it will not help you achieve your goal, then better not do it.
5. Play again.
If at first glance you think that there's a lesser chance of winning with the given candies, then go back and play again. If you think that you a lesser chance of getting your goal with the current resources that you have, then go back to basics and try again.
Saturday, April 4, 2015
Unique ways to save-up when booking flights
1. Book your flight on a holiday.
Yes, you read this right. Book your flight on a holiday. For example, take flight on a New Year's eve. Nobody wants to welcome a new year traveling when everyone's partying. I've actually tried this when I went to SG on a Christmas eve. There were less passengers and the ticket price is way cheaper than the regular days even if I just booked it around 5 days ahead.
2. Use incognito browser while browsing flights.
Usually most airline sites would keep track of their customers. If the same customer tries to check flight prices on the next day or even an hour after, the price would automatically go up. So, better keep an incognito identity to prevent the server from saving your data.
3. Book online.
Some of the lowest prices are only available online. I tried this once when the airline representative said that the flight I'm referring to was only available online.
4. Book through a travel agency
If you failed to book online, then try booking through an agency. Sometimes their prices are much lower because they have this "special" discount with airlines when they buy in bulk. I experienced this when I went to Cambodia but I don't want to mention the agency simply bec. I wasn't satisfied with their service.
Tuesday, March 31, 2015
Subscribe to:
Posts (Atom)