When you are using Tomcat 6 as the web service then restarting it is as follows:
sudo service tomcat6 restart
Simple eh?
When you are using Tomcat 6 as the web service then restarting it is as follows:
sudo service tomcat6 restart
Simple eh?
Problem:
Given a real number, write a JavaScript code to round it off to the “nearest five”. Examples:
Analysis:
The result would be an integer which is a multiple of 5.
Solution:
We will write the JavaScript code as part of an HTML file:
<html>
<head>
<script type=”text/javascript”>
// PART 2: the rounding off javascript code will be here
</script>
</head>
<body>
</body>
<!-- PART 1: this section will contain the HTML elements to visually display to user the transformation -->
</html>
Part 1:
We need three elements: a text box for the inputting of the number, a button to trigger the rounding off javascript code, and another text box to display the rounded off.
<input type="text" id="txtInput">
<input type="button" onClick="doRoundItOff();" value="Round It!">
<input type="text" id="txtOutput" >
Here the trigger is on the onClick event of the button which calls the doRoundItOff JavaScript function.
Part 2:
Here is the JavaScript code:
function doRoundItOff() {
var txtInput = document.getElementById("txtInput");
var txtInputValue = parseInt(txtInput.value,10);
var remainder = txtInputValue % 5;
var roundedValue = 0;
if (remainder == 2 ) {
var offsetDecimal = parseInt(txtInput.value*10,10) % 10;
if (offsetDecimal < 5)
{
roundedValue = txtInputValue - remainder;
}
else
{
roundedValue = txtInputValue - remainder + 5;
}
}
else if (remainder > 2)
{
roundedValue = txtInputValue - remainder + 5;
}
else
{
roundedValue = txtInputValue - remainder;
}
var txtOutput = document.getElementById("txtOutput");
txtOutput.value = roundedValue;
}
Explain! Explain! Explain!
We started the doRoundItOff function with identifying the txtInput HTML element. It is noteworthy to say that I usually make use as var in the JavaScript the id in the HTML element.
Next we take into account the remainder when the integer part of the input is divided by five. This remainder will determine which multiple of five we have to choose.
If the remainder is two then we take into consideration the decimal value of the input. If it is less than five then the input is closer to the largest multiple of five less than the input. Hence, we round down. Otherwise the input would be closer to the smallest multiple of five greater than the input and we round up.
If remainder is greater than two, the input is closer to the smallest multiple of five that is greater than the input. Thus, we round up. Otherwise, the input is closer to the largest multiple of five less than the input and we round down.
A while back I posted the inquiry http://nullpointer.ph/questions/3204/any-fix-to-sql-server-management-studio-timing-out-when-adding-a-new-column-to-a-table
Thanks to Alistair sharing his knowledge. After some research got the following fix
that is, navigating Tools > Options then looking at Designers > Table and Database Designers node you will have Table Options. Override the default value of Transaction time-out after: [____] seconds with your desired length of time.
Assuming you have an XML file structured as follows
<questionnaire>
<question>
<id>1</id>
<text>Which of the following is TRUE?</text>
<option1>6 is a perfect number.</option1>
<option2>All prime numbers are odd.</option2>
<option3>None of the Above</option3>
<answer>B</answer>
<explanation>B is FALSE because 2 is prime and even.
Perfect Numbers are such that the sum of their prime factors and 1 equals the number. Since the prime factors of 6 are 2 and 3 and 2+3+1 = 6, then 6 must be perfect.</explanation>
</question>
…
</questionnaire>
and there are a thousand more <question> … </question> set in it but you are interested only in retrieving the id and answer. Using SQL Server 2008, what SQL statements should you use?
Here it is:
-------------------------------------------------
DECLARE @FilePath AS VARCHAR(50)
DECLARE @Query AS NVARCHAR(MAX)
DECLARE @QuestionData XML
-- set the path to xml file
SET @FilePath = 'C:\Users\test\questions.xml'
SET @Query = N'SELECT @data = CAST(BulkColumn AS XML) FROM OPENROWSET(BULK N''' + @FilePath + ''', SINGLE_BLOB) AS XmlData'
EXEC sp_executesql @Query, N'@data AS XML OUTPUT', @QuestionData OUTPUT
DECLARE @hdoc int
EXEC sp_xml_preparedocument @hdoc OUTPUT, @QuestionData
SELECT
*
FROM
OPENXML (@hdoc, '/questionnaire/question', 10)
WITH (
id INT,
answer CHAR(1)
)
EXEC sp_xml_removedocument @hdoc
-------------------------------------------------
Simple eh?
We were successful in running the taste-getting-started example as seen here: http://teachitshem.blogspot.com/2011/04/simple-java-wicket-using-mahout.html. However, mahout offers other recommendation algorithms which are so interesting to study. For instance, the PearsonCorrelationSimilarity whose parameters are similar to that EuclideanDistanceSimilarity used in the original taste-getting-started example.
How then can do this?
First, we duplicate the taste-getting-started folder say to tgs and we achieve this by issuing cp taste-getting-started tgs –R in the command line.
Second, we change the node <artifactId>taste-getting-started</artifactId> to <artifactId>tgs</artifactId> from the pom.xml file.
Third, open the recommeder-context.xml file at src/main/webapp/WEB-INF folder and replace euclideanDistanceRecommeder with pearsonCorrelationSimilarityRecommender, euclideanDistanceSimilarity with pearsonDistanceSimilarity, and similarity.EuclideanDistanceSimilarity with similarity.PearsonCorrelationSimilarity.
Fourth, run mvn package against tgs.
Fifth, in order to compare results with the original taste-getting-started we have run both the original taste-getting-started and the new tgs web applications using different ports. Thus for taste-getting-started we can use the usual mvn jetty:run-war that uses port 8080 but for tgs we must use something like mvn –Djetty.port=9090 jetty:run-war which uses the URL http://localhost:9090/tgs/movies.
Simple eh?
While continuing the study of mahout, it is inevitable to write code that uses the various algorithms stored with it. So I asked a colleague to help out and one option was to start with a java wicket found here: http://blog.jteam.nl/wp-content/uploads/2010/04/taste-getting-started.zip
Using it is quite straightforward. Download the zip file. Unzip it to some folder (say taste-getting-started in the mahout machine). Using Ubuntu’s Terminal application, go to that folder and run mvn package. After packaging is complete, run mvn jetty:run-war. Once the jetty server is up, you can make use of the wicket by browsing http://localhost:8080/taste-getting-started/movies.
Although the above is the straightforward usage of the said wicket, setting it up requires some effort such as
Oh and if you do not have MySQL yet, install it by issuing the following command sudo apt-get install mysql-server mysql-client.
Problem: Research about mahout.
Solution: Obtain a running mahout code but this would require an VirtualBox with Ubuntu instance on my Windows machine.
Here are the steps I underwent:
After Ubuntu has been installed, run the Applications > Accessories >Terminal
JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export $PATH
Whew! I am just barely starting the journey… more to follow!
I just have installed Ubuntu 10.10 on an instance of an Oracle VM VirtualBox on my Windows 7 machine when I tried to install the prerequisites of mahout (http://mahout.apache.org/). So I opened the Terminal app, keyed in java and it suggests that I should use sudo apt-get install <package> to initiate the installation which I did.
Now in the next steps of mahout install procedure I saw the need for subversion. So I tried keying in svn and again Ubuntu suggests the use of sudo apt-get install <package>.
Very well indeed, this suggestion saved me time where to find the correct installers, time to download them, and fire up the installation.
I’ve been reading http://www.amazon.com/Teach-Yourself-iPhone-Application-Development/dp/0672330849 and here’s what I’ve learned today
Xcode
iPhone Simulator
So you want to know the upfront cost of programming apps for Apple’s iOS?
That’s all you need: no more than Php 60K.
Sometimes you want to find the BPI Bank closest to your area and here’s a self-service URL:
http://info.bpiexpressonline.com/bpiprod/prodserv.nsf/Pop-Ups/BranchesSearch
I was deploying an ASP.NET MVC 2 default application to one of my GoDaddy hosted sites when I encountered the below screen:
How can I know the underlying problem?
Simply edit the web.config file.
(1) Inside <system.webServer> node add
<httpErrors errorMode=”Detailed” />
<asp scriptErrorSentToBrowser=”true” />
(2) Inside <system.web> node add
<customErrors mode=”Off” />
<compilation debug=”true” />
Wasn’t that so easy?!
NOTE: Remove the said lines after you have found and applied the fix to your problem. You don’t want your regular website visitor know the internals of your application, right?
Time flew so quick and I guess I was left out in the know. So to catch up I’ll get to review http://www.asp.net/mvc/tutorials/getting-started-with-mvc3-part1-cs and download the installer here: http://go.microsoft.com/fwlink/?LinkID=208140
So you want to develop web sites/applications using CodeIgniter framework on XAMPP? Here are the initial steps to make your first page work:
We will assume (1) you have successfully installed XAMPP at C:\XAMPP\ folder on your Windows machine. Otherwise, you have to read about it. (2) you have downloaded (and extracted)CodeIgniter.
STEP 1: Copy the extracted CodeIgniter files to at C:\XAMPP\htdocs\somewebfolder\
At this point you can open your favorite browser and navigate http://localhost/somewebfolder/ and you’ll see something like the below:
I know you want to see your own work! Let’s move to the next step.
STEP 2: Open \somewebfolder\system\application\config\config.php and change as follows:
FROM:
$config['base_url'] = http://example.com/;
TO:
$config['base_url'] = http://localhost/somewebfolder/;
STEP 3: Open \somewebfolder\system\application\config\routes.php and do the following change:
FROM:
$route['default_controller'] = "welcome";
TO:
$route['default_controller'] = "home";
Now, if you try to navigate http://localhost/somewebfolder/ you’ll be seing a 404 Page Not Found message. That’s fine! We just need to add home.php at the controllers folder and add another home_view.php file at the views folder.
Initial content of home.php can be
<?php
class Home extends Controller {
function Home()
{
parent::Controller();
}
function index()
{
$this->load->view('home_view');
}
}
/* End of file home.php */
/* Location: ./system/application/controllers/home.php */
While home_view.php can have as follows
<html>
<head>
<title>Home Page</title>
</head>
<body>
<h1>This is the home page!</h1>
</body>
</html>
There you have it! You have successfully created a home page in CodeIgniter over XAMPP.
Have you ever wanted to use another computer running Windows 7 within your local area network but does not want to physically move to the said machine? Here’s what you can do:
Configure the other computer to allow remote desktop connections!
STEP 1: Navigate Start Menu > Computer > Properties
STEP 2: Click the Remote Settings link.
STEP 3: Select “Allow connections from computers running any version of Remote Desktop” option. Hit the OK button.
And there you have it. The other computer can now be remotely accessed from your machine.