1,916 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for Begginnerdev

This is a module that can be used to save tiff images pass in from a file dialog. This module was translated from C# to VB.net, and the original project can be found [URL="http://www.codeproject.com/Articles/16904/Save-images-into-a-multi-page-TIFF-file-or-add-ima"]here[/URL]. I do not claim rights to this code. You can copy this code straight down into …

Software Development image vb.net
Member Avatar for Lolatorres
0
287
Member Avatar for vegaseat

This is an example of a singly linked list allowing you to enter a number of names and associated ages. The twist is that the names are inserted into the list in ascending order. When the list is displayed, it is already sorted by name. Note: This is not an …

Software Development c linked-list
Member Avatar for Ancient Dragon
1
470
Member Avatar for Gribouillis
Member Avatar for Graphix

Hey everybody, Lately I have written the game Hangman in many different languages (C, JavaScript, Java and PHP so far). Here is the code snippet for Java! It uses a words file, on the bottom of this post you will see a small example of a few words. The source …

Software Development java open-source
Member Avatar for JamesCherrill
2
4K
Member Avatar for vegaseat

The PySide (PyQT) GUI toolkit can be used to play wave sound files.

Software Development gui python
Member Avatar for vegaseat
1
3K
Member Avatar for sciwizeh

I made this minesweeper game earlier this summer. It shows many things, including: array use, 1D array to 2D array, gridlayout, changing the way a JButton works depending on mouse button used, floodfill, loops, GUI. slightly long, 382 lines, can probably be condensed. There is one known bug that i …

Software Development gui java
Member Avatar for sciwizeh
2
860
Member Avatar for vegaseat

PySide's QWebView can load a given url and display the web page associated with it with just a few lines of code.

Software Development python
1
1K
Member Avatar for TrustyTony

There is free tools to do the same, but I was curious to see what it takes to make one myself. For info see: [url]http://en.wikipedia.org/wiki/LC-3[/url]

Software Development python
Member Avatar for TrustyTony
5
2K
Member Avatar for deepakps

this is a small graphical program in c....which gives you a clear discription about what a graphics can do in c..(a simple one)

Software Development c
Member Avatar for Deepak_17
0
176
Member Avatar for vegaseat

Shows you how to get a Python object's memory size. Notice that there can be a difference between Python versions.

Software Development motherboards-cpu-ram python
Member Avatar for Tcll
3
527
Member Avatar for vegaseat

If you decorate a function, then some of the information is lost during the debugging process. Python supplies another decorator @wraps to help out. A decorator for a decorator, very interesting.

Software Development python
1
435
Member Avatar for NicAx64

Just use the SetTimer function after you Create the window , and just handle the WM_TIMER message inside the message loop. That's it !

Software Development c++
Member Avatar for irum.nageen.3
0
6K
Member Avatar for ddanbe

Squaring a number is a rather common task in programming, but if you want to square an integer. Easy you think! Int MySquare = AnInt *.AnInt; This will happily overflow without giving any exception if AnInt is bigger than 46340, unless you put your code in a checked block. Now …

Software Development
Member Avatar for kplcjl
0
397
Member Avatar for D33wakar

Similar to echoserver, but this one handles multiple clients by forking the process.

Software Development c client-server socket-programming unix
0
349
Member Avatar for D33wakar

This is a simple echo server that I've written while learning sockets programming. Compile the server and run it. You can connect to it using telnet like this: telnet localhost 1337 Disconnect the client by typing "/quit" without quotes.

Software Development c client-server socket-programming unix
0
390
Member Avatar for Dani

This is a program I wrote for my x86 assembly class which generates matrices, multiplies them, and computes how long the arithmetic took. It uses Irvine32.inc which came with the textbook.

Software Development assembly matrix-multiplication
Member Avatar for ESLAMIKA
1
5K
Member Avatar for Echo89

This is a function that generates a string of random characters to the length that you specify.

Software Development c c# c++
Member Avatar for 5n0wn1nja
0
7K
Member Avatar for Gribouillis

This snippet prints a python list of strings in multicolumn format (similarly to linux `ls` command). It uses module prettytable, available in [pypi](https://pypi.python.org/pypi/PrettyTable).

Software Development python
Member Avatar for Gribouillis
3
2K
Member Avatar for Gribouillis

This snippet is reserved for users of the KDE linux desktop. It adds a *service menu* to kde applications such as dolphin and konqueror, to launch an ipython dashboard in a directory in one click. More specifically, save the text of this snippet as a file `~/.kde/share/kde4/services/ServiceMenus/opennotebook.desktop` (create the directory …

Software Development python web-browser
1
632
Member Avatar for ddanbe

A modal dialog is a window that you must respond to. The MessageBox for example is such a window. It is a handy tool for displaying a warning or other kind of message to the user. But, you can configure it only in a limited way. Xcelled194 did a good …

Software Development html-css
Member Avatar for ddanbe
3
974
Member Avatar for aditya369

you need to give the input text files in the command line...

Software Development python
Member Avatar for Nils_1
0
267
Member Avatar for james.lu.75491856

THIS IS DANGEROOUS CODE, if it fails, it may prevent yu frome editing it. also, you can use the functions to do crazy stuff. Look at [this refrence](http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx) and change the `0x12` to what you want. (This one hold alt, so typing r will actibvate the menu that starts with …

Software Development python
Member Avatar for sneekula
-4
363
Member Avatar for vegaseat

Shows you how to create multiple Tkinter buttons in a loop, each with its own name, label and command response.

Software Development gui python tkinter
Member Avatar for CodingCabbage
2
1K
Member Avatar for vegaseat

The code sample shows how to get an image from the internet and show it in a Tkinter label widget.

Software Development image python tkinter
Member Avatar for Nils_1
4
2K
Member Avatar for ddanbe

The test.txt file I'm using is: 1,2,3,Name1,Pizza,Pizza Hut,7,8,9 1,2,3,Name2,goose,my home,7,8,9 1,2,3,Name3,chicken,airplane,7,8,9 Most of the explanation can be found in the snippet. Some CSV(Comma Separated Value) files often contain as first line, a header. You could skip this, or threat it a bit differently. I had no header, so I leave …

Software Development
Member Avatar for deceptikon
0
3K
Member Avatar for vegaseat

Just a simple image file slide show using PySide (PyQT).

Software Development image python
Member Avatar for sneekula
2
4K
Member Avatar for ~s.o.s~

Here is a simple implementation of implementing a simple Left trim (ltrim) and Right trim(rtim) of unwanted characters from a C style string. (null terminated strings). Doesn't suffer the overheads of the memmove implementation in which the worst case scenario (a string containing all junk characters) is approx. N^2 / …

Software Development c
Member Avatar for Ancient Dragon
0
3K
Member Avatar for TrustyTony

Here little debugged version of my calculator posted earlier in GUI calculator thread. I prepared it after listening that their teacher did more limited calculator in around 150 lines of code with their graphics module. This is 115 lines without empty lines and comment lines [CODE]>>> li=[i for i in …

Software Development gui python
Member Avatar for fonzali
1
2K
Member Avatar for vegaseat

This example calculates timed x, y points of a projectile motion that can be used for plotting or other calculations.

Software Development python
Member Avatar for ddanbe
3
6K
Member Avatar for vegaseat

A Python sort with a helper function to allow for mixed order sort like age descending and weight ascending.

Software Development python
3
495
Member Avatar for emil_ham

This simulator works for: 1. First Come First Serve (FCFS) 2. Round Robin (RROB) 3. Priority (PRIO) 4. Longest Job First (LJF) 5. Shortest Job First (SJF) algorithms. The program is written for gcc linux compiler. In input file a sequence of processes coming to the systems included, where also …

Software Development algorithm c operating-system
Member Avatar for ElGauchoUTn
1
2K
Member Avatar for ddanbe

This has by far no practical use. But as I was used to VS, handling most of the code housekeeping "behind the back", I wanted to try to make a Forms program as minimalistic as possible. Start an Empty project, include a reference to System.Windows.Forms and fill in the code. …

Software Development
Member Avatar for pitic
1
169
Member Avatar for tinstaafl

Here's a simple class for what it's worth that will do simple base85 encoding and decoding. This only works with the required blocks of data and not large data structures or streams, and does no validation of the data. What it does do is encode a block of 4 8-bit …

Software Development c++
Member Avatar for tinstaafl
0
1K
Member Avatar for seanbp

The server only does the basics. TODOs: The header method needs expanding. The file send method can't handle too large files. Maybe write custom buffer class since some buffering is done. Keep cache of recent files.

Software Development client-server java web-server
Member Avatar for JamesCherrill
0
1K
Member Avatar for vegaseat

Just another loan calculation, this time using a handy function in Python module numpy.

Software Development python
Member Avatar for HiHe
3
4K
Member Avatar for vegaseat

Starting with Python 3.3 you now have access to a high resolution time counter (nanoseconds and better).

Software Development python
Member Avatar for vegaseat
6
4K
Member Avatar for Gribouillis

You can teach your linux system that executable python files must be executed with /usr/bin/python. This allows you to write python scripts without the shebang line [icode]#!/usr/bin/env python[/icode]. This snippet shows you how to do it !

Software Development python
Member Avatar for Gribouillis
0
1K
Member Avatar for vegaseat

Python module turtle makes it simple to draw graphics art similar to art done by the Logo language.

Software Development python
1
408
Member Avatar for vegaseat

Using Python module turtle to draw a Koch snow fractal.

Software Development python
Member Avatar for TheCodeCrimson
2
303
Member Avatar for slate

The most efficient static sieve generator in python I have seen so far. Returns the list of primes, that are not greater than n.

Software Development python
Member Avatar for vegaseat
1
496
Member Avatar for ddanbe

Yes, I know Fibonacci(=sun of a good man) again. Most famous for his series, but who among you all, know that he was the man who introduced to the Western world, the Arabic numeral system(including zero) in 1202 A.D.? The Italian merchands of those days adored it. It was far …

Software Development c#
Member Avatar for Triryche
2
580
Member Avatar for ddanbe

The luxuries we now have in the amount of pixels on a screen to draw some amazing graphs with, were lacking in the early days of computing. Most of the time you had to resort to rude printed output. It wasn’t that bad always. Sometimes it was and still is …

Software Development c#
Member Avatar for ddanbe
1
3K
Member Avatar for ddanbe

I wanted to draw a 5 pointed star in C# and here is how I finally did it. I leave it as an exercise (some hints are given in the code) to work out how I did this. It was fun to do (but a bit hard, my trig is …

Software Development
Member Avatar for ddanbe
1
4K
Member Avatar for vegaseat

A simple way to find duplicate words in a text. In this case the text is preprocessed to eliminate punctuation marks and set all words to lower case.

Software Development python
Member Avatar for paddy3118
2
4K
Member Avatar for Assembly Guy

**NOTE** This code won't work at the application level. It directly addresses memory at 0xB8000 which will result in a segfault at the application level. This code must be part of an OS or an application in a not-so-secure operating system like DOS, where applications can directly address any part …

Software Development assembly operating-system
Member Avatar for Assembly Guy
0
461
Member Avatar for Luckychap

Here is simple Digital Clock coded in C++ and compiler used is TurboC. A class DIGIT is designed to draw digits. Follwoing are the details for this class: Consructor: DIDGT(); for default settings DIGITE(int s,int c,int st); for user define settings s -> is size of the digit c -> …

Software Development c++
Member Avatar for irum.nageen.3
-2
15K
Member Avatar for sandeepparekh9

Lets say you have lots of data your listview. Now you want to Group This data According to a Perticular Subitems. For Example: Suppose i have some books data in my ListView. this listview items contains Author name and Books Title. And there are 2000 Books in list view. Now …

Software Development listview vb.net
Member Avatar for dragonfly67
1
1K
Member Avatar for lxXTaCoXxl

The snippet provided will cover the basics of an on screen keyboard; the only things it doesn't have are numbers, symbols, and extra keys. This will give you the fundementals to build off of. It's written using Microsoft's XNA Framework, however it should be fairly simple to port over to …

Software Development
Member Avatar for lxXTaCoXxl
0
267
Member Avatar for blamp

I have add the two functions the add and subtract I have to now add the multiply and divsion functions can someone help

Software Development c++
Member Avatar for irum.nageen.3
-1
475
Member Avatar for vegaseat

In Las Vegas random numbers move billions of Dollars in and out of gamblers' pockets. For the mildly inquisitive here is a test of three simple generators.

Software Development c
Member Avatar for rubberman
1
6K

The End.