Archive

Archive for the ‘javascript’ Category

MAP REDUCE using couchdb

February 18, 2014 Leave a comment

https://wiki.apache.org/couchdb/Introduction_to_CouchDB_views

http://guide.couchdb.org/draft/views.html

  • If you don’t use the key field in the map function, you are probably doing it wrong.
  • If you are trying to make a list of values unique in the reduce functions, you are probably doing it wrong.
  • If you don’t reduce your values to a single scalar value or a small fixed-sized object or array with a fixed number of scalar values of small sizes, you are probably doing it wrong.

mailto using javascript

February 21, 2011 Leave a comment

some time it is required to set mailto using javascript.

let us write a JavaScript function this.

<script type=”text/javascript”>

function sendmail() { var user=”apps”; var domain=”mydomainame.com”;      document.location=”mailto:”+user+”@”+domain;     }

</script>

now you can call this function using any event or method lets suppose we use onclick event of an div.

<div id=”click-me” name=”click-me” onclick=”sendmail()”>click me </div>

Voila, it opened my outlook.

Array to String Conversion using php

January 21, 2011 1 comment

it normally happen you are convert  some delimited string to array and php do it as using “explode()”

array explode ( string $delimiter , string $string [, int $limit ] )

php also provide the facility to convert array to string and most commonly used method is “implode”

string implode ( string $glue , array $pieces )

e.g lets we have an array of student names and we want to print  Read more…

How to extract the query string parameters.

January 20, 2011 Leave a comment

This was simplest method that i found very much help full, to extract the query string parameters .

  1. <script type=”text/javascript”>
  2. function getParameter(queryString, parameterName){
  3. var parameterName = parameterName + “=”;
  4. if ( queryString.length > 0 ) {
  5. begin = queryString.indexOf ( parameterName );
  6. if ( begin != -1 ) {
  7. begin += parameterName.length;
  8. end = queryString.indexOf ( “&” , begin );
  9. if ( end == -1 ) {
  10. end = queryString.length
  11. }
  12. return unescape ( queryString.substring ( begin, end ) );
  13. }
  14. return “null”;
  15. }
  16. }
  17. /* now we can call this javascript method as follows */
  18. var queryString = window.top.location.search.substring(1);
  19. var urlStr = getParameter(queryString, ‘url’);
  20. </script>

Thanks to mohsin who shared this code with me .