1,916 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for vegaseat

Using count() from Python's itertools module and the Tkinter GUI toolkit's after() function, you can create a simple counter that counts up the seconds until the Stop button is pressed.

Software Development gui python tkinter
1
3K
Member Avatar for avgprogramerjoe

This code takes a string a cyphers it by shifting it's position in the alphabet. I've gotten it so it can pretty much take paragraphs. It's quite neat to play with. For example the above when shifted to 5, would be: Ymnx htij yfpjx f xywnsl f hDumjwx ny gD …

Software Development python
Member Avatar for ShawnCplus
0
143
Member Avatar for Tight_Coder_Ex

User can enter an ascii string of up to 48 characters consisting of 1's or 0's, with randomly interspersed whitespace. IE: [B]1011111001011110 [/B]will be evaulated equally to [B][1011][111....cc001cccx01 111hhhh0 [/B]Algorithm parses from right to left so will be truncated at 16 position Purpose is to give all those still programming …

Software Development algorithm assembly
0
438
Member Avatar for jasimp

This one works pretty fast, even for large numbers. Like it says, aproxomite end number, and that is because it will generally go one fibonacci number above what you specify.

Software Development python
Member Avatar for ilovepython1978
0
150
Member Avatar for TkTkorrovi

You likely want something graphical, where the things move. GTK version of the classic arcade game Asteroids.

Software Development c
Member Avatar for TkTkorrovi
0
140
Member Avatar for vegaseat

The wxPython wx.lib.fancytext widget allows you to display super and subscripts in texts, and allows you to change fonts and colours too. All this is done with XML coded strings. XML documentation code is tag based and not that difficult to understand. It looks rather similar to the older HTML …

Software Development python xml
0
416
Member Avatar for jasimp

All this snippet does is asks you for some information and then uses it and some math to guess your age. Pretty simple but I have to start somewhere.

Software Development python
Member Avatar for majestic0110
0
157
Member Avatar for vegaseat

The wxPython GUI toolkit has a number of calendar widgets, but the one that is most customizable is the wx.lib.calendar widget. Here we expanded it to colour the weekends and the holidays supplied by a dictionary of 'month: list of holiday dates in month' pairs. Since some holiday dates can …

Software Development gui python
0
2K
Member Avatar for bumsfeld

The wxPython GUI toolkit has a nice numeric LED widget (LEDNumberCtrl from the wx.gizmos module) that is used here for displaying the current time in very visible 7 segment LED color display. It also shows the application of the time module and wx.Timer(). The code is simple as far as …

Software Development gui python
0
2K
Member Avatar for TkTkorrovi

A small demo about how to use GTK label as a simple console. To compile GTK program, `pkg-config gtk+-2.0 --cflags --libs` should finally be somewhere in the compiler command line in the bash-like shell.

Software Development c
0
313
Member Avatar for darkscript

Gives different combinations(Permutations) of string in input

Software Development c++
Member Avatar for ShawnCplus
0
594
Member Avatar for TkTkorrovi

Replaces every occasion of the pattern, or only the first occasion if there is a subexpression, between \( and \), anywhere in the regular expression, as repeated replace is not what one would expect in that case. The string size is restricted in POSIX regular expressions to the size of …

Software Development c
Member Avatar for xaviv
0
1K
Member Avatar for darkscript

This filters out the letters and numbers in the parameters you give it.

Software Development c++
Member Avatar for hinduengg
0
127
Member Avatar for Sturm

Here are some functions I made for SDL abstraction:

Software Development c++
Member Avatar for Sturm
0
160
Member Avatar for vijayan121

a string which can be used ala std::string, preserves case, but comparisons are not case sensitive.

Software Development c++
Member Avatar for ~s.o.s~
0
463
Member Avatar for Arman Majumder

A JOptionPane version of the game of Penny Pitch. Uses numerical values spread on a board, and computer picks randomly chosen spot to place a penny and at the end of a run adds up the total score. *Two separate programs, PennyPitchGame and Square (Square Class)*

Software Development java
Member Avatar for NovaWarlock
0
2K
Member Avatar for Arman Majumder

A program that compounds interest [FONT=&quot]continuously [/FONT]to a specified premium, rate, and number of years. Displays the total work up in the GUI panel in a tree form.

Software Development gui java
0
178
Member Avatar for Arman Majumder

A simple program that displays the Muller-Lyer Illusion. Also tests the ability to draw simple figures using the Paint Component function.

Software Development gui java
0
1K
Member Avatar for Arman Majumder

A GUI form of the Game of Craps. Takes in total bank roll and bet for each round of the game. *Two seperate programs, Craps and CrapsData(Craps Class)*

Software Development gui java
0
1K
Member Avatar for Arman Majumder

A very simple program, which displays the coordinate points for the center point of the panel. Automatically updates the (X,Y) form coordinates with size modification.

Software Development gui java
0
731
Member Avatar for Arman Majumder

A red circle moves back and forth horizontally, when clicked (with a mouse) the circle halts motion and the background colour changes randomly, if clicked again the circle resumes it's motion and changes the background colour randomly. This loop continues until the user exits the program. *Two separate programs[FONT=&quot][/FONT], CirclePanel …

Software Development gui java
Member Avatar for cUtEAkew
0
1K
Member Avatar for Arman Majumder

A fixed Checkerboard board, which tests multiple panels each with alternating colors (Red and Black). Input the dimensions to output the board.

Software Development gui java
0
1K
Member Avatar for Arman Majumder

A simple GUI that tests the GridLayout function, multiple panels, and different coloured panels.

Software Development gui java
0
301
Member Avatar for msaqib

Demonstration of Linked list in java. Very simple and well commented java code for the beginners. Linked list of points are used to create a Polyline and display it More java codes at [URL="http://www.mycplus.com"]www.mycplus.com[/URL]

Software Development java linked-list
Member Avatar for jwenting
0
246
Member Avatar for sweetleaf

THE program highlights how to create a 2d array in freestore using pointers.. this is my first post so if i commit any fallacies regarding protocol or syntax please forgive me ....

Software Development c
0
111
Member Avatar for GreenDay2001

This would let you store different things of same type into one data structure, here its a list. A good and popular example would be file and folder hierarchical structure in your computer. Perhaps this is what this code demonstrates. The code has two classes [INLINECODE]File [/INLINECODE]and [INLINECODE]Directory[/INLINECODE](derived from File). …

Software Development c++ data-structure linked-list
0
298
Member Avatar for aj.wh.ca

Problem Description ----------------------- I tried to download my favourite site containing essays on history (leeching) with depth 4. For some reason say my download tool problem, I realized I could not download all the files. I had with me a list of files (list1) I downloaded and list of files …

Software Development python
Member Avatar for vegaseat
0
115
Member Avatar for Ene Uran

This simple Python code uses the Tkinter GUI toolkit and the Python Image Library (PIL) to create a program that allows you to grab an image of the display screen (or portion of it) and save it to an image file. Unfortunately, the ImageGrab.grab() method only works on a Windows …

Software Development apple gui python tkinter unix
Member Avatar for AndyGman
1
3K
Member Avatar for vegaseat

Just a little mathematical exercise in geography, namely the use of longitude and latitiude coordinates to calculate the distance between two given cities. You can obtain the coordinates for just about any earthly city from [URL="http://www.ASTRO.COM"]WWW.ASTRO.COM[/URL]. The coordinates are in a format like 35n13 (35 degrees, 13 minutes north). The …

Software Development python
3
2K
Member Avatar for Stylish

Here is a little spinner thing for the command line, used when your current bash script is waiting on a background/system process. The weird character is ^H or a backspace.

Software Development shell-scripting
Member Avatar for cfajohnson
0
254
Member Avatar for thekashyap

------------------------------------------------------------ [COLOR=Blue][B]Intro:[/B][/COLOR] This is a small program that measures the performance of given java classes. In snippet there are 2 classes: 1. TestClass.java contains all java classes that are being measured for performance, I've picked up Narue's Sorting Algorithms as AUT (application under test) 2. AJPerf.java: contains the aspect that …

Software Development java java-jsp
Member Avatar for thekashyap
0
150
Member Avatar for Fungus1487

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 …

Software Development java java-swing
Member Avatar for newtonorina
0
169
Member Avatar for vijayan121

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

Software Development c storage
0
736
Member Avatar for vegaseat

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 …

Software Development gui python tkinter
1
619
Member Avatar for vegaseat

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.

Software Development c#
Member Avatar for Mustafa Laith
0
685
Member Avatar for vegaseat

The normal XOR crypting is used with a small base64 twist to produce printable crypted text.

Software Development python
2
350
Member Avatar for vegaseat

Just a quick look at the way C# writes and reads text files.

Software Development c#
Member Avatar for cVz
0
548
Member Avatar for Mpiangu

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 …

Software Development c++ open-source
0
158
Member Avatar for Mpiangu

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:

Software Development c
Member Avatar for Mpiangu
0
194
Member Avatar for Lardmeister

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.

Software Development
0
167
Member Avatar for Lardmeister

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.

Software Development gui
Member Avatar for Lardmeister
0
380
Member Avatar for Lardmeister

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.

Software Development
0
232
Member Avatar for vegaseat

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.

Software Development c#
Member Avatar for varagpraveen
0
192
Member Avatar for vegaseat

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. …

Software Development algorithm apple c# delphi
Member Avatar for Ene Uran
0
1K
Member Avatar for Lardmeister

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 …

Software Development gui
Member Avatar for vegaseat
0
457
Member Avatar for Lardmeister

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.

Software Development
Member Avatar for HLA91
0
179
Member Avatar for Lardmeister

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 …

Software Development
Member Avatar for nido
0
342
Member Avatar for Lardmeister

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 …

Software Development
Member Avatar for Lardmeister
0
159
Member Avatar for Lardmeister

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.

Software Development image
Member Avatar for vegaseat
0
175
Member Avatar for Lardmeister

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.

Software Development gui
Member Avatar for Lardmeister
0
214

The End.