AnyExamples - latest examples feed Free, tested & ready to use examples - for any topic we competent in en-us WebDev JavaScript JavaScript Array map function function allows you to create a new array from the existing one by calling a function on each element of the original array. WebDev JavaScript 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 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 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 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 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 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 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 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 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 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 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 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 Completely disable any browser caching Here is a simple function which sends combination of headers that completely disable any browser caching. Programming PHP 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 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 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++ 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 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 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.