2,322 Reusable Code Snippet Topics
Remove Filter ![]() | |
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(). | |
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]. | |
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]. … | |
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 … | |
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. | |
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 … | |
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 | |
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. | |
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 … | |
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. | |
My first experience with pointers. Learned how to spell a string foreward and backward using pointers. I hope you can learn too! | |
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. | |
![]() | 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 |
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 … | |
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. … | |
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 … | |
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. | |
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] | |
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 | |
This is the coding needed to password any button on any switchboard from used in Access Database | |
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] | |
How might I write an implementation in C of the standard library function [inlinecode]strcpy[/inlinecode]? Here's how I might. | |
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]? | |
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]? | |
How might I write an implementation in C of the standard library function [inlinecode]strstr[/inlinecode]? Here's how I might. | |
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] . | |
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 … | |
A program that can send mails. This requires that you have activation.jar and mail.jar in you classpath. | |
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. | |
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. | |
This Program gives the details (name, kernel, machine type, domain, groups, sizeof data types, etc) of the host it is running on. | |
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 | |
This program allows u to search the Search Engine of GOOGLE from the command line. Just type MUPROG "searchtext" GIMME LOTZ OF STARZ | |
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. | |
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 … | |
It's a simple program .Just enter any date in dd/mm/yyyy format.If you enter wrong you will get the message . | |
This is a very basic way to make a delay that someone new to VB might be able to use. | |
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 … | |
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. | |
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. | |
An example of using the ToString() DateTime Strings to produce common date & time output formats in Visual Basic.Net | |
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 … | |
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 | |
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. | |
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. | |
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. … | |
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 | |
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. |
The End.