[wget] create log file in /root directory

Context :

System : Ubuntu 12.04
Techs : shell(bash)

I have a bash shell script who calls a web service. The web service is wrote in PHP and it will return true if everything is OK.
The method that I execute the calling service is like this :

wget -T 0 http://host/program/myurl > /tmp/mylog

Problem :

Every time I execute the script shell with root, it will generate a file which is called myurl.x (x will be replaced by numbers) in my /root directory instead of in the /tmp/mylog, and this file contains only a number : 1, which I thought it means true.

Continue reading

[JS Practice] Valid The Coupon Code

Title :

Valid The Coupon Code

Description:

Your online store likes to give out coupons for special occasions. Some customers try to cheat the system by entering invalid codes or using expired coupons.

Your mission:
Write a function called checkCoupon to verify that a coupon is valid and not expired. If the coupon is good, return true. Otherwise, return false.

A coupon expires at the END of the expiration date. All dates will be passed in as strings in this format: “June 15, 2014″

Continue reading

[JS Practice] Christmas day

Title :

Christmas day

Description:

Sometimes it’s useful to know on which day of week the holly holiday will occur.
But just don’t limit ourselves to this year and write a function which consumes a Christmas date and outputs a name of weekday.

Example

findOutChristmasWeekday('2013 12 25') // returns 'Wednesday'

Only valid Christmas dates will be passed to the function.

Date parameter could be a string or a Date object. If it’s a string here are possible date parameter formats:

'2013 12 25'
'12 25 2013'
'25 December 2013'

Note: calendar used in the kata is Gregorian.

Continue reading

[JS Practice] Find majuscule letters

Title :

Find majuscule letters

Description:

Instructions

Write a function capitals that takes a single string (word) as argument. The functions must return an ordered list containing the indexes of all capital letters in the string.

Example

Test.assertSimilar( capitals('CodEWaRs'), [0,3,4,6] );

Continue reading

[Linux-HA] High-Availability Linux

According to wikipedia :

The Linux-HA (High-Availability Linux) project provides a high-availability (clustering) solution for Linux, FreeBSD, OpenBSD, Solaris and Mac OS X which promotes reliability, availability, and serviceability (RAS).

The project’s main software product is Heartbeat, a GPL-licensed portable cluster management program for high-availability clustering. Its most important features are:

no fixed maximum number of nodes – Heartbeat can be used to build large clusters as well as very simple ones
resource monitoring: resources can be automatically restarted or moved to another node on failure
fencing mechanism to remove failed nodes from the cluster
sophisticated policy-based resource management, resource inter-dependencies and constraints
time-based rules allow for different policies depending on time
several resource scripts (for Apache, DB2, Oracle, PostgreSQL etc.) included
GUI for configuring, controlling and monitoring resources and nodes

TODO

Link : version chinese

[JS Practice] Sort characters

Title :

Sort characters

Description:

Write a function called sortGiftCode (sort_gift_code in Ruby) that accepts a string containing up to 26 unique alphabetical characters, and returns a string containing the same characters in alphabetical order.

Examples:

sortGiftCode( 'abcdef' );//=> returns 'abcdef'
sortGiftCode( 'pqksuvy' );//=> returns 'kpqsuvy'
sortGiftCode( 'zyxwvutsrqponmlkjihgfedcba' );
//=> returns 'abcdefghijklmnopqrstuvwxyz'

Continue reading

[JS Practice] Boiled Eggs

Title :

Multiplication table

Description:

You are the greatest chef on earth. No one boils eggs like you! Your restaurant is always full of guests, who love your boiled eggs. But when there is a greater order of boiled eggs, you need some time, because you have only one pot for your job. How much time do you need?

Your Task

Implement a function, which takes a non-negative integer, representing the number of eggs to boil. It must return the time in minutes (integer), which it takes to have all the eggs boiled.

Rules

  • you can put at most 8 eggs into the pot at once
  • it takes 5 minutes to boil an egg
  • we assume, that the water is boiling all the time (no time to heat up)
  • for simplicity we also don’t consider the time it takes to put eggs into the pot or get them out of it

Example

cookingTime(0); // must return 0
cookingTime(5); // must return 5
cookingTime(10); // must return 10
cookingTime(16); // must return 10

Continue reading