199,113 Archived Topics
Remove Filter ![]() | |
You can alternately show one of two lines drawn on the Tkinter canvas by simply moving them on and off the canvas screen. This beats a cumbersome create and delete cycle. | |
This python 2.7 snippet adds a thin layer of sugar on the itertools module's api, allowing many of its functions to be used as decorators and adding some new functions. Enjoy ! | |
There is always room for optimizing primelist functions. Here is an assortment timed with Python module timeit ... | |
Below you'll find a small program. The challenge is to predict the output of the program, then explain why it gave the output it did. using System; using System.Collections.Generic; namespace Sample { class Program { static void Main(string[] args) { MyStruct a; a.a = 1; a.b = 2; Dictionary<MyStruct, int> … | |
![]() | Hi I'm trying to learn how to create a random page using `rand() function` but also using the `$num` to `switch` each page. Is there a way to click a button? I only used the `Refresh Button` on Firefox. Plus it's not really display the data but only page name … ![]() |
Below is a documented code example showing how to use the [MySQL functions](http://php.net/manual/en/book.mysql.php) to connect and query your database (and check for errors). Please note that using the MySQL extension is **NOT RECOMMENDED**. This extension is no longer maintained and will be deprecated soon. If you want your scripts to … | |
Hi folks. I have a strange thing happening here. I have a loop where counter gets incrememnted by 0.1 starting from 0 and up to 1. In each iterration I use the counter in an expression with modulo operator. I get incorrect result when the counter has values of 0.8 … | |
Just a few more explorations using a Python class to mimic a C Structure or Pascal Record. Loading the record from a csv type data file, displaying the data and sorting and searching the data in various ways. | |
Hi all! This is a simple piece of code that I wrote about a year ago, in response to a question on Daniweb. I decided to infuse it with some C++11 magic, which led to a pretty sweet code snippet, full of neat little techniques you might want to use, … | |
When working whith large data files, it may be desirable to output a sequence of bytes by large chunks. This snippet defines a file adapter class to handle this transparently. Writing bytes to an ChunkedOutputFile will automatically write the underlying file object by fixed length chunks. | |
Hi! This is my submission for code snippet contest. I also posted this code to help other members on how they can use compact & repair their MS Access Database within Visual Basic 6.0. You also need to add Microsoft Jet and Replication 2.6 in your project reference. To use, … | |
This python 2 code snippet uses unicode chess symbols and box drawings symbols to display a chessboard in a terminal. With a terminal profile having a monospace font of size 20 or more, it looks quite usable to play chess. | |
This code demonstrates how to add controls to a form at run time. The number of rows and columns, the spacing between the controls and the size of the controls are all determined by Consts, but this could easily be changed so that the parameters are user entered. My example … | |
![]() | Hi I am trying to understand how to write a **If and Else** statement correctly regarding **sale tax or tax exemptions** on certain items for example fruits. For example: Here is a demo check out: * QTY--items - Price - Total * 6 ***apple*** - $0.89 (each) = $5.34 * … |
[code] #include <iostream> int main() { std::cout << "Merry Christmas Everyone!"; return 0; }[/code] | |
Netbeans is a free, open source IDE for developing software in Java. It's been around for almost 15 years, having gotten its start around the time Java began. Version 7.0 is about to be released, and I got my hands on the Beta release of this new version. In the … | |
please help me with the code behind file..as i am really confused...otherwise give me some tips to start doing the code | |
You can access the sound chip to play midi voices using winmm.lib, or in case of Dev C++ the libwinmm.a library. There are 128 midi voices to pick from, anything from the Acoustic Grand Piano = 0 to the Gunshot = 127. | |
I have prepared an example of login page which displays a form with inputs for username and password and compares submited values with records in database. If match is found the user is redirected to another page, if not error message is displayed. This example is heavy commented. Hope it … | |
Dig up this for discussion thread request and some Googling. By little experiment found the different forms for sending message commands. Could no send in Python3 the code of program itself so only simple test "Hello". Sorry that subject is left incorrectly refering program name. | |
I thought to post some not quite so trivial as it looks quiz for Python, to test if your brain has Python installed OK ;) Try to figure out what interpreter answers (#? lines), then check with your Python interpreter of choice: [CODE]>>> a = list(range(10)) >>> a[1:1] #? >>> … | |
This past Summer, Microsoft announced the beta of a new product called WebMatrix. Two weeks ago, the third beta came out. But before I talk about it, I have to ask: Is this a new product? Or am I having déjà vu?[ATTACH]18093[/ATTACH]WebMatrix (one word) is, in fact, a brand new … | |
Continued fraction expansion is a simple way to approximate common trigonometry functions to a relatively high precision. In this example we only look at sin and cosine. The results compare well with the results of high precision packages like SymPy. The Python module decimal is used to achieve the high … | |
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. [COLOR="Red"][B]A brief on problem:[/B][/COLOR] Lets take example problem for simplicity: - I have a GSM network with a cell in it. - Cell's coverage … | |
You need the Python tkSnack module to play notes of a given frequency and duration on your external sound system (attached to the PC's sound card). The code snippet gives just a tiny hint about the capabilities of tkSnack. It works with Tkinter, normally part of the Python installation. The … | |
Crypting with xor allows one to write one function that can encrypt and decrypt a file. In this example a text file is used, but it could be an image file as well. Once you have created the encrypted file you simply send it through the same function again to … | |
The past few days I've posted some sorting routines customized to the tasks they were required to solve. Since I have a bunch of different sorting routines already coded, I decided to post them. Please note that some of these sorts are fast, but not a single one is as … | |
Generating permutations of a sequence is a problem that is commonly asked. It's fairly easy to do if you know how many items will be used beforehand, but a generic method to do so would be better. The snippet will do a lazy generation of the permutations (the next one … | |
Hello, I have been working on a php/xml/ajax chat program which requires no database for the last few days and was wondering if anyone could test it out for me. It has a few bugs that I would love to have someone help me fix (I am running out of … | |
When I was studying computer programming in college many years ago, I didn't imagine that our work could impact lives, particularly in a negative way. We've heard reports (mostly true) of death, dying, and destruction as a result of software problems, such as the time a plane flew right into … | |
Hi, Can anyone help me finding an application which can read listbox values of any other window on screen and save the list items either to clipboard or some text file, etc. This may be done by getting the handle of the window/listbox and then reading the values, etc. I … | |
helloooo, Actually, i want to know something. please read this code... [CODE]using System; using System.Collections.Generic; using System.Text; namespace temp { class Program { static void Main(string[] args) { Int16 i = Int16.MaxValue; Console.WriteLine("Simple: " + (i )); unchecked { Console.WriteLine("Unchecked: " + (i + 1)); } checked { try { … | |
This is a snippet demonstrating how to create a new local Windows account, and have it show up in the Users section of the Control Panel. You will need to reference the System.DirectoryServices.AccountManagement Namespace | |
This handy function turns file into stream of words stripped of punctuation, whitespace and digits, but does not split for example we'd to two words. If you want that you can further process yielded words or change the definition. | |
This seems to be coming up in a LOT of posts at the moment so i figured i would put it into a handy code snippet to save us keep typing it. To access controls on a form you need to have a reference to the current instance of that … | |
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 System.CodeDom.Compiler … | |
[ATTACH=RIGHT]16267[/ATTACH]Indie game developer Jeff Vogel (head of Spiderweb Soft.) wrote a thoughtful [URL="http://jeff-vogel.blogspot.com/2010/07/sometimes-its-ok-to-steal-my-games.html"]piece[/URL] on piracy on Wednesday, for his blog, [URL="http://jeff-vogel.blogspot.com/"]The Bottom Feeder[/URL]. As an industry veteran and most important of all, human, he explains why piracy isn't always a bad thing, and can often be downright justifiable given the … | |
I just wanted to demonstrate a quick point regarding Constructors & inheritance. Look at these two classes and think about what you might expect to see after the main method has run. Notice that ClassB is a subclass (inherits from) of ClassA. So, what do we expect the output to … | |
I had been working on this program for a while. It was inspired by the slowness of Windows' search feature. I made it so I could simply look for files to see if/where they existed quickly. I eventually added in the feature to delete files. It was no major extension … | |
Rapid Application Development has come a long way since the early days of Delphi and Visual Basic in the mid 1990s. I remember those days well, as I immersed myself in Pascal development with the original Delphi back in 1995 and even wrote a couple of books about it. Delphi … | |
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. | |
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 … | |
![]() | I don't know if this is helpful for moderators but I've put together a code formatter in dotnet which automatically beautifies someone's code. Numerous times you will see newbies posting without code tags. Now the moderators can easily quote the post so the indentation is preserved, but sometimes the posters … ![]() |
In answer to a coworker's question today about memory management today, I wrote the following code. It's an implementation of the gets function that accepts an infinite length string (bounded only by the heap) and [i]does not[/i] force the caller to free the resulting pointer. I figure that it's a … | |
c program to implement a stack using two queue | |
[QUOTE]This discussion has been moved from [url]http://www.daniweb.com/forums/thread284115.html[/url]. Check there for the beginning.[/QUOTE] = = = = = = = = = = = = = = = = = = = = Actually neither approach is wrong. The original code does not store prime numbers but does correctly identify all … | |
The Python module 'tarfile' is more flexible then it's counterpart 'zipfile'. It allows you to simply archive files without compression, or use the gzip format of compression, or the super compression format bzip2. Here is code to show you the use of the module. | |
I have recently started to write my own tiny little electronic-book. This e-book is not about teaching C++ from ground up, but it is a collection of C++ pieces that I have learnt during these past few years that I want to share with everyone. I call this e-book "[B][I]C++: … | |
A demo of the Tkinter listbox widget that shows you how to create the listbox, make it scrollable, position it within a grid, load it with data from a file, select a line of data with the mouse and display it. Also, sort the lines, add a line, delete a … | |
I am trying to change the array in this program from a static array into a dynamic array. I'm totally lost on this one and could use a little help. There are a few other problems in the program, but the only thing I'm worried about right now is getting … |
The End.