August 10th, 2010

Simple SugarCRM iFrame Field

References:
SugarCRM – SugarCRM is an open-source software-solution vendor which produces the Sugar Customer Relationship Management (CRM) system.
en.wikipedia.org/wiki/SugarCRM

iFrame – HTML tag that is used to place a “frame”, often a picture or graphic, inside of a normal HTML document.
www.100best-web-hosting.com/glossary/termi.html

Bookmark and Share
August 9th, 2010

Simple PHP get URI or Segment element

This script takes any uri or segment from the url of the current page and assigns it to a $uri variable. It is very easy to implement so enjoy.

php 

$uri = $_SERVER['REQUEST_URI'];
$pieces = explode("/", $uri);
$uri_3 = $pieces[3];

/php

Refferenses:

URI -Term used to collectively refer to URLs, URNs, and URCs.
lcweb2.loc.gov/ammem/techdocs/repository/gengloss.html

$_SERVER is an array containing information such as headers, paths, and script locations. http://php.net/manual/en/reserved.variables.server.php

explode() Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string delimiter. http://php.net/manual/en/function.explode.php

Bookmark and Share
Tags:
July 23rd, 2010

SugarCRM SOAP Methods List

Method Name: login
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/login
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: loginRequest
parts:
user_auth: tns:user_auth
application_name: xsd:string
name_value_list: tns:name_value_list
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: loginResponse
parts:
return: tns:entry_value
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: logout
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/logout
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: logoutRequest
parts:
session: xsd:string
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: logoutResponse
parts:
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: get_entry
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/get_entry
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_entryRequest
parts:
session: xsd:string
module_name: xsd:string
id: xsd:string
select_fields: tns:select_fields
link_name_to_fields_array: tns:link_names_to_fields_array
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_entryResponse
parts:
return: tns:get_entry_result_version2
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: get_entries
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/get_entries
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_entriesRequest
parts:
session: xsd:string
module_name: xsd:string
ids: tns:select_fields
select_fields: tns:select_fields
link_name_to_fields_array: tns:link_names_to_fields_array
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_entriesResponse
parts:
return: tns:get_entry_result_version2
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: get_entry_list
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/get_entry_list
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_entry_listRequest
parts:
session: xsd:string
module_name: xsd:string
query: xsd:string
order_by: xsd:string
offset: xsd:int
select_fields: tns:select_fields
link_name_to_fields_array: tns:link_names_to_fields_array
max_results: xsd:int
deleted: xsd:int
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_entry_listResponse
parts:
return: tns:get_entry_list_result_version2
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: set_relationship
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/set_relationship
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: set_relationshipRequest
parts:
session: xsd:string
module_name: xsd:string
module_id: xsd:string
link_field_name: xsd:string
related_ids: tns:select_fields
name_value_list: tns:name_value_list
delete: xsd:int
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: set_relationshipResponse
parts:
return: tns:new_set_relationship_list_result
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: set_relationships
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/set_relationships
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: set_relationshipsRequest
parts:
session: xsd:string
module_names: tns:select_fields
module_ids: tns:select_fields
link_field_names: tns:select_fields
related_ids: tns:new_set_relationhip_ids
name_value_lists: tns:name_value_lists
delete_array: tns:deleted_array
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: set_relationshipsResponse
parts:
return: tns:new_set_relationship_list_result
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: get_relationships
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/get_relationships
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_relationshipsRequest
parts:
session: xsd:string
module_name: xsd:string
module_id: xsd:string
link_field_name: xsd:string
related_module_query: xsd:string
related_fields: tns:select_fields
related_module_link_name_to_fields_array: tns:link_names_to_fields_array
deleted: xsd:int
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_relationshipsResponse
parts:
return: tns:get_entry_result_version2
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: set_entry
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/set_entry
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: set_entryRequest
parts:
session: xsd:string
module_name: xsd:string
name_value_list: tns:name_value_list
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: set_entryResponse
parts:
return: tns:new_set_entry_result
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: set_entries
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/set_entries
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: set_entriesRequest
parts:
session: xsd:string
module_name: xsd:string
name_value_lists: tns:name_value_lists
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: set_entriesResponse
parts:
return: tns:new_set_entries_result
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: get_server_info
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/get_server_info
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_server_infoRequest
parts:
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_server_infoResponse
parts:
return: tns:get_server_info_result
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http


Method Name: get_user_id

Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/get_user_id
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_user_idRequest
parts:
session: xsd:string
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_user_idResponse
parts:
return: xsd:string
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: get_module_fields
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/get_module_fields
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_module_fieldsRequest
parts:
session: xsd:string
module_name: xsd:string
fields: tns:select_fields
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_module_fieldsResponse
parts:
return: tns:new_module_fields
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: seamless_login
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/seamless_login
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: seamless_loginRequest
parts:
session: xsd:string
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: seamless_loginResponse
parts:
return: xsd:int
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: set_note_attachment
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/set_note_attachment
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: set_note_attachmentRequest
parts:
session: xsd:string
note: tns:new_note_attachment
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: set_note_attachmentResponse
parts:
return: tns:new_set_entry_result
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http


Method Name: get_note_attachment

Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/get_note_attachment
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_note_attachmentRequest
parts:
session: xsd:string
id: xsd:string
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_note_attachmentResponse
parts:
return: tns:new_return_note_attachment
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: set_document_revision
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/set_document_revision
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: set_document_revisionRequest
parts:
session: xsd:string
note: tns:document_revision
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: set_document_revisionResponse
parts:
return: tns:new_set_entry_result
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: get_document_revision
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/get_document_revision
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_document_revisionRequest
parts:
session: xsd:string
i: xsd:string
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_document_revisionResponse
parts:
return: tns:new_return_document_revision
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: search_by_module
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/search_by_module
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: search_by_moduleRequest
parts:
session: xsd:string
search_string: xsd:string
modules: tns:select_fields
offset: xsd:int
max_results: xsd:int
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: search_by_moduleResponse
parts:
return: tns:return_search_result
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http


Method Name: get_available_modules

Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/get_available_modules
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_available_modulesRequest
parts:
session: xsd:string
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_available_modulesResponse
parts:
return: tns:module_list
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: get_user_team_id
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/get_user_team_id
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_user_team_idRequest
parts:
session: xsd:string
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: get_user_team_idResponse
parts:
return: xsd:string
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Method Name: set_campaign_merge
Binding: sugarsoapBinding
Endpoint: http://10.0.2.113/sugarcrm/service/v2/soap.php
SoapAction: http://sugar/sugarcrm/service/v2/soap.php/set_campaign_merge
Style: rpc
Input:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: set_campaign_mergeRequest
parts:
session: xsd:string
targets: tns:select_fields
campaign_id: xsd:string
Output:
use: encoded
namespace: http://www.sugarcrm.com/sugarcrm
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/
message: set_campaign_mergeResponse
parts:
Namespace: http://www.sugarcrm.com/sugarcrm
Transport: http://schemas.xmlsoap.org/soap/http

Bookmark and Share
June 28th, 2010

jQuery Tools Form + PHP mail() (PHP 4, PHP 5)

jquery php email form

jquery php email form

This example shows how to integrate php mail which is is used to send emails from inside a script with jQuery Tools form which is a collection of essential form building tools. Validation, range- and date inputs for humans. Those two make a great combination and are easy to implement to any website. Here is the example. The code speaks for itself so there is not much commenting on it.

Standalone example can be found HERE.
Source code HERE.

PHP:


if(isset($_POST['submit'])){
  $to      = $_POST['email'];
  $subject = "You've got mail";
  $message = "*** eMail: ".$_POST['email']."*** Website: ".$_POST['url']."*** Name: ".$_POST['name']."*** Age; ".$_POST['age'];
  $headers = 'From: webmaster@example.com' . "\r\n" .
      'Reply-To: webmaster@example.com' . "\r\n" .
      'X-Mailer: PHP/' . phpversion();

  mail($to, $subject, $message, $headers);
  
  echo "Email to ".$_POST['email']." was sent successfuly! <br />";
}

HTML:


<form id="myform" method="post">

   <fieldset>
      <h3>PHP + JQuery Tools Sample email form</h3>
      
      <p> Enter bad values and then press the email button. </p>
      
      <p>
         <label>email *</label>
         <input type="email" name="email" required="required" />
      </p>
      <p>
         <label>website *</label>
         <input type="url" name="url" required="required" />
      </p>
      <p>
         <label>name *</label>
         <input type="text" name="name" pattern="[a-zA-Z ]{5,}" maxlength="30" />
      </p>
      <p>
         <label>age</label>
         <input type="number" name="age" size="4" min="5" max="50" />
      </p>
      <input type='hidden' name='submit' />
      
      <button type="submit">Email form</button>
      <button type="reset">Reset</button>
   </fieldset>

</form>


<script>
$("#myform").validator();
</script>

Bookmark and Share
May 24th, 2010

Overview of WebM Open Video Format and VP8 High-Quality Video Codec

WebM HD Video Example VP8 HTML 5

WebM HD Video Example VP8 HTML 5

The purpose of this post is to provide general information about the new webm open video format and VP8 High-Quality Video Codec.


Define webm

WebM is an open, royalty-free media file format designed for the web. WebM files consist of video streams compressed with the VP8 video codec and audio streams compressed with the Vorbis audio codec. The WebM file structure is based on the Matroska media container.


Define VP8

VP8 is a highly efficient video compression technology that was developed by On2 Technologies. Google acquired On2 in February, 2010.


webm Browser Support

Google Chrome — Currently only available in Chromium
Firefox — Grab a Firefox WebM nightly build
Opera — Opera 10.54 has WebM support


HTML 5 webm Implementation

<video src="video_name.webm" controls="controls">
Your browser does not support the video tag!
</video>


webm VP8 HTML 5 DEMO

Demo Page
Download Sample webm vp8 video


How To Build FFMpeg for Windows and Linux with VP8 WebM Guides

Build FFMpeg for Linux with VP8 WebM support
Build FFMpeg for Windows with VP8 WebM support


Thanks for reading!

Bookmark and Share
May 8th, 2010

C++ Standard Template Library (STL) vector class example

This C++ program illustrates how to use the Standard Template Library (STL) vector class


#include < vector >
#include < iostream >
using namespace std;

int main()
{
    // vector is a template, the <int> means it is a vector of ints
    vector<int> numbers;  

    // push_back() puts a new value at the end (or back) of the vector
    for (int i = 0; i < 10; i++)
        numbers.push_back(i);

    cout << "print all elements in vector" << endl;

    // This is one way to iterate through a vector and print all the values
    for (int i = 0; i < numbers.size(); i++)
        cout << numbers[i] << endl;

    // This is the preferred way to iterate through a vector

    // an iterator is a special object used to keep track of internal structures
    vector<int>::iterator iter;
    for (iter = numbers.begin(); iter != numbers.end(); iter++)
        cout << *iter << endl;

    cout << "now print it backwards" << endl;
    iter = numbers.end();
    for (iter--; iter != numbers.begin(); iter--)
        cout << *iter << endl;
    cout << *iter << endl;
}

// In order to motivate why the iterator mechanism show above is more
// efficient that using the index method (the numbers[i] method)
// consider how you would implement finding a specific element of a
// linked list.  Each time this function is called it has to start
// at the head of the list.

/*
bool List::index(int i, int &value)
{
    Node *ptr;
    for (ptr = m_head; i > 0; ptr = ptr->m_next, i--)
        ;
    if (ptr != NULL)
    {
        value = ptr->m_value;
        return true;
    }
    else return false;
}
*/

Bookmark and Share
Tags:
May 8th, 2010

C++ wait for key press to continue execution example

Simple C++ program that waits for a key to be pressed to continue execution of the program.


#include " stdafx.h "
#include < iostream >

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
  cout << "Press 'n' and then ENTER to continue!" << endl;
  while (1)
  {
    if ('n' == getchar())
       break;
  }
}

Bookmark and Share
Tags:
May 8th, 2010

C++ Using the standard template library (STL) map example

This program demonstrates using the standard template library (STL) map it reads pairs of data and inserts them into a map then it reads names and looks those names up in the map
A map stores a collection of pairs For example, consider this collection of data: Tom is 42 years old Sally is 20 years old Fred is 21 years old We can think of this data as three “pairs” A map stores these pairs. For each key (a name in the above example) there is a single value


#include < map >
#include < string >
#include < iostream >
using namespace std;

int main()
{
    // maps are parameterized by two types.  The first is the type of the key,
    // the second is the type of the thing being stored in the map
    map<string, string> my_map;
    string owner_name;
    string pet_name;

    cout << "enter owner names and pet name pairs: " << endl;
    while (cin >> owner_name)
    {
        if (owner_name == "quit")
            break;
        cin >> pet_name;
        // insert the pet_name into the map using the owner_name as the key
        my_map[owner_name] = pet_name;
    }

    cout << "enter owner names to lookup:" << endl;
    while (cin >> owner_name)
    {
        if (owner_name == "quit")
            break;
        // NOTE: this code is not very good.  
        // If an owner_name is not in the map, this code prints an
        // empty string.
        cout << owner_name
             << "'s pet is <"
             << my_map[owner_name]
             << ">"
             << endl;
    }
}

Bookmark and Share
Tags:
May 8th, 2010

c++ Sample program to test compilation

Here is a simple C++ program to test compilation:

// Sample program to test compilation
#include <iostream>
using namespace std;

int main()
{
    cout << "Hello world." << endl;
}

Bookmark and Share
February 25th, 2010

Python – Passing URL Parameters Variable To Python

The following python

script provides a simple

way to get a parameter

from url using the well

known syntax appended

at the end of the url

?parameter=value

In the following example

I am using url_parameter

as a parameter and the value could be any string you want.

Example url for testing purposes will be something like this:

http://erunways.com/examples/cgi-bin/index.py?url_parameter=Somthing

DEMO SOURCE

Here is the content of the source code for this script:


#!/usr/bin/env python# -*- coding: UTF-8 -*-# enable debugging
import cgitbcgitb.enable()
import cgi
print "Content-Type: text/plain;charset=utf-8"
print
print "Your URL parameter is: "
form = cgi.FieldStorage()
print form.getvalue('url_parameter')

Bookmark and Share