2,322 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for bumsfeld

This short code shows how to indicate the mouse-over event on wxPython button, similar to the mouse-over in web pages. Button changes colour when mouse pointer is over its area.

0
2K
Member Avatar for Dave Sinkula

In [url=http://www.daniweb.com/code/snippet259.html]Part 1[/url], the code reversed the string in place. This version uses a source and a destination string.

0
138
Member Avatar for bumsfeld

The myth is around that while loop is faster than the corresponding for loop. I checked it out with Python module timeit, and came to surprising conclusion. This snippet can easily be modified to time any of your functions you write.

Member Avatar for Begjinner
0
2K
Member Avatar for vegaseat

Yet Another Calculator using wxPython, smaller, but more advanced than the previous one. Wrote this one to test the Curry class, but it didn't work well. So there is no curry there. I found out that one has to be careful with the eval() function. If you write 012 instead …

1
155
Member Avatar for hemanthjava

JAVA Date Utility ( This program Demonstrates the proper use of Date functionality in common java programming scenarios ) Date and Time

Member Avatar for msg2ajay
0
206
Member Avatar for Rajnesh

/*This program works just like MS-DOS. It takes in the input, uses the C Library, uses the system files and function, executing and displaying the code on the same command prompt. */

Member Avatar for Ancient Dragon
0
1K
Member Avatar for vegaseat

Let mathematics do your art work! It is amazing how a simple mathematical formula can draw very intricate shapes. Here we draw a fractal tree on a Python Image Library (PIL) blank image, and save the finished drawing as an image file in one of the popular formats. Look at …

0
694
Member Avatar for vegaseat

The wx.BitmapButton shows an image, great for those folks who think that a picture is worth a thousand words. The snippet gives an example how to load the image, size the button, and put the image on the the button.

Member Avatar for InfoClock
0
827
Member Avatar for Jessehk

This is a simple, but complete (pseudo) random password generator. Examples of usage: [code] $ ruby pgen.rb soovmuvytv $ ruby pgen.rb --length=20 bynnugipyeeghdbihcdn $ ruby pgen.rb --length=20 -n v3ji3awj1trzjlda5oax $ ruby pgen.rb --length=20 -np :sa6vafpummpttjp?qo: [/code] For complete usage guidelines, run [inlinecode]$ ruby pgen.rb --help[/inlinecode] This (hopefully) serves as both …

-1
171
Member Avatar for bumsfeld

The program takes text and establishes dictionary of character:frequency. This dictionary is then presented sorted by character. Since it is important to show the most frequent characters, two methods are given to present dictionary sorted by frequency. Should all be very good for learning Python.

0
627
Member Avatar for nanodano

This snippet shows how to use command line arguments as variables in your program. A command line argument is extra information you give a program at runtime, by typing the information after the program name like so: Linux might look like this: user$: ./myprogram argument1 argument2 A windows command prompt …

0
186
Member Avatar for vegaseat

Just a small Python program to calculate monthly payments and other costs. I have compared it with some of the calculators available from many of the online mortgage companies, and results seem to match.

2
1K
Member Avatar for Jaks_maths
Member Avatar for ~s.o.s~
0
153
Member Avatar for vegaseat

In this snippet we are playing around with wxPython's buttons, showing you how to bind the mouse click event, enable and disable, show and hide the buttons. Each button also has a tool-tip (hint) associated with itself.

Member Avatar for Racoon200
0
4K
Member Avatar for vegaseat

If you want a variable in a C function to retain its last assigned value, you simply declare it as static. Python does not have static variables, but you can impersonate one in different ways. The default list argument is my preferred option. Here are some examples.

0
601
Member Avatar for Jaks_maths

Returns the duplicate value in array t[n], which contains numbers 1 to n-1. Given two approaches with O(n) and O(n-square) complexities.

Member Avatar for yogeshwar
0
129
Member Avatar for vegaseat

Py2Exe takes your Python code file and packages it into an executable file that you can distribute to a client that does not have Python installed. The executable file contains your byte code, all the required modules and the Python interpreter. It is not a small file. The snippet is …

Member Avatar for Aestter
1
375
Member Avatar for Jaks_maths
0
120
Member Avatar for Jaks_maths
Member Avatar for bumsfeld

Do you think that people act demented during full moon nights? This small python program will tell you moon phase of a date you give it, so you can take precautions!

0
4K
Member Avatar for dubeyprateek

[B][COLOR="Red"]Introduction[/COLOR][/B] There are many times when we try to create a binary search tree of many different data types. This article explains creation of a template library CTree. template <class T>class CTree can be used to create a binary search tree (BST) of any data type. [B][COLOR="red"]Features[/COLOR][/B] This class support …

0
164
Member Avatar for vegaseat

This small snippet shows how to load and display HTML (Hyper Text Markup Language) with wxPython's HtmlWindow(). This could be particularly useful with instruction and help text. HTML allows you to include pictures, fancy fonts and links.

0
1K
Member Avatar for vegaseat

When I first met folks in Las Vegas that used biorhythm values of the top players in a team to place their bet, I thought they were a little odd. Some of them were successful, but I am sure biorhythms were not the only thing they considered. You can read …

0
3K
Member Avatar for Narue

FASM can output an executable PE directly, but sometimes you want to output an object file for linking with modules in other languages. The following program can be used to link with the C library of the GCC compiler with the following commands: C:\>fasm hello.asm hello.obj C:\>gcc hello.obj -o hello.exe …

0
280
Member Avatar for Narue

Some languages are hard to get started in. FASM appears to be one of these languages because the documentation is not detailed enough for a beginner. That's a shame because FASM is (in my opinion) one of the better assemblers. The following snippet is a simple Hello, world! program which …

0
1K
Member Avatar for vegaseat

Just in time, a short Python code snippet to calculate the date of Easter Sunday of a given year. This can be expanded to calculate the important date of Mardi Gras too.

0
4K
Member Avatar for Banderson

[COLOR=Blue] Ever since PHP turned register_globals_off I have had problems here and there in my codes. I searched hard and long for a simple fix while keeping globals turned off. Fortunately, I found one! I have posted it below for your convenience and it is also described [URL=http://www.nasatech.com/PHP-DOCS/faq.misc.html#faq.misc.registerglobals]Here[/URL]. I'm not …

Member Avatar for Banderson
0
430
Member Avatar for vegaseat

Using an SDL (Simple DirectMedia Layer) wrapper is one way to play sound and music with Ruby. I have tested this snippet with .MID .MOD and .WAV files and it performs well. There are several SDL wrappers for Ruby available, I picked RUDL because of its simplicity. RUDL is great …

0
296
Member Avatar for vegaseat

I took the data of an old State Trivia game and applied it to Python. The data forms a series of lists with matching indexes. One example of how to ask a trivia question, present four possible answers, and how to evaluate the correct answer is given. You can expand …

0
744
Member Avatar for Lord Soth

--- Basic Datatypes --- --- Form Management --- --- Data Access --- --- Component model ---

0
744
Member Avatar for Lord Soth

You can use any of the commented constants to perform the explained function. You might need to adjust the process privilege on NT based OSes.

0
213
Member Avatar for Lord Soth
Member Avatar for Lord Soth
Member Avatar for Lord Soth

In case there are mote than one NIC (Network Interface Card) the coe gives the MAC of the first adapter. You can change the 0 on the line qoted below to take the MAC of other NICs if present. "Result := GetAdapterInfo(AdapterList.lana[0]) "

1
1K
Member Avatar for Lord Soth

This code disables font smoothing for a TLabel component. Can easily be converted for other VCL controls. Loren Soth

0
347
Member Avatar for Vagabond

Beginner C++ - A simple calculator writen in C++, compiled on Tubo C++ v4.5 & Borland C++ 5.5. The user inputs numbers & chooses '+','-','*'/' The operator is tested. If correct the appropriate sum is preformed.

0
154
Member Avatar for mnemtsas
Member Avatar for bumsfeld

Question of wordcount program similar to Unix wc came up in the forum and I worked on a solution. Program shows number of lines, number of words, number of characters and text file's name. Good learning for commandline, file and string handling.

1
3K
Member Avatar for Comatose

The Relative of push is pop. Pop removes the last item in an Array, and returns the value into a single (scalar) variable. Again, due To VB Limitations, this one works on strings.

0
202
Member Avatar for Comatose

Simple Function To Simulate The Push Command, due to VB's limitations, This one is Specific To Strings. (Simple enough to modify for integers or variants, etc)

0
208
Member Avatar for kharri5

This is a little code for a shell that allows for simple redirection and multiple yes! MULTIPLE piping abilities. It is slightly glitched for background processes, and this is only my second program written with C/C++ so it looks to be quite inefficient, but the piping works pretty nicely. The …

Member Avatar for ZeRo 00
0
224
Member Avatar for bumsfeld

The little program allows eye patients to test their color skills. They are given a random color rectangle by the computer and are then asked to match the color as closely as they can using sliders of the three basic colors. An evaluation button examines the closeness of the results.

0
418
Member Avatar for Rajnesh

This prog uses SQL Server's Master Databases xp_cmdshell stored procedure (Shell Commands) to send messages in a LAN.Make Sure the driver name is 'netsend' and it points to Master Database. Check and change the username and passwords in the Java Program also.Make sure you have sufficient priviledges to execute stored …

Member Avatar for Antony Prabu
0
187
Member Avatar for vegaseat

A list comprehension derives a new list from an existing list, and was adopted by Python from the Haskell language. This snippet tries to explain the development of list comprehension and shows a number of uses, including nested list comprehension. The benefits are simplicity (after an initial learning bump) and …

1
272
Member Avatar for vicky_dev

This program calculates the determinant of a square matrix of any order using a recursive function. Uses a square matrix struct and related functions.

Member Avatar for royujjal
0
394
Member Avatar for Eng. theFOX

count the number of occurrences of a sub-string in another string. a good example for learning how to make your own functions like strcpy, strlen and strcmp

0
172
Member Avatar for tayspen
Member Avatar for Dave Sinkula

Yet another angle at this same topic. [i]See also [url=http://www.daniweb.com/code/snippet318.html]Parsing a String into Tokens Using strcspn, Part 1[/url] and [url=http://www.daniweb.com/code/snippet443.html]Parsing a String into Tokens Using strcspn, Part 2[/url].[/i]

0
727
Member Avatar for Dave Sinkula

This snippet is a variation of the code in [url=http://69.93.117.133/code/snippet318.html][i] Parsing a String into Tokens Using strcspn, Part 1[/i][/url]. It uses canned strings rather than reading from a file. [i]See also [url=http://www.daniweb.com/code/snippet444.html]Parsing a String into Tokens Using strcspn, Part 3[/url].[/i]

0
747
Member Avatar for roverphoenix

Regular expression pattern match in a string, I only checked with * as wild card, other wild card characters are easy implement but I havent done that. any problems you can email me @ [email]rramaswa@usc.edu[/email] platform - Unix/Linux, havent tested in windows, should'nt be a problem unless some standard header …

Member Avatar for ~s.o.s~
0
172

The End.