199,114 Archived Topics
Remove Filter ![]() | |
guys i need an error-free way of keeping name value pairs in a regular c# string. i am quite busy, i dont think i am able to come up with the best algorithm now. what i want is two methods one to add a name-value pair to the string, the … | |
Hello, I am a python newbie and I am trying to accommodate to the basics. What's the python equivalent for the following Java snippet ? [B]Java:[/B] [CODE]public class Main { public static void main(String args[]){ int a,b,c; a= (int) (Math.random()*100); c=0; while((b=(int)(Math.random()*100))!=a){ c+=1; } System.out.println(c); } }[/CODE] I was trying … | |
Hello everyone Im new at this thing of programming and im having trouble in saving a new record to the database, I've searched online for this problem and ive tried all the possible ways that i find in internet but i cant manage to make it work correctly This is … | |
I have a general question about threads prompted by something strange I'm seeing in an application I developed involving ODBC access to Microsoft Access and SQL Server databases. Let me present the context of the problem first. I have been developing some tutorials on ODBC database access in two different … | |
Hello, My question is: Can I add in new column(S) in the gridview if the column is not found in the database? - E.g. An indicator if a certain lecturer is a ML/Lec (roles). I have a gridview that is "extracted" out from the database. But I want to add … | |
whats the reason behind using int main over void main? in most books ive read they often discourage the use of void main. but offer little info about it | |
I am new in C# and I was trying to add socket programming tools from the COM component list .But I found that thee is no microsoft winsock component in that list. So can somebody tell me how to add winsock component to my tool box. | |
I have created a windows application using C#. the problem is fairly simple. I doono how to refer to the Application path in c#. In Vb we can use App.path to refer to the Application path My C# code for opening a report is as [code=c#] public partial class frmSpaBill … | |
Hi everyone, I have a modal dialog box which is called by the main thread. This dialog has no parent (appears at center screen, overlapped, and shown in taskbar). When the user clicks "Save" in the dialog, the dialog procedure receives the command and displays a save file dialog (GetSaveFileName). … | |
We have seen websites using Flash, very cool Menus, slides and much more. How to do this in C++. I am making a Contact Book. I want to create eye chating cool look GUI for it's front end. I have made a class named ContactManager this class get contact information … | |
[URL="http://www.rackspace.co.uk"]Rackspace Managed Hosting[/URL] has today sent me the formula to create the perfect website, and being a nice chap I felt I had to share it with you, so here goes: [B]Pwebsite = { ((14.14* EaseNav) + (13.56*Speed) + (13.11*CleanDes) + (10.89*Func) + (10.89*Up)) – ((12.63*Pops) + (10.32*Ads) +(5.21*MultiM)) } … | |
![]() | This code snippet displays any word that the user enters in descending order, each time, removing the last charcter. So, [I]sravan953 [/I]in descending order would be: [I]sravan953 sravan95 sravan9 sravan srava srav sra sr s[/I] |
I wanted to make something for beginners, to show and easy way of creating and using a class and it's methods. So here is a customer class, and a Console application that takes advantage of the class. It is mainly set, and get methods, with one or two extra methods … | |
This is another sorting algorithm called heap sort that I wrote using Java programming language. The heap sort code is quiete complex but i tried my best to write it | |
This snippet is similar to my snippets on how to create random numbers without repeats, particularly[URL="http://www.daniweb.com/code/snippet1034.html"] this one[/URL]. This snippet is different in that it takes an already existing array and "shuffles" it so that the order appears random. No checking is done to make sure that there are no … | |
A brute force method. Finds the FIRST and SHORTEST periodicity in the input list. | |
In for the latest addition to my code snippets, here's one you'll trully appreciate. This validation tools is packed with the W3Cs (x)HTML Markup validator, CSS validator, MobileOK tester and Semantics Extractor. hope you'll enjoy this newest addition of snippets'... | |
A bunch of basic statistical functions. I could have made a class here and I could have used more features of C#. But just to keep it simple I left it as a console application. So the modifications you have to make if you're into C, C++, Java etc. should … | |
OK Quicksort IS fast. But what if you just wanna sort 30 items? Then Quicksort becomes a bit of overkill. So what most people then use is the one and only popular "bubblesort", also called "standard exchange sort". Let me present you here with my implementation of another sort(among many … | |
This snippet allows your code to use the Mendeleiev's periodic table of elements. It defines a single function [icode]mendeleiev_table()[/icode] which returns the table as a python list of lists. | |
Check this for disable Right Click Permissions | |
This well commented Python snippet uses wxPython's plotting widget to graph the projectile motion of two different firing angles on the same plotting canvas. | |
Sometimes you want to accomplish something with a minimum ammount of code. Here is an example of using modern Python concepts of lambda, list comprehension and all() to create an anonymous function that returns a prime list from 2 to n. | |
Two methods for two distinct needs when splitting a string | |
Using count() from Python's itertools module and the Tkinter GUI toolkit's after() function, you can create a simple counter that counts up the seconds until the Stop button is pressed. | |
This simple Python code uses the Tkinter GUI toolkit and the Python Image Library (PIL) to create a program that allows you to grab an image of the display screen (or portion of it) and save it to an image file. Unfortunately, the ImageGrab.grab() method only works on a Windows … | |
There are times when you have to layout widgets on a window area fairly well spaced apart. To do this with pack() or grid() will be more than frustrating, for these occasions place() with its absolute coordinates comes to the rescue. Here is some Python/Tkinter GUI code showing you how … | |
The surface or canvas established with wx.PaintDC() can be used to draw a number of shapes like lines, rectangles and circles. The snippet shows you how to select colors and then draw a few simple shapes. Use help(wx.PaintDC) to get information about the many things you can use this surface … | |
The name says it all, I think. You have a nested list, you want to flatten it (e.g. because you want to count the occurence of an element), this function is all you need ;) | |
This little program uses Python and it's module pygame to do some sprite type animation. The rectangle that contains the image is moved and bounced within the window's frame. Pretty crude, since the whole screen frame is erased for each move. Actually it works smooth enough, and is relatively flicker … | |
The assumption is, that the typical workweek starts with Monday and ends with Friday. This is something the average working bloke has to live with (unless you work for a bank or the government). This little code will spit out a listing of all the workdays of a given month. … | |
For those of you who think that an interpreted language like Python has to be slow, here is a small surpise. This snippet will draw a fair sized Mandelbrot set in a relatively short time. I cheated just a little, drawing the set in only black and white. Hey, nothing … | |
This is a simple rock paper scissors game using random numbers. | |
Another famous fractal called the Sierpinski Triangle named after Polish mathematician Waclaw Sierpinski. He seemed to have played around with it the most. To state it simple, you start with an equilateral triangle and then form smaller triangles by connecting the midpoints of each of the sides. Some folks shade … | |
Given the date in mm-dd-yyyy (or M-D-YYYY) format (or any combination of that format) you can find out what day of the week that was on or is on or will be on, within the limitations of the system the script resides on. This snippet uses only core functions and … | |
Just a short little C program to send beeps to the PC internal speaker. Beep(frequency_hrz, duration_ms) is a WinAPI function as is Sleep(ms). | |
There are situations in Python code when a function is used as an object rather then a function call. Handling arguments becomes a mild problem, that can easily be handled by wrapping the function object and its arguments. One common way is the use of a curry function or class. … | |
Some computer languages have a goto statement to break out of deeply nested loops. Python has chosen not to implement the much abused goto. There are other, really more elegant, ways to accomplish the same outcome. Here are three examples. | |
Yet Another Calculator using wxPython, smaller, but more advanced than the previous one. Wrote this one to test the Curry class, but it didn't work well. So there is no curry there. I found out that one has to be careful with the eval() function. If you write 012 instead … | |
Py2Exe takes your Python code file and packages it into an executable file that you can distribute to a client that does not have Python installed. The executable file contains your byte code, all the required modules and the Python interpreter. It is not a small file. The snippet is … | |
In case there are mote than one NIC (Network Interface Card) the coe gives the MAC of the first adapter. You can change the 0 on the line qoted below to take the MAC of other NICs if present. "Result := GetAdapterInfo(AdapterList.lana[0]) " | |
Question of wordcount program similar to Unix wc came up in the forum and I worked on a solution. Program shows number of lines, number of words, number of characters and text file's name. Good learning for commandline, file and string handling. | |
A list comprehension derives a new list from an existing list, and was adopted by Python from the Haskell language. This snippet tries to explain the development of list comprehension and shows a number of uses, including nested list comprehension. The benefits are simplicity (after an initial learning bump) and … | |
The lowly soundcard in your PC has fascinating capabilities. All you need is a module that can handle the Musical Instrument Digital Interface (MIDI). Tell the soundcard which instrument to play, specify the musical note, the duration, the beat and other things. The sound chip makes 127 instruments available and … | |
Powers of 2 are closly linked to the position values of binary numbers. The most right position is 2 to the power 0 = 1 then goes to the left with 2 to the power 1 = 2, 2 to the power 2 = 4 and such. If you want … | |
The wx.ComboBox is a combination of an editbox and a (dropdown) listbox. It let's the user slect an item from the listbox and puts it in the editbox. In this snippet we use two comboboxes, each used to select an area unit of measurement. Once selected, an area value can … | |
Using a wxPython GUI program to find the position of the mouse when clicked within the frame/window. Also sets the color of the frame and changes the cursor to a pencil. The title bar of the frame displays the coordinates of the mouse position. | |
This short code lets you create a base64 encoded image string, that you can copy and paste into your Python program code to display relatively small embedded images. For a typical application see: [url]http://www.daniweb.com/code/snippet393.html[/url] | |
Python has a module specifically made for timing built-in or owner coded functions. This code snippet explains how to use this feature. | |
Python24 introduces the function decorator that lends itself nicely to the timing of a function. As a sample function we are using the ever popular and rather stodgy prime number generator. The prime number generator seems to exist only to fluster students and to make niggling comparisons of the speed … |
The End.