1,916 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for mrnutty

Its a typical implementation of mergesort algorithm. It runs in a stable time of O(n*log(n) ). Just thought, I would add it to the library. Its been tested, although not very throughly, so if any bugs are found, just post it here, so others can be aware of them. Its …

Software Development algorithm c++
Member Avatar for Rashakil Fol
0
885
Member Avatar for William Hemsworth

A small game of pong I put together in about half an hour :) Enjoy.

Software Development c++
Member Avatar for William Hemsworth
2
7K
Member Avatar for vegaseat

Python programming can have its lighter moments. Here we use one of those moments to draw an optical illusion using the Tkinter canvas to draw a rectangle, some lines and circles.

Software Development python tkinter
2
726
Member Avatar for Beat_Slayer

ITunes Library Persistent ID Editor. Sample usage: [CODE]fxml = 'iTunes Music Library.xml' # path to xml file fitl = 'iTunes Library.itl' # path to itl file itk = ITunesLibKeys(fxml, fitl) print itk.file_xml # prints path to xml file print itk.file_itl # prints path to itl file print itk.xml_key # prints …

Software Development iphone python streaming-service
0
1K
Member Avatar for vegaseat

Do I have to spell it out for you? This short C code will do just that. It will spell out an integer number in English words. The banks do that on large checks, and it would be nice to get one of those every now and then.

Software Development c
Member Avatar for soulcandra44
1
527
Member Avatar for Dave Sinkula

This code uses a structure to map a letter to an equivalent representation of Morse code. It simply loops through either a string to encode or decode looking for text to substitute with a replacement string or character. Output is presented to the stdout.

Software Development c
Member Avatar for Quagmire232
0
377
Member Avatar for jbronen

Hey, I'm writing a program that takes files and renames them to include a timestamp of the current time on them in c++. I'm pretty new to c++ (and programming in general) and any help or advice would be greatly appreciated. So far I have this: When I compile it …

Software Development c
Member Avatar for jbronen
0
845
Member Avatar for vegaseat

The code is shamefully short, but here it is. Now you can listen to the many sound files in wave (.wav) format and boing, chirp, chime, bark, booh, laugh and mooh at the people around you.

Software Development python
Member Avatar for jbronen
3
1K
Member Avatar for TrustyTony

Here is my practise with [URL="http://www.boggled.org/"]boggle [/URL]letter square non-overlapping word finder after some drastic debugging and cleaning. I think it is reasonable speed also. Comments wellcome.

Software Development gaming python
Member Avatar for TrustyTony
0
1K
Member Avatar for Lusiphur

As suggested by Duki in [URL="http://www.daniweb.com/forums/thread298488.html"]this thread[/URL] I figured I'd compile all the workable examples and explanations here towards the question of "Why do we use get/ set to change properties?" [QUOTE=pritesh2010]Properties provide the opportunity to protect a field in a class by reading and writing to it through the …

Software Development data-protection data-structure
2
504
Member Avatar for saqib_604

Aslam o Alikum to all, here is my code to get and change the attributes of a txt file. I want to change the hidden attribute of file. In this code, when i get attribute of file, the number 20 (100000) is returned in cx. I changed this number to …

Software Development assembly
Member Avatar for muslimgirl
0
315
Member Avatar for Tech B

This bot has some common functions, along with some not so common. I've been using this code to text my wife from work when my phone dies. Requirements: [LIST] [*]Gmail account (for texting) [*]xgoogle (for lang translation) [/LIST] I know it is messy, and the variables are named poorly; sorry. …

Software Development python
0
482
Member Avatar for Dingbats

Hello Everyone, my first post - so please don't shoot me if it goes wrong! I'd been looking for this for some time now and have seen a number of related queries but no solutions. I cannot take credit for the whole code here, but I did adapt it to …

Software Development c++
0
625
Member Avatar for Black Magic

A simple function that converts alphabetic values into their respective lowercase value.

Software Development pascal
Member Avatar for TrustyTony
0
235
Member Avatar for mrnutty

This is a simple demonstration of meta programming. It shows the idea of meta programming. It basically calculates the factorial of a number before runtime. When I first saw the concept of meta programming, it blew my mind so badly. I was so surprised that one could do this. Its …

Software Development c++
Member Avatar for griswolf
2
410
Member Avatar for G_Waddell

Hi, Ever had an application that you want to store [B][U]user specific[/U][/B] settings on? e.g. login name or Form background colours, User specifc DSN connections etc. So the next time they run the app the information is there for them? This can be achieved in VB.net with just a few …

Software Development app-store vb.net
6
2K
Member Avatar for jcao219

This is not my code! Taken from [URL="http://stackoverflow.com/questions/3230978/code-golf-four-is-magic/3231355#3231355"]this SO post[/URL]. You can use this to get the number of letters in the English representation of an integer, from 0 to 99. So for example 5 (five) is [icode]len("five")[/icode] which is 4.

Software Development python
Member Avatar for TrustyTony
0
176
Member Avatar for TrustyTony

Here is my try of changing integers to English written numbers. Here corrected version 3 check: [CODE]from __future__ import print_function import random,sys if sys.version_info[0]==3: raw_input=input to_19 = ["zero", "one","two","three","four","five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" ] tens = ["","","twenty", "thirty", "forty", "fifty", …

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

A simple program to count the words, lines and sentences contained in a text file. The assumptions are made that words are separated by whitespaces, and sentences end with a period, question mark or exclamation mark.

Software Development python
Member Avatar for snippsat
2
2K
Member Avatar for TrustyTony

As I was student, the bracketed plurals were absolute 'NO, NO'. With this simple function you can cleanly avoid putting bracket plural(s) after your numbers. If the number deciding singular/plural should not be automatically included, you can make version with [icode]str(n)+' '+[/icode] eliminated. If you want to put automatically space …

Software Development apple python
Member Avatar for TrustyTony
0
771
Member Avatar for appunu

I new to python . I created the one console application in python for that i used two data bases IBM_DBI and POSTGRESQL8.4. I converted the console application into windows exe for that i used py2exe. It is created, while running the exe it coudn't connect with DB2 data base …

Software Development python
Member Avatar for TrustyTony
0
995
Member Avatar for Rajnesh

start Server first start Client by passing the ipaddress of the server eg; java Client 10.0.1.15 if an error pops up change the port in both Client and Server programs

Software Development client-server java socket-programming
Member Avatar for jt86442
0
3K
Member Avatar for TrustyTony

See the link ([URL="http://norvig.com/sudoku.html"]Solve Every Sudoku Puzzle[/URL] for fine description of logic of the code) I attach the top95.txt file of tough problems and the sudoku claimed toughest of all time by Finnish mathematician Arto Inkala ([URL="http://www.kristanix.com/sudokuepic/worlds-hardest-sudoku.php"]The Worlds Hardest Sudoku Puzzle[/URL]) Solving this was piece of cake for the code, …

Software Development puzzle python
Member Avatar for TrustyTony
0
1K
Member Avatar for FlamingClaw

The arguments are passed by value and by reference

Software Development pascal
Member Avatar for mahmoud85
1
198
Member Avatar for nikelin

Simple package loader to load all packages contents from directory-based or from JAR-compressed class path entry.

Software Development java
Member Avatar for NormR1
0
416
Member Avatar for Fungus1487

This is a very brief overview of how to achieve an ON-THE-FLY creation of an appointment in the clients outlook calendar. This will not force the user to add it to there calendar but gives them the option to add it automated. Using the older .vcs file extension for outlook …

Member Avatar for elf123
0
212
Member Avatar for nikelin

Helps to filter objects by interfaces and annotations their contains/implements with respect to parental relations.

Software Development java
0
484
Member Avatar for TrustyTony

The code from my answer to thread: [url]http://www.daniweb.com/forums/thread292949.html[/url] Any field names with any same separator separating the values. This is straight text file reading routine, see the original thread for csv module based code. sample.dat: [CODE]id; name; email; homeaddress 123; gishi; gishi@mymail.com; 456 happy st. 345; tony; tony.veijalainen@somewhere.com; Espoo Finland …

Software Development python
Member Avatar for TrustyTony
0
1K
Member Avatar for daviddan2010

First i'd like to say that this is for testing only. If you try to use this program for any illegal practices what so ever... you will be responsable for your actions and i will be responsable for nothing. you would need some kind of security code generator to illegally …

Software Development python
Member Avatar for daviddan2010
0
2K
Member Avatar for sahasrara

Hi ladies and gentelmen Merge sort program has 3 function . 1-func that sorts first array ascending 2-func that sorts other array descending 3-func that merges these arrays together I wrote it by Borland 5.02 . Good Luck!

Software Development c++
Member Avatar for sandros
0
167
Member Avatar for vegaseat

The wxPython GUI toolkit makes a very nice plotting component/widget available. You can select line or marker plotting, or a combination of both. All you have to supply is a list of x,y point tuples. Other features include zooming and printing.

Software Development gui python
Member Avatar for aernie
1
2K
Member Avatar for TrustyTony

As I told before here is second implementation of one word anagrams, which prepares lookup table for all available words, if it is not generated and afterwards uses it for fast lookup. The implementation of lookup table generation is quite unoptimized, but it is only done once per vocabulary. If …

Software Development python
Member Avatar for TrustyTony
0
810
Member Avatar for trpsjt2008

Create Panel And ToolStrip in panel Panel Property [CODE] Dock = Dock At Left Or Right Or Buttom Or Top High = 40 Backgroundcolor = Black [/CODE] ToolStrip Property [CODE]Dock = None RenderMode = System GripStyle = Hidden Background = Transparent ImageScalingSize = 32,32[/CODE] U Can Extend any side by …

Software Development vb.net
0
144
Member Avatar for angraca

I am new to python and this is my first program. The program factorize a number given by a user. It also makes a list of all the primenumbers, that it finds and stores them in a file. Is there anybody who can see a way that I can make …

Software Development python
Member Avatar for vegaseat
0
940
Member Avatar for Tom Gunn

The forum is buzzing with questions about tokenizing a C++ string. This is a short function that does it and returns a vector of the tokens. As an option, the delimiter string can represent either a multichar delimiter or a collection of single char delimiters: [code] // multichar delimiter == …

Software Development c c# c++
Member Avatar for daviddoria
1
734
Member Avatar for TrustyTony

I made this program during forum discussion for accessing configuration relative to module directory, not main program's position (which can be accessed by sys.argv[0]'s directoryname). As the thread is closed I post my proves as code snippet.

Software Development file-system microsoft-access python
0
1K
Member Avatar for harshchandra

This program maintains a employee's record using Doubly linked list.It was a weekly project submission by me for the course CI 031 .Invloves simple graphics and a login menu where i had used file handling to maintain a record of 3 user's name and their password .So before running the …

Software Development c ide linked-list
Member Avatar for ylnsagar
0
349
Member Avatar for jcao219

Interesting right? If you read [URL="http://www.daniweb.com/forums/post1252636.html"]this[/URL] amazing tutorial by lionaneesh, you will understand why I posted this brain-boggling code.

Software Development python
Member Avatar for jcao219
0
161
Member Avatar for NathanOliver

Hey all I have seen a lot of stuff about palindrome checkers so I thought I would write one that works for STL containers as well as arrays. it accepts a bidirectional iterator to the first element and an bidirectional iterator to 1 after the last element. Included is a …

Software Development c++ mathematics
Member Avatar for NathanOliver
3
330
Member Avatar for Duki

I've spent the last couple of days researching how to connect to a database server and modify the data in that server. I was able to find a lot of information on how to Read from a database, but I found very little material to assist with Writing to a …

Software Development c# sql
Member Avatar for Duki
0
823
Member Avatar for masterofpuppets

Simple functions for binary-to-decimal and decimal-to-binary conversion :)

Software Development python
Member Avatar for TrustyTony
0
798
Member Avatar for vegaseat

Let Python do the work for you and figure out the roman numerals for a given integer. I have to ask you to keep the integer values somewhat reasonably low (from 1 to 4999), since roman numerals from 5000 on use characters with an overline and most PCs don't have …

Software Development python
Member Avatar for eljakim
0
3K
Member Avatar for rohit83.ken

hello frnd this a c program that removes c c++ style comments

Software Development c c++
Member Avatar for Swathyy
0
2K
Member Avatar for avarionist

its a wrapper class. it combines stl stack class with a custom user class. i made it so that i could rename push and pop if i wanted or size and top :) best of all it combines stack and classes :) something i made to see if i could …

Software Development c++
Member Avatar for avarionist
0
123
Member Avatar for NathanOliver

Hey All This code is for matching a string with a wildcard in it to another string. If you want to have a Astrix in the first string be counted as a character and not as a wildcard put a \ in front of it. I have tested it for …

Software Development c++
Member Avatar for NathanOliver
4
488
Member Avatar for TrustyTony

Here is solution number one for one word anagrams, I gave in discussion thread, response time in my humble Athlon PC under 70 ms. List of words is from original posting of the discussion thread. [url]http://www.daniweb.com/forums/post1206616.html#post1206616[/url] This version does not give we'd for input dew. Next time I give final …

Software Development python
Member Avatar for TrustyTony
0
1K
Member Avatar for TrustyTony

I used this pattern few times to answer a thread and thought to post it as snippet.

Software Development hard-drive python
Member Avatar for TrustyTony
1
2K
Member Avatar for TrustyTony

Do you know that there is clean way of doing what C-language ternary operator ? does in Python's recent versions. It is if with special twist. The syntax is: [CODE]'The value if true' if <condition> else 'Value when false'[/CODE] Values can be any type. You can put this structure to …

Software Development c python
0
1K
Member Avatar for anuragcoder

Hi guys, Here's my project finally. It's name is C.L.O.S.E - The Command Line Open Source Editor Please review and comment. Mention errors if any, Also, for this code to work. Please download open.cpp, find.cpp, new.cpp, append.cpp, compile them and place all of them including the main source in a …

Software Development c c# c++ open-source
Member Avatar for anuragcoder
0
327
Member Avatar for Dave Sinkula

Many times [inlinecode]strtok[/inlinecode] is recommended for parsing a string; I don't care for [inlinecode]strtok[/inlinecode]. Why? [list][*]It modifies the incoming string, so it cannot be used with string literals or other constant strings. [*]The identity of the delimiting character is lost. [*]It uses a static buffer while parsing, so it's not …

Software Development c
Member Avatar for Aia
0
1K

The End.