Tag Archive for example

example tag XML C Sharp Documentation comment

// compile with: /doc:DocFileName.xml

/// text for class TestClass
public class TestClass
{
/// <summary>
/// The GetZero method.
/// </summary>
/// <example> This sample shows how to call the GetZero method.
/// <code>
/// class TestClass
/// {
///     static int Main()
///     {
///         return GetZero();
///     }
/// }
/// </code>
/// </example>
public static int GetZero()
{
return 0;
}

/// text for Main
static void Main()
{
}
}

source

mthfeedit configuration

###configuration feedit

plugin.tx_newsfeedit_pi1.mthfeedit {
#allowedGroups = 1
pid = 722

infomail = 1
email.from =
email.fromName =
email.admin =
email.field = FIELD FROM RECORD WHERE USERS EMAIL SHOULD BE FOUND.

fe_cruser_id = tx_newsfeedit_fe_cruser_id
fe_crgroup_id = tx_newsfeedit_fe_crgroup_id
fe_crgroup_id = 0
create.fields = hidden, category, title, bodytext, datetime, author, image
#create.fields = hidden, category, title, bodytext, datetime, author, author_email,image, imagetitletext

create.show_fields = title, category, bodytext, datetime, image
#create.show_fields = title, category, bodytext, datetime, author, author_email, image, imagetitletext

create.overrideValues {
hidden = 0
}

create.defaultValues {

hidden = 0
datetime = now
category = {$blogcategory}

}

create.evalValues {
title = required
}

}

source

Typoscript menu example

### Typoscript Code ##########
lib.submenu_lache= COA
lib.submenu_lache{
wrap = <div class="menu_left">|</div>
10 = TEXT
10{
data = leveltitle : 1
wrap = <div class="menu_left_top_tut">|</div>
}
15 = HMENU
15{
entryLevel = 1
wrap = <div class="menu_left_menu" >|</div>
1 = TMENU
1{
wrap = <ul id='menuList'>|</ul>
noBlur =1
ACT=1
ACTIFSUB = 1
NO{
wrapItemAndSub = <li class='menuItem'>|</li>
ATagParams = class='menuLink'
}
ACT{
wrapItemAndSub = <li class='menuItem'>|</li>
ATagParams = class='menuLinkAct'
}
ACTIFSUB{
wrapItemAndSub = <li class='menuItem'>|</li>
ATagParams = class='menuLinkAct'
}
}
2 = TMENU
2{
noBlur = 1
ACT = 1
ACTIFSUB = 1
wrap = <ul class='submenuList'>|</ul>
NO{
wrapItemAndSub = <li class='submenuItem'>|</li>
ATagParams = class='submenuLink'
}
ACT{
wrapItemAndSub = <li class='submenuItem'>|</li>
ATagParams = class='submenuLinkAct'
}
ACTIFSUB{
wrapItemAndSub = <li class='submenuItem'>|</li>
ATagParams = class='submenuLinkAct'
}
}
}
}

source

jQuery Simple Style Switcher

/** @id sipleSwitcher
* @classDescription Very simple style switcher using jQuery
*/
$(document).ready(function(){
$('#styleSwitch .button').bind('click', function(){
$('body').removeClass();//remove all the other classes
$('#styleSwitch .button').removeClass('selected');
$(this).addClass('selected');
switch(this.id){
case 'style1':
$('body').addClass('style1');
break;
case 'style2':
$('body').addClass('style2');
break;
case 'style3':
$('body').addClass('style3');
break;
}
return false;
});
});

source

Function Template

/*
Function:	<Function, ex. my_function( $param1, $param2 )>
Description:	<Description of what it does>
Parameters:	<Parameters for function>
Example:	<Show an example of your function in use, ex. my_function( "thisparameter", "newparameter");>
Requirements:	<Anything that your function requires>
Notes:		<Any other comments you have>
Author:		<your name and email/website address>
*/

source

append_content

function append_content($text) {
if ( $this->initem ) {
$this->concat( $this->current_item[ $this->incontent ], $text );
}
elseif ( $this->inchannel ) {
$this->concat( $this->channel[ $this->incontent ], $text );
}
}

source

Reusable Box with Images and CSS (implements a non-semantic variant of Sliding Doors)

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!--** Time-stamp: <[box.html] modified by Noah Sussman on Saturday, 2007.04.07 at 12 : 41 : 08 on GRIMOIRE> **-->
<title>Reusable Box (sliding doors)</title>
<style type="text/css">
/****************************************************************
** Reusable Box
** This is an image-based box design, which allows arbitrary
** expansion up to the width and height of its component images.
** See the "Sliding Doors of CSS" series of articles at A List Apart
** for in-depth explanation.
** Note that I have not actually implemented "Slding Doors," as the
** markup here is anything but semantic.
****************************************************************/
body { background: url(images/mars.png) }
.reusableBox {
background: url(images/left.png) no-repeat;
margin-left: -10px;  /* Using a negative margin to avoid overlap of transparent images. I learned to do this by reading css-discuss. NS 2007.04.06 */
position: absolute;
}
.reusableBox .presentationTop {
background: url(images/top.png) no-repeat top right;
margin-left: 10px;
/*     padding-top: 10px; */
}
.reusableBox .rbContent {
padding-top: 20px;
padding-left: 10px;  /* another 10px is added by the margin of presentationTop */
padding-right: 20px;
position: relative;
}
.reusableBox .presentationBottom {
height: 10px;
background: url(images/bottom.png) no-repeat bottom right;
position: relative;
top: 10px;
}
.reusableBox .presentationLeftBottom {
height: 10px;
width: 10px;
margin-left: -10px;
margin-bottom: -10px;
background: url(images/bottom.png) no-repeat top left;
position: relative;
}
.reusableBox .rbNipple {
background: url(images/nipple.png) no-repeat;
width: 15px;
height: 11px;
position: absolute;
top: 4px;
left: 22px;
}
.rbSource {  display: none; } /* this line is optional */
/* styles below here apply to the example implementations */
div#foo {
width: 320px; /* set the width of each box by its id */
top: 40px;
left: 500px;
position: relative;
}
div#downBalloon {
width: 200px;
top: 110px;
left: 740px;
position: relative;
}
div#downBalloon .rbNipple {
left: 134px;
}
p { display: inline; } /* optional */
code { display: block; padding: .3em; } /* optional */
</style>
<script type="text/javascript">
function makeWeb2Box(elId, width, top, left, hasNipple, nippleOffset) {
var el = document.getElementById(elId);
var elContainer = document.createElement('div');
elContainer.className="reusableBox";
elContainer.style.width = width;
elContainer.style.top = top;
elContainer.style.left = left;

var offset = (nippleOffset ? 'style="left: '+ nippleOffset +'px"' : '');
var nipple = (hasNipple ? '<div class="rbNipple"' + offset + '></div>' : '');

elContainer.innerHTML = '<div class="presentationTop"><div class="rbContent">' +
el.innerHTML +
'</div><div class="presentationBottom"><div class="presentationLeftBottom">' +
nipple +
'</div></div></div>';
el.parentNode.insertBefore(elContainer, el);
el.parentNode.removeChild(el);
}

window.onload = function() {
makeWeb2Box('bar', 400, 10, 40, true, 102);
makeWeb2Box('jsBox', 200, 300, 400);
}
</script>
</head>
<body>

<!-- snippet #1 -->
<div class="reusableBox" id="foo">
<div class="presentationTop">
<div class="rbContent">
<!-- snippet #1 ends -->

<p>Reusable box built with css </p>

<!-- snippet #2 -->
</div><!-- end of rbContent -->
<div class="presentationBottom">
<div class="presentationLeftBottom">
</div><!-- end of presentationLeftBottom -->
</div><!-- end of presentationBottom -->
</div><!-- end of presentationTop -->
</div><!-- end of reusableBox -->
<!-- snippet #2 ends -->

<div class="reusableBox" id="downBalloon">
<div class="presentationTop">
<div class="rbContent">
<h3>mars</h3>
<p>this is a popup built with css</p>
</div><!-- end of rbContent -->
<div class="presentationBottom">
<div class="presentationLeftBottom">
</div><!-- end of presentationLeftBottom -->
<div class="rbNipple"></div>
</div><!-- end of presentationBottom -->
</div><!-- end of presentationTop -->
</div><!-- end of reusableBox -->

<div id="bar" class="rbSource">
<p>Reusable balloon, built with JavaScript.
<code>
makeWeb2Box(someId (string), width (integer), top (integer), left (integer), [hasPointer (boolean), pointerPosition (integer)])
</code>
Turns the hidden div named 'someId' into a popup,
with or without a pointer (the default is no pointer).
If a pointer is specified, optionally set the left position
of the pointer image (the default is set in the CSS).
</p>
</div>

<div id="jsBox" class="rbSource">
<p>This is a box (not a balloon, because the pointer is omitted).  This box has been built with JavaScript.</p>
</div>

</body>
</html>

source

C – Example Buffer OverFlow

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
char *buffer1 = (char *)calloc(5, sizeof(char));
char *buffer2 = (char *)calloc(15, sizeof(char));
char *tmp;

strcpy(buffer2, "ls -a --color");
strcpy(buffer1, argv[1]);

// Indirizzi di memoria...
printf("%p <-- buffer1
", buffer1);
printf("%p <-- buffer2
", buffer2);
printf("

");

// Stampa indirizzi...
printf("Start code....
");
tmp=buffer1;
while(tmp<buffer2+15)
{
printf("%p: %c (0x%x)
", tmp, *tmp, *(unsigned int *)tmp);
tmp++;
}

printf("
");
system(buffer2);
return 0;
}

source

perl google soap example

#!/usr/bin/perl

use SOAP::Lite;
use strict;
use warnings;

@ARGV == 2 or die "Usage: google <query> <number of results 1-10>
";

my $key='OS7mOjxQFHIztxIYU9yb8y3ibYgY4w2o';

my($query, $maxResults) = @ARGV;

my @params = ($key, $query, 0, $maxResults, 0, '', 0, '', 'latin1', 'latin1');

my $result = SOAP::Lite->service("file:GoogleSearch.wsdl")->doGoogleSearch(@params);

print "Result:
";

print join "
", map( { qq{$_->{URL}} } @{$result->{resultElements}} );

Here is the Google include file:

<?xml version="1.0"?>

<!-- WSDL description of the Google Web APIs.
The Google Web APIs are in beta release. All interfaces are subject to
change as we refine and extend our APIs. Please see the terms of use
for more information. -->

<!-- Revision 2002-08-16 -->

<definitions name="GoogleSearch"
targetNamespace="urn:GoogleSearch"
xmlns:typens="urn:GoogleSearch"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">

<!-- Types for search - result elements, directory categories -->

<types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:GoogleSearch">

<xsd:complexType name="GoogleSearchResult">
<xsd:all>
<xsd:element name="documentFiltering"           type="xsd:boolean"/>
<xsd:element name="searchComments"              type="xsd:string"/>
<xsd:element name="estimatedTotalResultsCount"  type="xsd:int"/>
<xsd:element name="estimateIsExact"             type="xsd:boolean"/>
<xsd:element name="resultElements"              type="typens:ResultElementArray"/>
<xsd:element name="searchQuery"                 type="xsd:string"/>
<xsd:element name="startIndex"                  type="xsd:int"/>
<xsd:element name="endIndex"                    type="xsd:int"/>
<xsd:element name="searchTips"                  type="xsd:string"/>
<xsd:element name="directoryCategories"         type="typens:DirectoryCategoryArray"/>
<xsd:element name="searchTime"                  type="xsd:double"/>
</xsd:all>
</xsd:complexType>

<xsd:complexType name="ResultElement">
<xsd:all>
<xsd:element name="summary" type="xsd:string"/>
<xsd:element name="URL" type="xsd:string"/>
<xsd:element name="snippet" type="xsd:string"/>
<xsd:element name="title" type="xsd:string"/>
<xsd:element name="cachedSize" type="xsd:string"/>
<xsd:element name="relatedInformationPresent" type="xsd:boolean"/>
<xsd:element name="hostName" type="xsd:string"/>
<xsd:element name="directoryCategory" type="typens:DirectoryCategory"/>
<xsd:element name="directoryTitle" type="xsd:string"/>
</xsd:all>
</xsd:complexType>

<xsd:complexType name="ResultElementArray">
<xsd:complexContent>
<xsd:restriction base="soapenc:Array">
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:ResultElement[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="DirectoryCategoryArray">
<xsd:complexContent>
<xsd:restriction base="soapenc:Array">
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:DirectoryCategory[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="DirectoryCategory">
<xsd:all>
<xsd:element name="fullViewableName" type="xsd:string"/>
<xsd:element name="specialEncoding" type="xsd:string"/>
</xsd:all>
</xsd:complexType>

</xsd:schema>
</types>

<!-- Messages for Google Web APIs - cached page, search, spelling. -->

<message name="doGetCachedPage">
<part name="key"            type="xsd:string"/>
<part name="url"            type="xsd:string"/>
</message>

<message name="doGetCachedPageResponse">
<part name="return"         type="xsd:base64Binary"/>
</message>

<message name="doSpellingSuggestion">
<part name="key"            type="xsd:string"/>
<part name="phrase"         type="xsd:string"/>
</message>

<message name="doSpellingSuggestionResponse">
<part name="return"         type="xsd:string"/>
</message>

<!-- note, ie and oe are ignored by server; all traffic is UTF-8. -->

<message name="doGoogleSearch">
<part name="key"            type="xsd:string"/>
<part name="q"              type="xsd:string"/>
<part name="start"          type="xsd:int"/>
<part name="maxResults"     type="xsd:int"/>
<part name="filter"         type="xsd:boolean"/>
<part name="restrict"       type="xsd:string"/>
<part name="safeSearch"     type="xsd:boolean"/>
<part name="lr"             type="xsd:string"/>
<part name="ie"             type="xsd:string"/>
<part name="oe"             type="xsd:string"/>
</message>

<message name="doGoogleSearchResponse">
<part name="return"         type="typens:GoogleSearchResult"/>
</message>

<!-- Port for Google Web APIs, "GoogleSearch" -->

<portType name="GoogleSearchPort">

<operation name="doGetCachedPage">
<input message="typens:doGetCachedPage"/>
<output message="typens:doGetCachedPageResponse"/>
</operation>

<operation name="doSpellingSuggestion">
<input message="typens:doSpellingSuggestion"/>
<output message="typens:doSpellingSuggestionResponse"/>
</operation>

<operation name="doGoogleSearch">
<input message="typens:doGoogleSearch"/>
<output message="typens:doGoogleSearchResponse"/>
</operation>

</portType>

<!-- Binding for Google Web APIs - RPC, SOAP over HTTP -->

<binding name="GoogleSearchBinding" type="typens:GoogleSearchPort">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>

<operation name="doGetCachedPage">
<soap:operation soapAction="urn:GoogleSearchAction"/>
<input>
<soap:body use="encoded"
namespace="urn:GoogleSearch"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:GoogleSearch"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>

<operation name="doSpellingSuggestion">
<soap:operation soapAction="urn:GoogleSearchAction"/>
<input>
<soap:body use="encoded"
namespace="urn:GoogleSearch"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:GoogleSearch"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>

<operation name="doGoogleSearch">
<soap:operation soapAction="urn:GoogleSearchAction"/>
<input>
<soap:body use="encoded"
namespace="urn:GoogleSearch"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:GoogleSearch"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>

<!-- Endpoint for Google Web APIs -->
<service name="GoogleSearchService">
<port name="GoogleSearchPort" binding="typens:GoogleSearchBinding">
<soap:address location="http://api.google.com/search/beta2"/>
</port>
</service>

</definitions>

source

ruby ascii golf example

#!/usr/bin/env ruby

$><<"e[2J";s,o,f,c,u=20,"#"," ";b,m=(z=0..s).map{z.map{(rand<0.3)?o:f}},[-1,0,1]*3;until c==b;c=b.map{|z|z.dup};$><<"e[H"<<b.map{|x|x*f}*"";s.times{|i|s.times{|e|n=(m.sort.zip(m)-[[0,0]]).select{|x,z|o==(c[i+x]||[])[e+z]}.size;n!=2?b[i][e]=n==3?o:f:f}};sleep 0.2;end

source