PostIT

while scratching my head…

Windows – Set JAVA_HOME December 28, 2011

Filed under: JAVA — Remo @ 12:52 am
Tags: , , ,

Stage 1. Locate the JRE Installation Directory

If you already know the installation path for the Java Runtime Environment, go to Stage 2 below. Otherwise, find the installation path by following these instructions:

  1. If you didn’t change the installation path for the Java Runtime Environment during installation, it will be in a directory under C:\Program Files\Java. Using Explorer, open the directory C:\Program Files\Java.
  2. Inside that path will be one or more subdirectories such as C:\Program Files\Java\jre6.

Stage 2. Set the JAVA_HOME Variable

Once you have identified the JRE installation path:

  1. Right-click the My Computer icon on your desktop and select Properties.
  2. Click the Advanced tab.
  3. Click the Environment Variables button.
  4. Under System Variables, click New.
  5. Enter the variable name as JAVA_HOME.
  6. Enter the variable value as the installation path for the Java Development Kit.
    • If your Java installation directory has a space in its path name, you should use the shortened path name (e.g. C:\Progra~1\Java\jre6) in the environment variable instead.
  7. Click OK.
  8. Click Apply Changes.
  9. Restart Windows. (This is not always necessary, but it often prevents problems.)
  10. If you are running the Confluence EAR/WAR distribution, rather than the regular Confluence distribution, you may need to restart your application server.

 

source:

http://confluence.atlassian.com/display/DOC/Setting+the+JAVA_HOME+Variable+in+Windows

 

SQL Server – LIMIT Clause December 28, 2011

Filed under: Database,SQL Server — Remo @ 12:17 am
Tags: , , ,

Yes, SQL Server does not support LIMIT clause as you usually does with MySQL…

SELECT TOP 10 * FROM (SELECT TOP 20 FROM Table ORDER BY Id) ORDER BY Id DESC

 

 

SQL Server – Auto Increment December 15, 2011

Filed under: SQL Server — Remo @ 6:42 am
Tags: , , , , ,
  • Add IDENTITY property on selected field
  • IDENTITY property requires two parameters
  1. Seed (value for first record in the table)
  2. Increment (incremental value)

 

 

 

PHP – Run PHP Script in The Background on Windows Box December 13, 2011

Filed under: PHP,Windows — Remo @ 11:27 am
Tags: , , ,

<?php
$runCommand = ‘php -q FULLPATH/FILE.php’;
$WshShell = new COM(“WScript.Shell”);
$oExec = $WshShell->Run($runCommand, 7, false);
?>

 

source:

http://php.net/manual/en/function.shell-exec.php

 

PHP – Shutdown Windows December 13, 2011

Filed under: PHP,Windows — Remo @ 11:15 am
Tags: , ,

<?php
$runCommand = ”C:\\WINDOWS\\system32\\shutdown.exe -t:30″; //Wrong on purpose to get some good output
$WshShell = new COM(“WScript.Shell”);
$output = $WshShell->Exec($runCommand)->StdOut->ReadAll;
echo ”<p>$output</p>”;
?>

 

source:

http://php.net/manual/en/function.shell-exec.php

 

PHP – Connecting to SQL Server with Windows Authentication December 9, 2011

Filed under: PHP,SQL Server — Remo @ 8:52 am
Tags: , , , ,

<?php
$serverName      = “(local)”;
$databaseName = “TEST”;
$connectionOptions = array(“Database”=>$databaseName);

$conn = mssql_connect($serverName, $connectionOptions);

if ($conn === false){
die(FormatErrors(mssql_errors()));
}

echo ‘connection succeed!’;
?>

 

Google Maps – Find Nearby Location November 16, 2011

Filed under: Google Maps,MySQL — Remo @ 9:29 am
Tags: , , , , , ,
To find locations in markers table that are within a certain radius distance of a given latitude/longitude, you can use a SELECT statement based on the Haversine formula. The Haversine formula is used generally for computing great-circle distances between two pairs of coordinates on a sphere. An in-depth mathemetical explanation is given by Wikipedia and a good discussion of the formula as it relates to programming is on Movable Type’s site.Here’s the SQL statement that will find the closest 20 locations that are within a radius of 25 miles to the 37, -122 coordinate. It calculates the distance based on the latitude/longitude of that row and the target latitude/longitude, and then asks for only rows where the distance value is less than 25, orders the whole query by distance, and limits it to 20 results. To search by kilometers instead of miles, replace 3959 with 6371.

SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) – radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20;

 

 

source:
 

Code Igniter: Find Version Number November 14, 2011

Filed under: Code Igniter — Remo @ 4:30 am
function get_version() {
    echo CI_VERSION; // echoes something like 1.7.1
}
this constant can be found on:
/system/codeigniter/CodeIgniter.php (old)

/system/core/CodeIgniter.php (new)

source:
http://stackoverflow.com/questions/2196799/which-version-of-codeigniter-am-i-currently-using
 

MySQL – Reset Root Password October 29, 2011

Filed under: MySQL — Remo @ 4:07 am
Tags: , , ,

viral patel has described in a short , simple and clear explanation on the steps needed to accomplish this, see it here http://viralpatel.net/blogs/2008/12/how-to-reset-mysql-root-password.html

 

Code Igniter: Enable GET October 13, 2011

Filed under: Code Igniter,PHP — Remo @ 3:56 am
Tags: , , ,

1. edit config.php

$config['uri_protocol'] = ”PATH_INFO”;

2. add this to your controller

parse_str($_SERVER['QUERY_STRING'], $_GET);

 

 

 
Follow

Get every new post delivered to your Inbox.