2,322 Reusable Code Snippet Topics
Remove Filter ![]() | |
Theres no doubting that using Java Swing is time consuming on load times. So heres a demo splash screen to keep your users captivated. You will need two classes for this example i.e. Splash.java and SplashWindow.java (remember line: 8 change this to match your splash image) just change the class … | |
choose a random element from a sequence when a. you do not know how many elements are there before hand b. you want to make one single pass through the sequence c. you do not want to use auxiliary storage | |
There are times when you have to layout widgets on a window area fairly well spaced apart. To do this with pack() or grid() will be more than frustrating, for these occasions place() with its absolute coordinates comes to the rescue. Here is some Python/Tkinter GUI code showing you how … | |
A short C# code snippet to get the US Naval Observatory Master Clock Time from: [URL]http://tycho.usno.navy.mil/cgi-bin/timer.pl[/URL] The snippet displays the raw HTML code with the time infomation and then extracts one specific US time zone. | |
The normal XOR crypting is used with a small base64 twist to produce printable crypted text. | |
Just a quick look at the way C# writes and reads text files. | |
This code will create for you an application. we are goig to use visual c++ for it open visual, c++. click file then New. in the New dialogue box click projects. click win32 application. give it a name eg my_project. and click finish. Then again click file. click files. the … | |
hi every body try out this code it can store your info and then retriaeve it ant any time you wish. They are two codes each wrote separatly so first write the outputting code and run it. Then write the inputting code and also run it have fun:lol: | |
A closer look at some string methods, just having a learning experience and fun with this C# class. This program uses a simple MessageBox to display the results. | |
I could not resist to put this little utility into a GUI dress. The code shows you that the C# StringBuilder is nicely suited to create the binary string. Also included is a check to assure that the input is an all digit numeric string. | |
A quick look at finding a substring in a string and giving the position of the substring, if found. The string method IndexOf() has a number of options to explore. | |
C# has two types of strings, one is immutable and the other, the class StringBuilder, is mutable (dynamic). I just wanted to hang a short code snippet out there to show you some of the typical operations. | |
I followed Lardmeister's smart hints about creating templates with VC# 2003 and using SnippetCompiler.exe to write and test the rest of the program. It also allows you to build the executable (only 7k in size). The algorithm is from one of my Python snippets I wrote a long time ago. … | |
Here I made a GUI template with a Form, Button and Listbox using MS VCS 2003. MS VCS 2003 still produces a single file usable as a templet, whereas MS VCS 2005 smears files all over the map. Must be some marketing persons idea of market dominance. I took the … | |
It's spring break, so let's beep in C# code, actually a 440 Hz A. We are just borrowing the Beep() function from the Windows kernel. | |
There are plenty of things you can code in C# without having to rely on the ever so omnipresent MS-VCS. Here is an example of some typical drawings like lines, arcs, circles, text, curves and gradients you can create with C# and actually retain some control over the program. This … | |
A very simple C# console program to give you a table of investment (savings) growth over the years. To compile the program, copy and paste the code into an editor, and save it for instance as "savings.cs". Then find the C# compiler "csc.exe" in the "C:\Windows\Microsoft.NET\Framework\ ..." folder and run … | |
A simple picture viewer written in C# that allows you to view jpg, bmp, gif and animated gif image files. Uses a file dialog to load files, and keeps track of pictures already viewed with a list box. | |
A simple C# program showing you how easy it is to create a basic Windows GUI program which will display the results of a factorial number calculator. | |
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. … | |
This script displays the current time in your browser. You can choose the 12-hours format or the 24-hours format. | |
This snippet shows different types of csting liblary implementation. | |
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. | |
Here is just a simple program to sort two strings inputted from the user entered on the command line. | |
![]() | This snippet has a will convert Decimal number to Binary number. |
![]() | This snippet has a will convert Decimal number to Octal number. |
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 … | |
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 ;) | |
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 … | |
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 … | |
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. | |
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)) … | |
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. | |
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 … | |
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 … | |
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. | |
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. … | |
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 … | |
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. | |
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 = … | |
A simple guessing game for amatuer programmers like myself. | |
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 … | |
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 … | |
The FlashWindow component of wxPython will play those nice animated flash files found on the internet. They have file extension .swf usually. | |
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. | |
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 … | |
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 … | |
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. | |
This is a simple rock paper scissors game using random numbers. | |
this's daoremon's song code i hope you ever see doraemon's movie... |
The End.