2,322 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for vegaseat

Just to give you an idea what Delphi can do, here is a plot of the ever popular sin(x). I have put enough information into the code comments so you can build the form. The PaintBox Paint Event takes care of the plotting.

0
973
Member Avatar for vegaseat
Member Avatar for DeFrog777

This simple program will draw several randomly sized and colored lines on the screen. Makes a good screensaver!

Member Avatar for Dani
0
207
Member Avatar for 1o0oBhP

A singly (sp) and a Doubly Linked list class to create linked lists. Can be used to make dynamic arrays and could also be templated to work with any data type (this is old code and i didnt know how to at the time). Has been extremely useful to me …

Member Avatar for 1o0oBhP
0
112
Member Avatar for vegaseat

The Standard Template Library (STL) vector is tempting. The burden of dimensioning an array is removed, and there are many wonderful functions to explore. The learning curve is a little steep, it will make your head swell, but in the end it's all worthwhile. Take a look at some of …

Member Avatar for vegaseat
1
178
Member Avatar for vegaseat

Let's expand the decimal to binary converter to include, amongst others, octal and hexadecimal conversions. Also shows how to exert some input control. Simple stuff!

1
186
Member Avatar for vegaseat

Let's say you worked in the White House and had to keep two lists, one for the friends and one for the enemies. The boss came to you and said: "The Almighty talked to me out of a burning bush last night, telling me that I shall make my enemies …

2
192
Member Avatar for vegaseat

Another experiment with the Standard Template Library (STL). This time we are taking a look at map. Map is a Sorted Pair Associative Container (a mouthful). The pair is -- const Key, Data --, where Key has to be unique. It is Key that is sorted. In this code sample …

1
169
Member Avatar for vegaseat

Using the C++ Standard Template Libraries (STL) can be easy, once you know how to do it. No need to putz around with doubly linked lists anymore! Here is code showing how a STL list allows you to add, insert, remove, sort, splice, merge, display, and clean-out-duplicate strings.

2
164
Member Avatar for vegaseat

Get simple information like serial number, bytes/sector, sectors/cluster, free and total disk space of your hard drive using Windows API calls.

Member Avatar for sytheron
2
155
Member Avatar for harshchandra

This program finds the solution of system of simulataneous equation Using GAUSS SEIDEL METHOD. This method is very popural among the students who studies Numerical Techniques.Though this program cant find the solution of every equations,it is widely used.This can only found the solutions of those equations which are Digonally dominant.

0
280
Member Avatar for vegaseat

What is so easy to do in HTML gets quite involved in C. Once you learn to look past the standard GUI overhead it becomes more obvious. This example shows the effect of the mouse cursor moving across a label by changing foreground and background colors.

0
219
Member Avatar for vegaseat

This program shows how to display a JPEG (also GIF,BMP,WMF etc.) image using some Windows Graphical User Interface C code. The program uses the uuid.lib file that comes with many C compilers.

Member Avatar for ashutosh_singh
2
1K
Member Avatar for vegaseat

This snippet shows how to draw a red circle on a Windows form. Original code via BCX, modified to compile with Dev C++. The GUI code looks a little complex. Gets simpler, once you get past the required overhead. For those who need some hand holding with the Dev C++ …

0
2K
Member Avatar for Narue

This code demonstrates AVL insertion and deletion. The code was originally written in C by myself a little while back for a tutorial. The translation to Java was fairly trivial, and to add a little excitement I even threw in a few generics. Yes, I'm aware of this line: tree.data …

Member Avatar for easternRAT
2
342
Member Avatar for ALT-F4

This small program simply allows the user to call two different methods passing along an interger value to each. One method will output numbers from zero utnil that integer value using iteration. The other method outputs numbers from zero to that integer using recursion.

Member Avatar for Dani
0
192
Member Avatar for Narue

Insertion sort, Selection sort, Bubble sort, Shell sort, Quicksort, and Heapsot. All optimized and ready to be experimented with. This is the framework for a Java application that speed tests various sorting algorithms (because there's usually little need to write one's own in production programs). Several popular algorithms were left …

Member Avatar for majestic0110
1
361
Member Avatar for DeFrog777

This is Similar to the Previous Snippet, but it puts indivdual pixels of different colors randomly on the screen. Also makes a nice screensaver!

Member Avatar for yvesli
0
329
Member Avatar for ReDuX

Ok, this is about as simple as it gets. This is a hit counter for your page that stores the count in a simple text file of your choosing. No need for a database, MySQL or otherwise. No complicated rubbish. Just one single function and one single file to store …

Member Avatar for DaveSW
0
143
Member Avatar for vegaseat

Use a Windows API call to add some color to your text output. A rewrite of an earlier C++ snippet for the C crowd.

2
568
Member Avatar for ReDuX

Well like my previous snippet but completing the collection i suppose, this snippet counts how long it takes to parse the page and displays it somewhere..

Member Avatar for mohamed badr
0
167
Member Avatar for ReDuX

You've seen those sites that say how many seconds it took to parse the page and how many database queries comprised the page. Well heres the database query bit...

Member Avatar for klinke
0
239
Member Avatar for vegaseat

The continued fraction expansion gives us the answer to life's most persistent questions, like what is sin(x) or even tanh(x). This surprisingly short code allows you to estimate SIN, COS, TAN, EXP, SINH, COSH and TANH fairly accurately. Careful, this code is not for the usual TV crowd! You should …

Member Avatar for bumsfeld
2
193
Member Avatar for Narue

This quicksort implements the basic recursive algorithm with three improvements. The first improvement is choosing the pivot based on the median of three values in the list to be sorted. This minimizes the chances of a worst case scenario. The second improvement speeds up the algorithm by termination when subfiles …

Member Avatar for Matt Labbé
1
1K
Member Avatar for BlackDice
Member Avatar for venomlash
0
122
Member Avatar for BlackDice

this is a wrapper around the AnimateWindow API. this allows random animations in a dialog. I just call it in the dialog's OnInitDialog() handler. The 'fade' effect has not been implemented because I didn't like the idea of having to call RedrawWindow or something like that because sometimes the borders …

Member Avatar for Satil
0
159
Member Avatar for BlackDice

Returns the name of a folder in a CString after allowing user to browse for it. This is just a wrapper around the SHBrowseForFolder API, but it's great for only allowing a user to browse for folders!

0
197
Member Avatar for vash shadows

Put it in you footer at Admin CP->Board Wrappers, and underline will disappear for username links. This code only makes sense when you have underline enabled for links in your CSS.

Member Avatar for peter_budo
0
170
Member Avatar for vash shadows

Have you ever wanted an arcade for your forum? Well now you can! The best part is you can play the games from x arcade at your forum, and not at some site! The instructions are easy to understand, and in no time you will have an arcade! Unlike If …

Member Avatar for Starnova
0
141
Member Avatar for vash shadows

Add to....Board Wrappers: Footer No need to really change anything in the code, if you want to select a different default URL just change the variable in the top of the script. It's there so that at least some URL is added to the website url field. You can't add …

0
148
Member Avatar for chound

This programme can find the dimensions of cuboid and cylinder. In cuboids it can find missing dimensions also. Eg. if length is missing and volume is given it will find the length.

0
430
Member Avatar for chound
Member Avatar for C#Coder

Adding this because it took literally an hour of searching before I found a code sample using fscanf that read more than just the first line of a file. This code assumes you're reading a file line by line that has the angle (int) followed by the Sine Value of …

0
4K
Member Avatar for dazzlindonna

If query is called getResults and your field name is called myField To change to 2-across or 3-across, or whatever, just change the MOD 4 to 2 or 3 or whatever number you wish.

0
114
Member Avatar for dazzlindonna

Change Your_Query to match your query name, Your_data to match your field name(s), and change the colors (ffffff and dadada) to match the colors you want.

0
148
Member Avatar for dazzlindonna
Member Avatar for dazzlindonna

Change the yourActionPage.cfm to the name of the page you want to open, and adjust the sizes and other parameters as you need.

0
185
Member Avatar for Drew

Learn how to take the Now() command and format it in a bunch of differnt ways. [B]Code from: [URL]http://www.iportalx.net[/URL][/B]

-1
325
Member Avatar for Syneticus

Alrighty! My goal here is to add the specified information into a MySQL database, but then also include a script that goes back and checks to make sure that the entrie given does not already exist. If you have any corrections, or any ideas on how to do this, I'd …

Member Avatar for Ginetta
0
109
Member Avatar for DanF

Hi, this is my first post here, just wanted a place to post some PHP code for a Savant2 plugin I created. I hope that's ok. If you've never heard of Savant/Savant2, you should definitely visit its website. Savant is a very elegant template solution for PHP that stands out …

Member Avatar for Dani
0
148
Member Avatar for Paladine
Member Avatar for Paladine
Member Avatar for SleepDepD
Member Avatar for SleepDepD

There are probably a few different version of this...here's the one I use which I find pretty simple:

Member Avatar for mjwest10
0
234
Member Avatar for SleepDepD
Member Avatar for SleepDepD
Member Avatar for Dani

A simplistic program to compute the volume of a cylinder when its radius and length are input via MyInput.class

0
191
Member Avatar for Dani

A simple demonstration of how MyInput.class can be used to input data from the keyboard. Computation is then done to compute the interest rate on a mortage.

Member Avatar for holmes008
0
201
Member Avatar for Dani
Member Avatar for p.bondam
0
201
Member Avatar for Dani

An example of method overloading. The program calls a function to get the square root of a number. The appropriate function (integer or double version) is executed.

2
210

The End.