In the context of programming and software applications, ad hoc is typically used to signify that
some coding (or more generically, some definition/specification) is done at run-time,
rather than pre-defined and encaspsulated in the application.
Ad hoc items have the characteristic of being done to serve a particular purpose rather than a generic or pre-defined one.
One may run some ad-hoc queries in SQL to familarize oneself with the the database content. (Equvalent expression would be "writing queries on the fly"). This differs from one's writing queries in the context of a program whereby the list of columns to get, the filters to apply etc. are driven by the application's specifications.
In a very similar usage, and end-user may request the ability to run ad-hoc reports (equivalent expression/underlying concept: "a custom report feature"), which indicates the need for the application to allow end users to decide, at run time, which elements of the report they wish to see (possibly in which specific order etc.).
One may also [typically] quickly "whip-up" a small program for to serve a particular purpose, such as say to parse some input for loading a database (Possible equivalent: "Throw-away code"). Such ad-hoc programs are expected to be used once or a few times, and in the limited timeframe which surrounds the a particular task. The opposite would be to write a generic import utility which may be reused in similar but different contexts (and be use/reused over time).
This article is about the Latin phrase. For other uses, see Ad hoc (disambiguation).
Ad hoc is a Latin phrase meaning "for this". In English, it generally signifies a solution designed for a specific problem or task, non-generalizable, and not intended to be able to be adapted to other purposes (compare with a priori).
Common examples are ad hoc organizations, committees, and commissions created at the national or international level for a specific task. In other fields, the term could refer, for example, to a military unit created under special circumstances, a tailor-made suit, a handcrafted network protocol (e.g. ad hoc network), a temporary banding together of geographically-linked franchise locations (of a given national brand) to issue advertising coupons, or a purpose-specific equation.
Ad hoc can also be an adjective describing the temporary, provisional, or improvised methods to deal with a particular problem, the tendency of which has given rise to the noun Adhocism. It also could mean shifting contexts to create new meanings or inadequate planning. 
According to The Chicago Manual of Style, familiar Latin phrases that are listed in Merriam-Webster, such as "ad hoc", should not be italicized.
Main article: Ad hoc hypothesis
In science and philosophy, ad hoc means the addition of extraneous hypotheses to a theory to save it from being falsified. Ad hoc hypotheses compensate for anomalies not anticipated by the theory in its unmodified form.
Scientists are often skeptical of scientific theories that rely on frequent, unsupported adjustments to sustain them.
In the military
In the military, ad hoc units are created during unpredictable situations, when the cooperation between different units is suddenly needed for fast action, or from remnants of previous units which have been overrun or otherwise decimated.
Main article: Wireless ad hoc network
The term ad hoc networking typically refers to a system of network elements that combine to form a network requiring little or no planning.
- Howard, R. (2002), Smart Mobs: the Next Social Revolution, Perseus
- The dictionary definition of ad hoc at Wiktionary