1,916 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for thekashyap

Hi *, Here is a small program I had created to search for a given .class file within given CLASSPATH. It is primarily used in our project on test machines where lotsa ppl put lotsa patches in lotsa paths/jars and finally end up wondering which class file is being used. …

Software Development api java oracle unix windows-api
0
213
Member Avatar for eXceed69

This snippet shows different types of csting liblary implementation.

Software Development c++
Member Avatar for Ancient Dragon
0
134
Member Avatar for eXceed69

An interactive program using std::cin, std::cout, while loop and switch which will take from user no. 0 to 9 and print the number in characters. (eg. if user inters 0 the program shall respond You Have Entered : ZERO) If any negative number is given program should terminate.

Software Development c++
Member Avatar for Ene Uran
0
156
Member Avatar for Lazaro Claiborn

Here is just a simple program to sort two strings inputted from the user entered on the command line.

Software Development c
Member Avatar for John A
0
215
Member Avatar for GreenDay2001

This snippet has a will convert Decimal number to Binary number.

Software Development c++
Member Avatar for hashjoe
0
150
Member Avatar for GreenDay2001

This snippet has a will convert Decimal number to Octal number.

Software Development c++
0
132
Member Avatar for vegaseat

The surface or canvas established with wx.PaintDC() can be used to draw a number of shapes like lines, rectangles and circles. The snippet shows you how to select colors and then draw a few simple shapes. Use help(wx.PaintDC) to get information about the many things you can use this surface …

Software Development python
1
870
Member Avatar for mawe

The name says it all, I think. You have a nested list, you want to flatten it (e.g. because you want to count the occurence of an element), this function is all you need ;)

Software Development python
1
850
Member Avatar for Ene Uran

The small images you put on buttons and such are nice, but a real pain if you have to attach all those image files to your program. Python's base64 encoding module makes it easy to convert the binary image code to a string that you can simply make part of …

Software Development gui python tkinter
Member Avatar for vegaseat
0
2K
Member Avatar for RwCC

The following is a simple painting program. It uses Windows Forms and will allow you to draw whatever you want. You can also include code to change the colour or size of the brush via a right click menu by using code such as this: [CODE] MenuItem mi = new …

Software Development c#
Member Avatar for Ali.M.Habib
0
468
Member Avatar for Mushy-pea

Well, I asked Dani and she said I could create a Haskell catagory in code snippits just by submitting a Haskell program :p . What self respecting code repository would be without one? So here goes, this program calculates the nth triangular number, given n by the user. Steven.

Software Development
Member Avatar for Rashakil Fol
0
105
Member Avatar for ShawnCplus

This program was inspired by my college math 1 class. It takes the values of a1, a2, b1, b2, c1, c2 and solves, displays the equation and shows the work. It also stops if the equation is dependant or inconsistent (Zero division) Cramer's Rule if a1x+b1y=c1 and a2x+b2y=c2 then x=((c1*b2)-(c2*b1))/((a1*b2)-(a2*b1)) …

Software Development c++
0
3K
Member Avatar for Matt Tacular

Ever have two lists in python and you want to know what how much of one list the other contains? This code snippet will help you do that.

Software Development python
Member Avatar for vegaseat
0
360
Member Avatar for vegaseat

This little program uses Python and it's module pygame to do some sprite type animation. The rectangle that contains the image is moved and bounced within the window's frame. Pretty crude, since the whole screen frame is erased for each move. Actually it works smooth enough, and is relatively flicker …

Software Development image python
Member Avatar for vegaseat
1
970
Member Avatar for vegaseat

Sometime in my childhood biology class I heard that the fancy colors of butterfly wings aren't really true colors, but interference patterns. This program claims to create interference patterns using a series of 3d sine waves using Python's popular pygame module. The whole contrivance is pretty to look at, and …

Software Development python
0
222
Member Avatar for Ene Uran

Nothing fancy. just shows a simple monthly calendar in a Tkinter label. The trick is to use a fixed font so spaces take up the same area as numbers.

Software Development display python tkinter
Member Avatar for ndhdo
0
288
Member Avatar for vegaseat

The assumption is, that the typical workweek starts with Monday and ends with Friday. This is something the average working bloke has to live with (unless you work for a bank or the government). This little code will spit out a listing of all the workdays of a given month. …

Software Development python
1
3K
Member Avatar for jrcagle

Inspired by Bumsfeld's color tester, and wanting to give my students some practice at interpreting color strings, I wrote a little Tkinter program that asks the user to chose one of six buttons whose color most closely matches the color string printed at top. Comments welcome, and does anyone know …

Software Development python tkinter
0
222
Member Avatar for vegaseat

Yes, the Python module 'zipfile' can handle an archive of files. This snippet shows you how to pack a PKZIP format zip file with several files and then unpack these archived files to individual files again.

Software Development python
Member Avatar for 1337455 10534
0
688
Member Avatar for jrcagle

So I needed a way to represent a line in Python. My first stab was to create a function dynamically. But classes are so much ... classier, so here's a simple implementation of a line object, with plenty of room for additional methods. The line is created as l = …

Software Development python
Member Avatar for jrcagle
0
2K
Member Avatar for JJarvis

A simple guessing game for amatuer programmers like myself.

Software Development pascal
Member Avatar for mumble bee
0
111
Member Avatar for vegaseat

For those of you who think that an interpreted language like Python has to be slow, here is a small surpise. This snippet will draw a fair sized Mandelbrot set in a relatively short time. I cheated just a little, drawing the set in only black and white. Hey, nothing …

Software Development python
1
864
Member Avatar for vegaseat

Here is an example of a random spin button using a button surrounded by labels to create the feeling of a spin animation. This example uses the Tkinter GUI and lets you select numbers 1 to 6. If your game requires more then this, just add additional labels. You are …

Software Development gui python tkinter
Member Avatar for Bill Fisher
0
606
Member Avatar for bumsfeld

The FlashWindow component of wxPython will play those nice animated flash files found on the internet. They have file extension .swf usually.

Software Development flash python
Member Avatar for akennedy93612
0
423
Member Avatar for SpS

For all functions, a domain error occurs if an input argument is outside the domain over which the mathematical function is defined. On a domain error, the function returns an implementation-defined value.

Software Development c
Member Avatar for Dave Sinkula
0
340
Member Avatar for vicky_dev

This program solves the geometric problem, called the Convex Hull problem. Given a set of points, the objective is to find a region such that the line joining any two points lies within that region. Informally, it is the polygon of largest area that can be formed out of the …

Software Development c++
Member Avatar for manutd
0
577
Member Avatar for Ene Uran

Let's say you had a list of full names, where the name would consist of a title, followed by first, middle and last name, or maybe just title and last name. You can sort this list by last name only, by creating a temporary list of sublists of type [last …

Software Development python
0
487
Member Avatar for IP2Location

This module is a Python Library to support all IP2Locationâ„¢ database products. It has been optimized for speed and memory utilization. Developers can use the API to qeury all IP2Locationâ„¢ binary databases for applications written in Python.

Software Development api python
0
639
Member Avatar for manutd

This is a simple rock paper scissors game using random numbers.

Software Development c++
1
306
Member Avatar for gabriel_wadley

this's daoremon's song code i hope you ever see doraemon's movie...

Software Development c++
Member Avatar for vegaseat
0
6K
Member Avatar for iamthwee

Evaluates an expression as a string using reverse polish notation.

Software Development c++
Member Avatar for William Hemsworth
0
955
Member Avatar for Dave Sinkula

This snippet uses [INLINECODE]strtod[/INLINECODE] to be a little more stringent.

Software Development c
Member Avatar for bemboysms
0
249
Member Avatar for nanodano

This code snippet actually contains a few nifty things. There are two functions, hasVisited() and main(). hasVisited() makes use of a very handy function for CGI programmers: getenv. You can see I use it to retrieve REMOTE_ADDR which is the person's IP address. In main() it gets the count from …

Software Development c c# c++
Member Avatar for manutd
0
262
Member Avatar for vegaseat

This little snippet combines a Tkinter GUI application with sound from the pygame mixer. The snippet should do fairly well across platforms. I tested it on a Windows XP machine, but let me know your experience with other platforms.

Software Development gui python tkinter
0
453
Member Avatar for nihilks

The program uses doubly linked lists to store the numbers where each node contains a single digit . Hence numbers of any length can be used as operands . Program works only with +ve integers

Software Development c
0
142
Member Avatar for MattEvans

Ever wanted to evaluate a user-provided expression, maybe from a form input or otherwise, and return the result? eval($expr) is dangerous because eval(open $out, "> file.what"); will open the file, infact, eval(everything) will pretty much do everything. checking though everything is tedious, and manually parsing everything seems like a waste …

Software Development perl
Member Avatar for KevinADC
0
392
Member Avatar for teddy13
Member Avatar for ~s.o.s~
0
383
Member Avatar for kalyanraj
Member Avatar for progurammaar
0
507
Member Avatar for venomlash

This can be used for plotting radioactive decay of an unlimited* number of elements, decaying into each other. *Limited only by memory and user attention span.

Software Development c++
0
179
Member Avatar for Mouche

This game takes a random word from a list, gives you five prompts to guess letters in the word, and then it shows you a "masked word," filling in the letters you've guessed. Say the word is "hockey" and the user guesses: 'h,' 'e,' 't,' 'r,' and 's.'The masked word …

Software Development python
0
280
Member Avatar for vegaseat

This shows you how to draw a colorful bar graph of a data set using the Tkinter canvas and rectangles. An attempt has been made to use most of the canvas area for the graph. The bars are spaced and labeled with the corresponding value. The x-axis is simply the …

Software Development python tkinter
2
4K
Member Avatar for roverphoenix

the code now contains snippet to create the linked list too! any questions can be directed to [U]raghu_tillu@hotmail.com[/U]

Software Development c linked-list
Member Avatar for virusfree
0
152
Member Avatar for Ene Uran

The snippet shows the use of a list of class instances to form a sortable and searchable database for solvents, or for that matter other chemicals. The list can be expanded and all the needed data added at the same time.

Software Development python
0
269
Member Avatar for vegaseat

You can use the Tkinter canvas and the canvas.create_line() function to draw a line plot of a mathematical function. The canvas.create_line() function accepts a list of x, y points that you can create within a for loop. The resulting plot is centered and can be stretched along the x and …

Software Development python tkinter
0
2K
Member Avatar for bumsfeld

The wxPython GUI tool makes it very simple to create nice looking analog clock. The analog clock component was put into simple dialog frame and can be moved about the screen.

Software Development gui python
0
729
Member Avatar for vegaseat

Another famous fractal called the Sierpinski Triangle named after Polish mathematician Waclaw Sierpinski. He seemed to have played around with it the most. To state it simple, you start with an equilateral triangle and then form smaller triangles by connecting the midpoints of each of the sides. Some folks shade …

Software Development python
1
1K
Member Avatar for venomlash

For those of you who live at home, run this on your parents' computer fullscreen, blue background, white font. Then put the mouse over the block in the upper lefthand corner, and enjoy the show.:twisted:

Software Development c++
Member Avatar for lol_hacker101
0
134
Member Avatar for venomlash

This code will let you play Battleship against the computer (bad graphics, I know) for a while, upon which it quits without so much as an error message. Could an experienced coder look this over and tell me why? Thanks. Venomlash :?:

Software Development c++
0
125
Member Avatar for ~s.o.s~

Hello to everyone out there. Recently many people on different forums have been asking how to make a recursive function which reverses the string passed to it. But unlike the normal recrusive funtion which only prints out the reversed string, this implementation returns a pointer to reversed string.

Software Development c
Member Avatar for roverphoenix
0
172
Member Avatar for Lord Soth

Based on [url]http://astronomy.swin.edu.au/~pbourke/geometry/insidepoly/[/url] Converted to Delphi by Lord Soth

Software Development delphi pascal
Member Avatar for Zajoma
0
768

The End.