2,322 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for ~s.o.s~

Hello here i am posting the non recursive or no recursion implementation of outputting [B]Permutations of a string [/B]as compared to the recursive implementations previously posted. Any feedback, constructive criticism or comments are most welcome.

Member Avatar for samir1
0
2K
Member Avatar for Bench

The C++ [i]string[/i] type can be converted to a [b]const[/b] null-terminated string using [icode].c_str()[/icode] for interoperability with legacy C code. However, this poses a potential problem when mixing [i]std::string[/i] with functions designed to mutate a string in-place. a const_cast to get around this issue results in undefined behaviour, since the …

0
966
Member Avatar for mrnutty

We are all tired of from our daily lives. So I suggest to sit back and play this game. I present here a hangman game( text version ) for your enjoyment. There might be some bugs as I haven't throughly tested it, so sorry if you find it( I'm sure …

Member Avatar for mrnutty
1
290
Member Avatar for Topzturvins07

I used this code to store convert pictures to "[COLOR="Red"]binary[/COLOR]" inoreder to save in database but it stores only one picture from two pictureboxes. let someone show me how, you can convert pictuers in two seperate [COLOR="Green"][B]'picturebox ("picturebox1 and Picturebox2")'[/B][/COLOR] using the function in the code snippet on something similar. …

Member Avatar for deleodesanmi
1
345
Member Avatar for banders7

A program that handles either piped input (command/prog | your_prog) or file redirected (your_prog < file_name) input. Determine whether such input exists before issuing a stdin read so that the program does not go into a "waiting for input" state. Written in/for the XP environment.

Member Avatar for jivemaster
0
641
Member Avatar for Nick Evan

[B]Background[/B] I was looking for a simple control in wxWidgets which I could use to plot out [i]some value[/i] against time, but I found that apparently I was the only one that needed that kind of graph. (so I don't know why I'm posting it... but anyway). I decided to …

Member Avatar for callmegood
0
919
Member Avatar for ben_

This function will take a string and convert it into a folder/file friendly name. I use it in conjunction with url rewriting, deriving the filename from the title of an article.

Member Avatar for Ravenheart
0
136
Member Avatar for ReDuX

If you have done a PHP based website, chances are you have dynamic content called by variables and so on. As many people use a main page (index.php) and use code within that page to dictate what content is displayed, either with if or switches or whatever. Thing is, Google …

Member Avatar for wiltekg
0
121
Member Avatar for subcom

[B]Introduction[/B] In this sample,It shows how to move files to another folder. [B]Background[/B] It can be used in winForm applications.

Member Avatar for logiccool
0
3K
Member Avatar for ddanbe
Member Avatar for ddanbe
2
999
Member Avatar for miteigi-san

NOTE: ~this code is in c++ ~you need not change anything in the code ~the commented lines are there just in case you want to see how the program works in real time - simply uncomment them and run the program, these commented lines are not necessary for the program …

Member Avatar for dusktreader
0
380
Member Avatar for Gribouillis

This snippet defines a class OptCmd which adds line and options parsing capabilities to the python standard lib's cmd.Cmd class. It allows you to quickly write an extensible command line interpreter. To use this module, you will need [url=http://www.daniweb.com/code/snippet234768.html]this other code snippet[/url], saved as a module named 'argv.py'. Enjoy the …

1
1K
Member Avatar for Gribouillis

Some time ago, I was writing a small command line interpreter, with the help of [url=http://docs.python.org/library/cmd.html#module-cmd]the standard module cmd[/url] which offers minimal support for such tasks, and I had the problem that this module doesn't have a function to parse a command line to produce a list argv which can …

Member Avatar for Gribouillis
1
875
Member Avatar for beanonymous

OK here is a piece of code I've been working on that actually logs you in and returns what ever Curl sees except i have no idea how to make Curl function correctly with websites that require cookie authentication correctly, can anyone help? =/

0
187
Member Avatar for linksprocket

Hope some one can assist me Below is my code which works fine. I need to be able to select more than one of the options at the same time. The code at the moment will only select one option rather than all my options. Any advice would be great.

Member Avatar for Hangfire
0
185
Member Avatar for NotNull
Member Avatar for NotNull
-1
419
Member Avatar for tux4life

Intended as a replacement for [URL="http://www.daniweb.com/code/snippet217322.html"]this[/URL] old crap of myself ;) Note: no error checking provided, if you need it, then you can easily implement it yourself :)

0
161
Member Avatar for akonful

I am developing a code to find the occurence of digits in a string. I need help. When it compiles I get the error: cannot find symbol variable countDigits

Member Avatar for apegram
0
191
Member Avatar for vegaseat

Wallpaper or tile images are small images that can be spread across a background repetitively. A common practice on web pages. The surface created with wx.PaintDC() can be used for this effect and still allows other widgets to be put on top of the wallpaper. The small tile image is …

Member Avatar for vegaseat
1
984
Member Avatar for SeanBlack0000

In this snippet of code, I am trying to check the customers request against the volume remaining in the tank. If the request is greater, I need to instruct the customer to move to the next tank. But I am having problems. The tank is set to store 100 gallons. …

Member Avatar for WaltP
0
473
Member Avatar for pysup

Hi, The code below will check if a particular exe is running in windows, return the Process ID and force kill the process. If anybody has an easier way to do it please feel free to comment :)

Member Avatar for Tech B
0
229
Member Avatar for vegaseat

A lotto simulator with a twist, you pick the winning numbers and the computer buys the lotto tickets. Anyway, the computer at least generates the tickets and checks how many of them would match the winning numbers you selected. Let's assume you would be the state lotto commissioner and your …

Member Avatar for lyndon enero
0
7K
Member Avatar for sohil.shivani

Hello sir, I tried with this code it is running well but I am not getting mail in my account with this code, even this code is not giving any error. Is there any problem?? Please help me.

0
490
Member Avatar for naveenreddy61

the code takes each character and stores where and how many times a roman numeral appears and the assess the integer. this is my first code im posting. anything to make the code better is most welcome. roman numeral refers to M=1000 D=500 C=100 L=50 X=10 V=5 I=1 and uses …

Member Avatar for WaltP
0
974
Member Avatar for greenphpcoder

hi i was set the task to increment a number by x every x seconds and i tried to find some [URL="http://www.daniweb.com/code/../techtalkforums/thread68355.html#"]code[/URL] off the net, but found the subject covered very sparsley so for whoevers benefit ill post the code here hope it helps [URL]http://www.daniweb.com/code/../techtalkforums/dani-images/smilies/fiyellow/icon_smile.gif[/URL] Thanks Nicholas

Member Avatar for sharasyn
0
906
Member Avatar for runningbull

The password salt (the byte array) can be any random collection of numbers - so long as it matches in both the encrypt and decrypt methods. Also - the same password key needs to be used in both encryption and decryption.

0
356
Member Avatar for fsn812

A very simple PHP/Javascript snippet to detect the resolution of a user's monitor and create a table using that resolution to best fit within the user's browser (to avoid scrolling). Note: This is a PHP script which includes Javascript

Member Avatar for almostbob
0
543
Member Avatar for Ancient Dragon

The idea for this came from another thread in the C++ forum that wanted to duplicate the _getdelim() function that is supported by GNU compilers g++. I made one major change in that this version does not allocate new memory every time it is called, which is grossly inefficient. Instead, …

Member Avatar for Ancient Dragon
2
318
Member Avatar for justice igwe

here is how the code works. small but powerfull. this code will unblock the command prompt of any system that has been disabled. Just open your NOTEPAD, then type in COMMAND.COM .. then save the file using the extension " .bat " example igwe.bat then run the program .. enjoy …

Member Avatar for Ancient Dragon
-5
358
Member Avatar for Gribouillis

This snippet provides 2 functions to create in memory a gziped archive of a sequence of files and directories, and to extract files from this archive. These functions are similar in effect to the linux commands [icode]tar czf[/icode] and [icode]tar xzf[/icode] but instead of writing an archive file on disk, …

2
4K
Member Avatar for hondros

This code should be able to get you started to design 2-D scrolling games, like Mario. I spent a few hours trying to figure this out, and firgured I'd put up my efforts. I think there might be a better way to do it, but this should help you get …

1
1K
Member Avatar for avirag

This is a snippet that takes a min value, max value and how many random numbers from the user then, after it checks to make sure it's not already in the list, adds the new random number to a List.. I hope it helps you..... :)

Member Avatar for apegram
0
235
Member Avatar for Diamonddrake

I needed a way to buffer into memory an entire wav sound file to be played back a moments notice, as if for a game. So i created this class, simple instantiate it by passing to it a string and a bool indicating if you should buffer it to memory. …

0
769
Member Avatar for gmahlert

The program uses an implementation of the Sieve of Eratosthenes to generate a small list of prime numbers which is subsequently used for direct comparison to find the prime factors for any whole number up to and including 478939. This limitation is due to the primitive method used to generate …

Member Avatar for GeniusDex
0
311
Member Avatar for Banderson

Hi, This will show you how to create a login form using swing. Please be aware that this form does not connect to anything. ( eg. A URL or a database) This is just a little advanced example of one of the many things you can do in swing. A …

Member Avatar for masijade
1
2K
Member Avatar for vegaseat

Convert a decimal (denary) integer to a binary string. An exercise in do ... while and while loops.

Member Avatar for arun26
2
2K
Member Avatar for DGXI

i have created lines in graphwin but i did it the long way is there a simpler way using loops ? cheers

Member Avatar for vegaseat
0
183
Member Avatar for mrnutty

Some background. We all used the string class, but some of you might not know that string is just a typedef of basic_string. In fact here is the typedef you might find when looking in the XString library. [code] typedef basic_string<char, char_traits<char>, allocator<char> > string; [/code] This code snippet shows …

Member Avatar for Dave Sinkula
2
3K
Member Avatar for landonmkelsey

This code defines a new operator new in C++ such that the memory returned is in the shared memory segment rather on the heap. This code exists to prove a point. "Objectifying" shared memory. One can not overload the new operator but one can overload operator new. Reference the C++ …

1
427
Member Avatar for sandorlev

Hello, I've been working on this self-made database. What do you think about it? What features should I create for it? I'd also like to get help in a select method, because I don't have the foggiest idea how it could be done. And what about making it a database …

0
243
Member Avatar for DealthRune

This one is a messaging system! Made it myself, works great! Hopes you like :)

Member Avatar for jamied_uk
1
259
Member Avatar for xavier666

The program generates a calendar for one year. The program only asks for the day on which 1st January falls from user. Notes : [LIST] [*]Compiler - Turbo C++ 4.5 [*]Leap year has been considered [*]The only reason for including [icode]conio.h[/icode] is because of [icode]clrscr()[/icode]. If somebody can give me …

Member Avatar for binkiwinki
-3
375
Member Avatar for b3nsoi
Member Avatar for low_coder

this code was written by me for my projects. all it does is increments by 1 the string which is passed to the function. if you have any improvements to my code ill be glad to hear from you ;)

Member Avatar for low_coder
0
726
Member Avatar for axn

need this to change to random colors every .8 secs. compiles ok, but not getting wanted results. cant figure out where i am wrong? i get the applet viewer window with a black square but no color change. Here is the .html file <applet code = ColorChange .class width = …

Member Avatar for cbarton.a
0
158
Member Avatar for RTHANGAVEL

I wrote this code to load the image on mouse click...but it is not displaying as soon as i click the mouse...i need to resize the jframe to make that visible what is the problem with this.......please anybody ans for this....thank u in advance...

Member Avatar for cbarton.a
0
110
Member Avatar for aakaashjois

Hello, Can anyone help me solve the error in this program?? I get the following error: [COLOR="Red"] Exception in thread "main" java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at converter.main(basic_convert.java:20)[/COLOR] The whole program runs properly. The error come after asking if I want …

Member Avatar for aakaashjois
-1
205
Member Avatar for avirag

HI ALL, i am writing this snippet to working with text files, here i explain the basic functionality of read/write operation on text files.....:) Here each method has a single parameter, the file name you wish to work with.

Member Avatar for jonsca
1
206
Member Avatar for Diamonddrake

If you drop a picturebox control onto a form and set its SizeMode to zoom you will notice that no matter what you change the padding property to, it won't change the output. The code for drawing the image in zoomed mode doesn't take in account the deflated rectangle it …

0
201
Member Avatar for Dave Sinkula

Several methods of reversing the bits of a byte are presented here. [i]Note that not all of the methods are portable.[/i]

Member Avatar for Dave Sinkula
3
770

The End.