AnyExamples - latest examples feed Free, tested & ready to use examples - for any topic we competent in http://www.anyexample.com/ en-us WebDev JavaScript http://www.anyexample.com/webdev/javascript/jquery_change_image.xml http://www.anyexample.com/webdev/javascript/jquery_change_image.xml Change image with JavaScript (or jQuery) One of the most asked questions by JavaScript beginners is how to change image on the html page when mouse pointer enters the image or maybe some other object on the page. This is called mouseover. WebDev JavaScript http://www.anyexample.com/webdev/javascript/javascript_string_compare.xml http://www.anyexample.com/webdev/javascript/javascript_string_compare.xml JS string compare example JavaScript string comparing is a very common operation for most of JS developers. Basically it's a check if one string equals another. But there are some tricky "issues" in JavaScript when doing comparison. WebDev AJAX http://www.anyexample.com/webdev/ajax/ajax_web_counter_for_widgets.xml http://www.anyexample.com/webdev/ajax/ajax_web_counter_for_widgets.xml AJAX web-counter for widgets Modern widget engines (Apple Dashboard, Yahoo!Widgets, Windows Vista Sidebar) use XML transport (AJAX) to constantly update various information(like weather, stocks, etc) from web. In this article there is a source of trivial php web-counter which collects stats and outputs number of page views(hits) and visitors(in fact, unique hosts) since midnight as XML file. There is also our special AeCounter Dashboard Widget (and it's sources) which receive these xml-statistics (with the help of XmlHttpRequest object) and displays numbers on a little nice panel. WebDev AJAX http://www.anyexample.com/webdev/ajax/ajax_example__get_page_title.xml http://www.anyexample.com/webdev/ajax/ajax_example__get_page_title.xml AJAX example: get page title AJAX (Asynchronous JavaScript and XML) is a JavaScript technique which involves special object XMLHttpRequest and sending/receive asynchronous (without full page reload) requests to server. This is an example of simple AJAX application which allows user to enter web-page url and display title of that page right after user stops typing. Programming Java http://www.anyexample.com/programming/java/java_hashmap_example.xml http://www.anyexample.com/programming/java/java_hashmap_example.xml Java HashMap example Java class HashMap(java.util.HashMap) is a fast and easy to use class representing hash table, a data structure that associates keys with values. Programming PHP http://www.anyexample.com/programming/php/downloading_files_from_amazon_s3.xml http://www.anyexample.com/programming/php/downloading_files_from_amazon_s3.xml Downloading files from Amazon S3 This is an example of non-interactive PHP script which downloads file from Amazon S3 (Simple Storage Service). Additional libraries like HMAC-SHA1 are not required. WebDev Rails http://www.anyexample.com/webdev/rails/rails_photo_gallery.xml http://www.anyexample.com/webdev/rails/rails_photo_gallery.xml Rails Photo Gallery This article contains step-by-step tutorial for creating photo gallery in Ruby On Rails -- basically a list of jpeg images with uploading/editing support. Command-line ImageMagick tools are used to generate thumbnails and determine image width and height. No Rails plugins or Ruby libraries (like RMagick) required. Programming PHP http://www.anyexample.com/programming/php/php_whois_client_function.xml http://www.anyexample.com/programming/php/php_whois_client_function.xml PHP whois client function This article contains PHP implementation of whois client (as a function ae_whois), which may be used to request domain information from specified whois servers WebDev Rails http://www.anyexample.com/webdev/rails/how_to_allow_some_safe_html_in_rails_projects.xml http://www.anyexample.com/webdev/rails/how_to_allow_some_safe_html_in_rails_projects.xml How to allow some safe HTML in Rails projects Although Ruby On Rails has support for various markup languages like textile and markdown via RedCloth and BlueCloth gems, often simple HTML is more preferable solution(like \"Some HTML is OK\" on Flickr). This article contains simple Ruby function ae_some_html which allows usage of basic HTML tags and converts everything else to entity-escaped HTML code. Programming C http://www.anyexample.com/programming/c/qsort__sorting_array_of_strings__integers_and_structs.xml http://www.anyexample.com/programming/c/qsort__sorting_array_of_strings__integers_and_structs.xml qsort: sorting array of strings, integers and structs qsort() is standard C function for sorting arrays. It is defined by ISO C standard, and implemented in most C/C++ standard libraries(stdlib.h). This article contains an example of using qsort() for sorting integers, strings and structs. Programming PHP http://www.anyexample.com/programming/php/gd___freetype_text_label_generator.xml http://www.anyexample.com/programming/php/gd___freetype_text_label_generator.xml Gd / FreeType text label generator This is an example of using Gd / FreeType to generate image text labels with TTF font. Provided script could be used as "text rasterization service" to generate arbitrarily text-images for a web site. MD5-based authorization is used to avoid image generation by unauthorized users. Programming PHP http://www.anyexample.com/programming/php/uploading_files_to_amazon_s3_with_rest_api.xml http://www.anyexample.com/programming/php/uploading_files_to_amazon_s3_with_rest_api.xml Uploading files to Amazon S3 with REST API Here is an example of command line non-interactive php script which uploads file to Amazon S3 (Simple Storage Service). Additional libraries like HMAC-SHA1 are not required. Programming PHP http://www.anyexample.com/programming/php/completely_disable_any_browser_caching.xml http://www.anyexample.com/programming/php/completely_disable_any_browser_caching.xml Completely disable any browser caching Here is a simple function which sends combination of headers that completely disable any browser caching. Programming PHP http://www.anyexample.com/programming/php/redirect_function_with_permanent_301_redirect_support.xml http://www.anyexample.com/programming/php/redirect_function_with_permanent_301_redirect_support.xml Redirect function with permanent 301 redirect support Here is an example of simple function ae_redir() for HTTP redirect. It supports relative site paths and permanent(seo-compatible) redirects. There is also function ae_redir_die() which stops execution of script after sending redirect. Programming PHP http://www.anyexample.com/programming/php/bar_chart_html_generator.xml http://www.anyexample.com/programming/php/bar_chart_html_generator.xml Bar chart HTML generator This article contains PHP function ae_bar_html for generating HTML/CSS based one-column bar charts. It is suitable for simple diagrams and does not require libgd. Programming PHP http://www.anyexample.com/programming/php/making_xml_xslt_driven_site_using_php.xml http://www.anyexample.com/programming/php/making_xml_xslt_driven_site_using_php.xml Making XML/XSLT driven site using PHP XML and XSLT technologies provides standard ways of separation of presentation and data. This article contains an example of simple php "xslt engine" for XML driven web-sites which implements caching techniques and Apache-based XML file processing. Programming C++ http://www.anyexample.com/programming/cplusplus/cplusplus_dynamic_array_template_class.xml http://www.anyexample.com/programming/cplusplus/cplusplus_dynamic_array_template_class.xml C++ dynamic array template class This article provides example of dynamic array implementation using C++ templates. It uses standard malloc/realloc memory allocation functions and simple "doubling size" resizing strategy. Our AeDynArray class interface resembles MFC standard CArray class, but uses only standard C libraries. Programming PHP http://www.anyexample.com/programming/php/5_useful_php_functions_for_mysql_data_fetching.xml http://www.anyexample.com/programming/php/5_useful_php_functions_for_mysql_data_fetching.xml 5 useful PHP functions for MySQL data fetching PHP usually comes with mysql extension mysql (mysql_... functions) which is rather low-level and requires writing too much code for a trivial tasks: error-checked execution of SQL queries, getting single row from SQL table, getting value from SQL table cell, etc. OOP mysqli extension isn't any better. In this article we present 5 useful functions which greatly simplify majority of real-life MySQL operations. WebDev JavaScript http://www.anyexample.com/webdev/javascript/ie7_javascript_prompt()_alternative.xml http://www.anyexample.com/webdev/javascript/ie7_javascript_prompt()_alternative.xml IE7 JavaScript prompt() alternative By default Internet Explorer 7.0 disables standard JavaScript prompt() function due to security reasons. Although users can enable this function again it's very unlikely that they will do so. This article presents alternative javascript function ae_prompt which displays fancy transparently shaded CSS-based prompt dialog and works with any modern browser including IE7. Programming PHP http://www.anyexample.com/programming/php/php_multiple_photo_thumbnail_generator.xml http://www.anyexample.com/programming/php/php_multiple_photo_thumbnail_generator.xml PHP multiple photo thumbnail generator Built-in PHP library gd does not have ready-to-use function for photo(jpeg) thumbnail generation. Although there are many such examples on the net, they are usually not suitable for effective generating series of thumbnails (240x240, 140x140, 80x80). This article provides php function thumbnail_generator and trivial image uploading script, which generates series of thumbnails.