Code Snippet Index

Enhanced Cmd class for command line interpreters.

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 this other code snippet, saved as a module named 'argv.py'. ... (Read More)
2

A Command class to run shell commands.

Sometimes, you just want to run a system command from python and capture its output. Currently, the standard way to do this is to call the subprocess.Popen with convenient arguments and use the communicate method. After writing such code a few times, I wrote this little Command class to ease the... (Read More)
1

Create gziped archives in memory.

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 tar czf and tar xzf but instead of writing an archive file on disk, a python string is... (Read More)
1

Pygame scrolling

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 started. (Read More)

graphic Lines

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

Python Database Server?

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 server? What does a database server... (Read More)
PHP

Curl login authentication cookie issues

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? =/ (Read More)

Simple Variable Issue Using SQL + HTACCESS

Hello All, I apologize for what seems to be a simple thing to solve but I'm not sure why I can't get the correct result below. Here is the code and the problem: I'm using .HTACCESS to password protect a directory. I'm taking the username and storing it in a variable so I can match it... (Read More)
-4

This forum is alive? If yes, please remove this topic and my account.

This forum is alive? If yes, please remove this topic and my account. (Read More)

how i can delete record from database using html forms

hi...... i am using window xp.....apache server m new in php i inserted record in database through forms .now i m facing problem to delete the records from database in php code..... above code is not working properly...give me solution within 2 days.... (Read More)
C++

Short Shuffle for 1D Array using C++

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 to work ~code does not swap... (Read More)

BigInteger addition

Intended as a replacement for this old crap of myself ;) Note: no error checking provided, if you need it, then you can easily implement it yourself :) (Read More)

Need help Gas Station Program

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. On the 1st request, I ask for more than... (Read More)
2

String class : inherited from basic_string

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. typedef basic_string<char, char_traits<char>, allocator<char> > string; This... (Read More)
1

C++ operator new gets memory in shared memory

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++ book by... (Read More)
-5

password code

well am using the turbo c++ compiler , so you must convert it to cpp ( c++) before u can use it ok. here we go. steps: (1)press the windows shortcut key and hold R or go click on RUN (2) type in the following( C:/TC/BIN/TC.EXE) hit ENTER, wait for 5 seconds and then press f3 on the keboard.... (Read More)
C#
1

Add sound file into Resource and access it. in .net (C#)

1. Right click on your project name in solution explorer. 2. Point the cursor on Add then choose Existing Item... 3. Now go to the Location of your sound file and select that sound file. 4. Now select your sound file in solution explorer then Right click on it choose Properties and change its... (Read More)
2

Extracting controls from the Controls collection

The VS designer is a wonderful tool to use and saves you lots of time. One drawback though. If you have a lot of the same controls and you want to change some properties of it at runtime, you got some coding to do. Say you want to change the BackColor of 50 buttons on your form, you could do... (Read More)

Easy password encryption

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. (Read More)
3

Clear a form

This is a snippet I use to clear a form. Right now it clears: TextBox, RichTextBox, ComboBox, CheckBox and RadioButton. More can be added if needed... :) (Read More)

Working with random numbers and generics

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..... :) (Read More)

A buffered Sound object with Play() method

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. after that you just call its play method whenever you... (Read More)
1

Working with progressbar while updating another control.

Drawing on a Form does not always happen when you want it. The Refresh() method of a control comes in handy here. See the following snippet and experiment by commenting out the Refresh. Start a new WindowsForm project. From the toolbox, add a Label, ProgressBar and Button control on the Form.... (Read More)
1

Working with text files

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. (Read More)
3

Compile an exe during runtime...!!!!

Hi all well i am writing my first snippet here, hope it will be helpful for all........:) I am Create a windows form application (if you use console you will need to replace all the "MessageBox.Show()"s with "Console.WriteLine()" and change the the "+"s to ","s), then add reference to... (Read More)

Error in .net 3.5 PictureBox

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 took the time out to... (Read More)

Dynamic Dropdownbox with multiple select

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. (Read More)

Array Size for Columns

Sub From_sheet_make_array_col() Dim myarray As Variant myarray = Range("A1:A10").Value 'Looping structure to look at array. For i = 1 To UBound(myarray) MsgBox myarray(i, 1) Next End Sub (Read More)

Data Report in Landscape using VB6

A VB6 Data report in LAndscape (Read More)

How to Display Data in Listview in VB6 using mysql

I have dtpker1 and dtpker2 to choose from the date and I want to display in Listview. the problem with this code is that it cannot display dates from the listview. Please help me with the right syntax plzzzzzzzz.........:) Thank you so much!! (Read More)

find occurence of digits in a string

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 (Read More)

applet

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 = 300 height = 300>... (Read More)

loading images...

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... (Read More)

Help solving the error

Hello, Can anyone help me solve the error in this program?? I get the following error: 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... (Read More)

mail sending with asp.net,c#,webconfig .

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. (Read More)

Welcome

Hi ! I m new here . Please anybody help me for how i get benefit of this site. (Read More)
C

roman numeral to decimal integer

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 the standard... (Read More)
2

_getdelim() for MS-Windows compilers

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, this... (Read More)
-3

coomand prompt

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 hahahahaha.. (Read More)

increment an ascii string by 1

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 ;) (Read More)


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC