2,322 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for vegaseat

If you have a Windows computer you can play musical beeps through the internal speaker. In this case it will sound like a very tiny Big Ben, brought to you by the module winsound and its method Beep().

2
2K
Member Avatar for Dave Sinkula

Some issues, such as leading whitespace and trailing characters that cannot be part of a number, were not handled in [url=http://www.daniweb.com/code/snippet357.html]Read a Floating-Point Value from the User, Part 1[/url]. Here such issues receive lip service. [I]See also [url=http://www.daniweb.com/code/snippet597.html]Read a Floating-Point Value from the User, Part 3[/url][/I].

0
440
Member Avatar for Dave Sinkula

Obtaining user input can be done in many surprisingly different ways. This code is somewhere in the middle: safer than [inlinecode]scanf("%lf", &n)[/inlinecode], but not bulletproof. It is meant to be a simple but relatively safe demonstration. Note also that there would be slight differences for using [inlinecode]float[/inlinecode] instead of [inlinecode]double[/inlinecode]. …

0
211
Member Avatar for Dave Sinkula

This snippet asks the user to fill in a structure and saves each record to the file. It uses append mode to add each new record to the end of the file. After all input is taken, it prints out the contents of the file. [i]Disclaimer: [font=courier new]fread[/font] and [font=courier …

1
492
Member Avatar for Dave Sinkula

Some issues, such as leading whitespace and trailing characters that cannot be part of a number, were not handled in [url=http://www.daniweb.com/code/showsnippet.php?codeid=266]Read an Integer from the User, Part 1[/url]. Here such issues receive lip service.

Member Avatar for drxs33
1
471
Member Avatar for Paul.Esson

I know what your thinking, You and everyone else has always wanted a clock that sits at the top of your command prompt and tells you the time. Why ? I made this in first year when i spent countless hours programming and little in bed. I decided i needed …

Member Avatar for Mpiangu
0
162
Member Avatar for Paul.Esson

My second C++ lab, bit of fun if i do say so my self. Its a stack that uses a linked list in C++ alot of debugging stuff still in here, but I like the debugging output anyway. Sorry about the lack of comments and

0
151
Member Avatar for tayspen
Member Avatar for vegaseat

Did you ever want to know how how many square inches are in a square meter? This short Python code allows you to get the answer. It uses a dictionary to simplify the conversions. Could be the start of a nice GUI program using radio buttons.

Member Avatar for vegaseat
2
3K
Member Avatar for vegaseat

The Python list container can be used for many practical things. In this somewhat light-hearted introspection of modern day politics we are looking at two lists and attempt to clear out elements that shouldn't be in both lists. No offense to anyone is intended, the outcome with the sets was …

Member Avatar for vegaseat
2
227
Member Avatar for vegaseat

A while ago I created a code snippet in C for the same question. Solving this question with Python is a lot simpler, and on top of that Python takes care of impossible dates with the appropriate error message.

Member Avatar for Lingson
2
225
Member Avatar for bumsfeld

My first experience with pointers. Learned how to spell a string foreward and backward using pointers. I hope you can learn too!

1
119
Member Avatar for vegaseat

A simple experiment with the ever so popular Mandelbrot fractal graphics, call it mathematical art, nice to look at. This set of experiments loops through a number of colors to make the whole thing more exciting.

Member Avatar for bumsfeld
1
181
Member Avatar for Electrohead

Example of using INCLUDE to show a nav bar. For beginners. Simply uses include to show an external file (in this case, nav.php) and that's it! You can also include this in another page with a CSS style. The CSS will be automatically included in formatting the INCLUDEd page! :D

Member Avatar for Dani
0
148
Member Avatar for yuppie
Member Avatar for vegaseat

Jumping through a few extra hoops allows you to display the common image format jpeg on a panel of the wxPython GUI window. All you need to do is to read in the image file as a binary, convert to a byte stream image and then to a bitmap. Now …

Member Avatar for Erik Vandamme
0
3K
Member Avatar for vegaseat

The other day I was looking at my family tree. There are my parents Antonio and Lucy Vegaseat, then my grandparents Alfonso and Ludmilla Vegaseat on my father's side and Roland and Helga Gruenspan on my mother's side. Then come my great grandparents, by now there are eight of those. …

Member Avatar for vegaseat
0
198
Member Avatar for vegaseat

While the calculation of the total resistance of two resistors in parallel is simple, this code shows you how to trap a number of potential errors that come with the entry of the required data. All is wrapped easily into a colorful GUI program, due to the simplicity of the …

2
3K
Member Avatar for vegaseat

The wxNotebook method from the wxPython module allows you to show a lot of data in a limited window space. It brings up tabbed pages you can click on to open each page. Enough said, run the code and experience the possibilities this humble method gives you.

Member Avatar for vegaseat
0
301
Member Avatar for Dave Sinkula

This snippet shows one way to count the number of lines in a file. It will count the last line of a file even if the last line does not end in a newline. Usage: [code]C:\>linecnt linecnt.c lines = 32[/code]

0
171
Member Avatar for gavindu123

This program was created by Gavindu Nuwan Dileepa and using this program you can add data to the stack , delete data and also you can view data from it... for more information contact [email]gavindu123@gmail.com[/email].. thanks

Member Avatar for Shark7
0
186
Member Avatar for Kerbrose
Member Avatar for rose_an
0
751
Member Avatar for Dave Sinkula

How might I write an implementation in C of the standard library function [inlinecode]strcmp[/inlinecode]? Here's how I might. [i]See also [url=http://69.93.117.133/code/snippet440.html] Strings: Comparing, Case-Insensitive[/url].[/i]

0
1K
Member Avatar for Dave Sinkula

How might I write an implementation in C of the standard library function [inlinecode]strcpy[/inlinecode]? Here's how I might.

0
193
Member Avatar for Dave Sinkula

How might I write an implementation in C of the standard library function [inlinecode]strstr[/inlinecode]? Here's how I might. [url=http://www.daniweb.com/code/snippet313.html]What if I need it to be case-[b]in[/b]sensitive[/url]?

0
164
Member Avatar for Dave Sinkula

How might I write an implementation in C a case-insensitive version of the standard library function [inlinecode]strstr[/inlinecode]? Here's how I might. [url=http://www.daniweb.com/code/showsnippet.php?codeid=314]But I need it to be case-sensitive[/url]?

Member Avatar for c_coder
0
2K
Member Avatar for Dave Sinkula

How might I write an implementation in C of the standard library function [inlinecode]strstr[/inlinecode]? Here's how I might.

0
134
Member Avatar for yuppie

A small script which converts Microsoft Office Documents (Word, Excel, Powerpoint) to Posscript. You can build your own PDF Converter with this script. More Python/Pywin32 examples can be found at [url]http://www.win32com.de[/url] and Python based PDF Converter (for server and client usage) can be found at [url]http://www.goermezer.de[/url] .

0
383
Member Avatar for vegaseat

This is another GUI program using the Tkinter module. It shows you how to change the background and foreground color of a component/widget. In this case it is a button. The button itself is used to toggle the color selection via a color dialog box. Enough comments have been added …

0
906
Member Avatar for cheenu78

A program that can send mails. This requires that you have activation.jar and mail.jar in you classpath.

Member Avatar for balagangadharm
0
174
Member Avatar for kerribyrd

This is a program I created a couple of weeks ago for class using DevC++ compiler. THis program allows the user 20 tries to guess a number between 1 and 100. It keeps track of wins and losses and offfers the option to continue or quit, displaying game stats.

Member Avatar for manutd
0
552
Member Avatar for kerribyrd

This is a program I created a couple of weeks ago for class using DevC++ compiler. THis program allows the user 20 tries to guess a number between 1 and 100. It keeps track of wins and losses and offfers the option to continue or quit, displaying game stats.

0
108
Member Avatar for anurag_pareek

This Program gives the details (name, kernel, machine type, domain, groups, sizeof data types, etc) of the host it is running on.

Member Avatar for maxthrill
0
120
Member Avatar for anurag_pareek

This Program gives the UserDetails of the logged in User. a) The RealName b) Login Name ( Why do we need this?) c) Home Directory d) Default Login Shell Additional Purpose of this code would be to invoke/ learn at man getpwuid and about struct passswd

Member Avatar for bumsfeld
0
1K
Member Avatar for Mahen

This program allows u to search the Search Engine of GOOGLE from the command line. Just type MUPROG "searchtext" GIMME LOTZ OF STARZ

0
201
Member Avatar for iacobus

Here are five simple snippets, to be used as an introduction to the use of unicode. This is, of course, an on-going thing, and hopefully additional snippets and comments will be forthcoming from the members.

Member Avatar for vegaseat
0
159
Member Avatar for Troy

class_http.php is a "screen-scraping" utility that makes it easy to scrape content and cache scraped content for any number of seconds desired before hitting the live source again. Caching makes you a good neighbor! The class has 2 static methods that make it easy to extract individual tables of data …

Member Avatar for Samir
0
347
Member Avatar for harshchandra

It's a simple program .Just enter any date in dd/mm/yyyy format.If you enter wrong you will get the message .

0
192
Member Avatar for Sparkplug188

This is a very basic way to make a delay that someone new to VB might be able to use.

0
133
Member Avatar for Troy

class_db.php is a database class that provides methods to work with mysql, postgres, and mssql databases. Other database types can be easily added. The class provides a common interface to the various database types. A powerful feature of the class is the ability to cache datasets to disk using a …

Member Avatar for ethen_th
0
223
Member Avatar for vegaseat

I was looking for a somewhat meaningful and interesting example to explain the Python class to beginners. A room full of multilingual students makes this phrase translator a good choice. You can experiment with it and add more languages and phrases.

Member Avatar for vartotojas
1
208
Member Avatar for vegaseat

Python's Tkinter module can be used to create a Graphics User Interface (GUI). This sample code creates a windows type form and positions a label and a canvas on the form. A simple shape is drawn on the canvas.

0
243
Member Avatar for Paladine

An example of using the ToString() DateTime Strings to produce common date & time output formats in Visual Basic.Net

Member Avatar for a.j.
-1
160
Member Avatar for Dave Sinkula

Obtaining user input can be done in many surprisingly different ways. This code is somewhere in the middle: safer than [inlinecode]gets(text)[/inlinecode] or [inlinecode]scanf("%s", text)[/inlinecode], but not bulletproof. It is meant to be a simple but relatively safe demonstration. The function [inlinecode]mygetline[/inlinecode] reads user input from the [inlinecode]stdin[/inlinecode] into a string …

Member Avatar for kedhar
0
328
Member Avatar for soumyajit_c`

Connection To Access Database and Save,Retrieve,Update D:\access\try.mdb=The Address of the Access database table 'Try'. Take a module as ModMain(Copy the code) table fields: idno,name,designation.(idno=auto number) textBoxes=TxtName,TxtDesignation And Combobox=CboRetrieve buttons=new,save,retrieve,exit

Member Avatar for bruce2424
0
1K
Member Avatar for vicky_dev

Hey People! This program gives you all Pythagorean triplets in a given range.( Eg. ( 3,4,5) - 3^2+4^2 = 5^2 ). I've used a pointer to allocate memory to hold the squares of all numbers in the range. The program uses a function to search for element in the array.

0
219
Member Avatar for vicky_dev

This program prints the prime factors of a number. Eg. 56=2x2x2x7 .I've heard its really important and stuff.I believe it is really efficient and simple. Uses two functions : one to check if a number is prime and other to return the next prime number.

Member Avatar for bofarull
0
172
Member Avatar for letmec

This is a program to calculate the n-th root of any number. This program uses the NEWTON_RAPTION_ITERATION method for calculation. The general formula to find the n-th root of any number is : *-------------------------------* * (((n-1)/n)*x0) + (1/n)*(N/d) * *-------------------------------* where n =1,2,3............ (n-th root). x0 is First approximate root. …

Member Avatar for vegaseat
0
174
Member Avatar for anurag_pareek

In this program i had just extracted the modulo of the number given,and keep on adding it in linklist. later on,i reversed the link list and displayed the result. By:-- Anurag Pareek

Member Avatar for Kellaw
0
590
Member Avatar for anurag_pareek

VIRTUAL PIANO It's a very simple sound program , Input device is mouse. Sound function is used to produce output.Working is very simple based on seven natural freqencies.Move mouse over keys for sounds. Change range and note the difference.

0
201

The End.