Wednesday, April 24, 2013

MYSQL: ERROR 1045 (28000): Access denied for user 'user'@'localhost' (using password: YES)

When I was trying to connect to mysql typing :

mysql -h localhost -u user -p

After typing the password I was getting this error:


ERROR 1045 (28000): Access denied for user 'user'@'localhost' (using password: YES)

I resolved that issue changing the user host value from % to localhost i.e using sqlyog:


Thursday, April 18, 2013

Maven Error: No plugin found for prefix 'jetty' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories

To solve the error:

No plugin found for prefix 'jetty' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories

Just run this command :

mvn org.mortbay.jetty:jetty-maven-plugin:run

Resource:
http://appfuse.547863.n4.nabble.com/No-plugin-found-for-prefix-jetty-in-the-current-project-td3041024.html

Wednesday, April 17, 2013

Javascript i18next example

Here is a link for great and simple examples using javascript i18next, jsperanto and I10n:

https://github.com/tabacha/javascript-i18n-example

Tuesday, April 16, 2013

IIS7: HTTP Error 404.3 - Not Found The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

To solve this error:


HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

Follow these steps:


1. Open IIS Manager
2. Display properties for the IIS Server
3. Click MIME Types and then add the JSON extension:
    - File name extension: .json
    - MIME type: application/json
4 . Go back to the properties for IIS Server
5. Click on Handler Mappings
    - Add a script map
    - Request path: *.json
    - Executable: C:\WINDOWS\system32\inetsrv\asp.dll
    - Name: JSON

Reference:
http://www.uipress.com/add-json-handler-support-in-iis-7/#.UW2eibVhUmM

Tuesday, April 2, 2013

Jquery: Change div background color using animate

You cannot use animate to animate colors without jQuery UI. So use

...

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
...
...
...

$( "#effect" ).animate({
          backgroundColor: "#fff",
          width: 240
        }, 1000 );


...
...
Resource:
http://stackoverflow.com/questions/6492418/changing-background-of-a-div-using-jquery
http://jqueryui.com/animate/

Javascript: random number in a given range

// Returns a random integer between min and max
// Using Math.round() will give you a non-uniform distribution!
function getRandomInt(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}

Source:
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/random

Javascript: Sort Array of Objects by Field Value


var employees=[]
employees[0]={name:"George", age:32, retiredate:"March 12, 2014"}
employees[1]={name:"Edward", age:17, retiredate:"June 2, 2023"}
employees[2]={name:"Christine", age:58, retiredate:"December 20, 2036"}
employees[3]={name:"Sarah", age:62, retiredate:"April 30, 2020"}

- Sort by employee age


employees.sort(function(a, b){
 return a.age-b.age
})


- Sort by employee name


employees.sort(function(a, b){
 var nameA=a.name.toLowerCase(), nameB=b.name.toLowerCase()
 if (nameA < nameB) //sort string ascending
  return -1 
 if (nameA > nameB)
  return 1
 return 0 //default return value (no sorting)
})


- Sort by employee name



employees.sort(function(a, b){
 var nameA=a.name.toLowerCase(), nameB=b.name.toLowerCase()
 if (nameA < nameB) //sort string ascending
  return -1 

 if (nameA > nameB)
  return 1
 return 0 //default return value (no sorting)
})

- Sort by date (retirement date)

employees.sort(function(a, b){
 var dateA=new Date(a.retiredate), dateB=new Date(b.retiredate)
 return dateA-dateB //sort by date ascending
})

References:
http://www.javascriptkit.com/javatutors/arraysort2.shtml
http://stackoverflow.com/questions/1129216/sorting-objects-in-an-array-by-a-field-value-in-javascript