2,322 Reusable Code Snippet Topics
Remove Filter ![]() | |
Here's I wrote some code to move controls on the form 1- Assign (Control_MouseMove, Control_MouseDown, and Control_MouseUp) to the controls you need it movable. | |
This is a facial recognition system. Supports one face so far. This is an example ported from C++ to python. To see the original and to obtain the dll used visit [URL="http://www.kyb.mpg.de/bs/people/kienzle/facedemo/facedemo.htm"]this site.[/URL] I do not take credit of the dll, only the ported python code. The comments in the … ![]() | |
Hi, please don't blame me for reinventing the wheel, I was bored and had nothing to do, so I thought: what would I write? And apparently this code is the result :P | |
This is a very simple bbcode example to use on a forum or your pages. Add this to a function page and make sure the function is required on the page you want to on. ENJOY!! :D | |
circle.h [code] // // circle.h // defines the functions to draw circle. // #ifndef CIRCLE_H #define CIRCLE_H #include <windows.h> typedef struct tagCircle { int x; int y; int radius; } Circle; /* set the window handle */ void SetWindowHandle(HWND); /* set pixel @parms int x xposition @parms int y yposition … | |
You can download the matplotlib free from: [url]http://matplotlib.sourceforge.net/[/url] It has, amongst many other things, the module pylab that allows for high quality plotting of data. All you have to do is to feed it a list of x values and the corresponding list of y values calculated from the x … | |
![]() | Hopefully someone searches this one day and it becomes useful. I never found anything. Below is the vb syntax for combining numbers in the same memory address. [code] Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim LngWord As Long = LngMakeWord(Integer.MaxValue, 65489) Dim LoLng As … |
An integer is loaded in from memory. ran through two loops to determine the tens place and the ones place. Integer is stored back to memory and displayed. Example #98 Tens place -->9 Ones place -->8 :) | |
This is a great example for a thread stop. Simple debugging trick for any looped process that needs the "e-brake" applied while making sure that the thread is working correctly. The idea is that you can manually stop a thread, to prevent that hanging sensation during any process. This works … | |
Hi! I just want to share you this code snippet of mine which I use always in my application. This code snippet will help you debug your code easily. It will also help you locate where the error occurred and it also create an Error log located on your project … | |
Just a little code I have been working on. New to programming and learned about rand. I applied it in this program. Like I said I'm new to programming and if there is a *easier and more effective way* to write some of my code, please tell me. The part … | |
If you want your program to startup automatically when the user logs in, just paste this code into it. To add as a HKLM (For all users) startup item instead of HKCU (Current User), change HKEY_CURRENT_USER to HKEY_LOCAL_MACHINE. I'm posting this because I had a hard time figuring this out … | |
[B]In this case, Form1 is the Main Form.[/B] Pre-requisites: [B]2 Forms (Form1 and Form2), 1 Button (on Form1)[/B]. [CODE]Public Class Form1 Function centerForm(ByVal Form_to_Center As Form, ByVal Form_Location As Point) As Point Dim pLocation As New Point pLocation.X = (Me.Left + (Me.Width - Form_to_Center.Width) / 2) '// set the X … | |
This little code snippet shows you how you save a wxPython canvas drawing to a standard image file. | |
1- Handler TextBox Key pressed event handler. | |
This is an example of using a binary index file to speed up random access of lines in a file. The file is indexed one time, where the position of the start of each line is stored in an index file. Subsequent requests for a get the position from the … | |
This short C# code will calculate the fibonacci number of an integer and display the result in a Windows GUI label. | |
![]() | [code] ''' <summary> ''' Returns a new copy of the bitmap passed in. The new copy is rotated ''' to the specified degree and resized to fit its new bounding box. ''' </summary> ''' <remarks> ''' The Original Bitmap should be the bitmap that has never been rotated. ''' If … ![]() |
Okay, this is just a simple trick to determine whether CAPS is pressed because some people here use API to determine whether the CAPS Lock is pressed. [QUOTE] KeyDown and KeyUp don't detect exactly the same information as KeyPress. KeyPress detects a character in its KeyAscii parameter, but KeyDown and … | |
This snippet takes a string as input and formats it to proper case | |
With this code you can explore the functions of math module interactively seeing the docstrings automatically for each function. EDIT: The docstring was unfortunately from old code, this version copes with values like 'e' and multiple parameter functions. | |
This program was developed and tested in the XP environment, so the requisite platform is Windows. It demonstrates some basic sound file manipulation techniques using the Multimedia Control Interface (MCI). | |
hey buddies:) here is login page for begining purpose in asp.net i hope you will enjoy it and it is expected there is some mistakes also so please feedback it. Thanks | |
This is one of the easiest steps to view and convert dcm image useing the [B][COLOR="Red"]snake(python)[/COLOR][/B] There are 3 modules involved. 1. Search for [B]pydicom[/B] and install 2. Search for [B]matplotlib[/B] and install 3. Search for [B]pylab[/B] and install. If you are on ubuntu destro, Installing matplotlib via the repo … | |
A project I am working needed a question style message box, but I wanted that contemporary look of Vista and Seven. I set out to see how it was accomplished, turns out there are some special APIs that exist in Vista and Seven that don't exist in XP that accomplish … | |
These days, it's usually unnecessary to consider how much memory to allocate for a string input. This was mostly for fun. This code allocates memory as the user inputs each key stroke, then allocates and returns a string pointer when the user presses enter. Tell me what you think! [B]USAGE:[/B] … | |
[CODE] DynamicTypeList list; list.add(42); list.add("forty-two"); for (DynamicType* item = list.begin(); item != list.end(); item++) { if (item->what_type == item->is_int) { cout << item->integer << endl; } else if (item->what_type == item->is_string) { cout << item->string << endl; } }[/CODE] | |
This is for the numerous people I see constantly asking how to "pause" the console after their code runs. The explanation for how the code works is within the snippet in comments. Basically, the "cin.clear();" function will clear the input stream, getting rid of any newline characters that would have … | |
Using FPS IDE with FPC compiler on windows xp. | |
I needed a very simple multi-line label control for a project I was working on, It had very simple requirements. It needed to draw text in any font, in any color, on multiple lines with vertical and horizontal alignment control. So I hacked up this little class. Just as easy … | |
The above code will get the user information from page "getuser.php". The output of getuser.php has some numericals populated in 5 rows. The 6th row i.e., the table footer has the sum of all numericals populated in the above 5 rows. The numericals in the first 5 rows are populated … | |
[COLOR="Red"]NB:Excuse me Experts,,,This is only for beginners......[/COLOR] [COLOR="Green"]JAVASCRIPT FOR CHECKING WHETHER THE TEXT FILED IS FILLED OR NOT[/COLOR] Be noted that 1.The form given above is just for example 2.You can add your own form,,please dont forget to chenge the names in assignments as you are going on your own … | |
Hi all, Well this is my 1000th post here at DaniWeb and I thought "What better way to celebrate than by posting my first ever code snippet?" This problem occurred in an application that I am working on. I have a password field in my form that was specified as … | |
This snippet generates the best rational approximations of a floating point number, using the method of continued fractions (tested with python 2.6 and 3.1). | |
It counts upper lower and digits in a file .. | |
Hello :) I'm from Brazil, so sorry about my english. This is the first code I post here - I'm a begginer in Python. It is a function to calculate determinants of matrices. You can attach it to a class if you wish. Please leave a comment if you wish … | |
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 is a program which declares two vectors of 6 elements each of type double. One vector is named weight and the other is named rate. The program uses a loop to prompt the user for a weight in ounces and a postage rate for that weight and then stores … | |
Here another small snippet of mathematical nature returning all possible divisors of number. (set is, by the way, needed because of perfect squares Not possible to edit the snippet part but here the same with less stupid command line interface (not repeating the loop): [CODE]def divides(n): return sorted(set(sum( ([x,n/x] for … | |
A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an "array of arrays". [COLOR="Red"]NOTE:-[/COLOR] I'm using Single dimensional jagged array. Actually I am using single and multi dimensional arrays as … | |
This snippet defines a function to merge sorted iterables containing similar items into a single iterable. Items are supposed to be sorted in ascending order. Only one item per iterable is stored at a time. | |
[edit] This code was originally posted [URL="http://www.programmersheaven.com/dow...3/ZipView.aspx"]here [/URL][/edit] The problem is to find all ways of placing n non-taking queens on a n by n board. A queen attacks all cells in its same row, column, and either diagonal. Therefore, the objective is to place n queens on an n … | |
This code is giving minimal change from real Python class to JavaMonster with every method having setter and getter not following the PEP8 naming but capitalizedWordsFormat. When instrunctor turns his head or if you put the code in your library, you can simply remove the setter/getter lines. | |
This snippet defines 3 functions to create in a few seconds an image of a graph containing arbitrary python objects. It uses the module pygraphviz (available at [url]http://pypi.python.org/pypi/pygraphviz/[/url]). See the example use case at the end of the module. | |
Based on thread [url]http://www.daniweb.com/forums/thread323401.html[/url], I did this recursive version for comparision. Thanks for posters of the thread! | |
The class GoogleSuggest will help you to grab the Google suggestion(s) for given expression. [B]Note[/B]: The urllib2 module has been split across several modules in Python 3.0 named urllib.request and urllib.error. The 2to3 tool will automatically adapt imports when converting your sources to 3.0. Example and output: [QUOTE] >>> ================================ … | |
Looking on the web very few have got VB.net 2008/2010 using object arrays working. I felt it was time to give back what I have taken from the web for any other users. VB6 had a simple object array system which has been lost in VB.net As a C#/ C++ … |
The End.