2,322 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for Ramy Mahrous

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.

Member Avatar for vigor
2
1K
Member Avatar for Tech B

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 …

Member Avatar for Tstrv
1
659
Member Avatar for tux4life

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

Member Avatar for Ancient Dragon
0
205
Member Avatar for ApocDen

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

Member Avatar for phplover
0
391
Member Avatar for NicAx64

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 …

2
499
Member Avatar for Ene Uran

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 …

Member Avatar for Flintstone_
2
2K
Member Avatar for Unhnd_Exception

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 …

Member Avatar for zinnqu
2
983
Member Avatar for Fabii23

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 :)

0
406
Member Avatar for zinnqu

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 …

0
3K
Member Avatar for jhai_salvador

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 …

Member Avatar for jhai_salvador
0
1K
Member Avatar for dadam88

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 …

Member Avatar for frogboy77
0
438
Member Avatar for hahanottelling

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 …

Member Avatar for WaltP
0
3K
Member Avatar for codeorder

[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 …

Member Avatar for codeorder
0
821
Member Avatar for vegaseat

This little code snippet shows you how you save a wxPython canvas drawing to a standard image file.

1
2K
Member Avatar for Ramy Mahrous
Member Avatar for Narue

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 …

4
366
Member Avatar for Lardmeister

This short C# code will calculate the fibonacci number of an integer and display the result in a Windows GUI label.

Member Avatar for nive.s
0
505
Member Avatar for Unhnd_Exception

[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 …

Member Avatar for Unhnd_Exception
0
941
Member Avatar for jhai_salvador

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 …

Member Avatar for jhai_salvador
0
879
Member Avatar for seanbp
Member Avatar for PsychoCoder
Member Avatar for TrustyTony

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.

Member Avatar for TrustyTony
0
220
Member Avatar for banders7

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).

Member Avatar for Azar Mohamed
-3
4K
Member Avatar for nirveshverma

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

Member Avatar for umamahesh2020
0
155
Member Avatar for richieking

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 …

Member Avatar for richieking
0
4K
Member Avatar for Diamonddrake

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 …

2
224
Member Avatar for seanbp

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] …

0
332
Member Avatar for seanbp

[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]

0
591
Member Avatar for packetpirate

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 …

Member Avatar for MosaicFuneral
-1
2K
Member Avatar for EAnder
Member Avatar for Diamonddrake

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 …

2
453
Member Avatar for aditya61

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 …

Member Avatar for scrappedcola
0
312
Member Avatar for DealthRune
Member Avatar for rajesanthu

[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 …

0
212
Member Avatar for darkagn

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 …

Member Avatar for darkagn
2
380
Member Avatar for Gribouillis

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).

Member Avatar for Gribouillis
1
1K
Member Avatar for Shankye
Member Avatar for Hawkeye Python

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 …

Member Avatar for Gribouillis
0
3K
Member Avatar for PsychoCoder

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

Member Avatar for nelsonddon
3
1K
Member Avatar for gpjacks

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 …

0
255
Member Avatar for TrustyTony

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 …

Member Avatar for TrustyTony
1
877
Member Avatar for ashishkumar008

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 …

Member Avatar for Shlesh
1
139
Member Avatar for praneeth_gunda
Member Avatar for Gribouillis

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.

Member Avatar for Gribouillis
0
599
Member Avatar for meabed

[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 …

Member Avatar for bangonkali
0
894
Member Avatar for TrustyTony

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.

0
261
Member Avatar for Gribouillis

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.

Member Avatar for woooee
1
1K
Member Avatar for TrustyTony

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!

Member Avatar for TrustyTony
0
1K
Member Avatar for Krstevski

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] >>> ================================ …

Member Avatar for TrustyTony
0
658
Member Avatar for DavidRathbone

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++ …

Member Avatar for AndreRet
1
2K

The End.