2,322 Reusable Code Snippet Topics
Remove Filter ![]() | |
How to create a png image containing a fragment of source code ? Well, don't do it yourself, the [url=http://pygments.org]pygments module[/url] contains all the necessary tools. The example below shows how to produce a png image from python code, but pygments supports lexers for many other languages and its formatter … | |
I saw a thread lately on this site to rotate an integer. Seemed like a fun project to do. There are probably more efficient solutions out there but this is mine, and indeed it was fun! It is mostly a demo on how you could use the less known shift … | |
[url=http://www.daniweb.com/software-development/python/threads/375271/1621485#post1621485]Sample code credited to Enalicho[/url] In this example, we count the number of appearances of the number 1 through a range of pages using while loops. First off, notice how easy it is to tell what the variables in this method are doing. I did not write this method, but … | |
Hello everyone. i have a student database, from which i search a student by entering the student ID at the web interface.Im using a repeater to display search results. Within this repeater i have a link button that should redirect to a page that will display full information about the … | |
A functor, or function object is sometimes a convenient way to encapsulate helper functions and data needed to achieve a small task, and also to share data between calls to the same function. This snippet defines a base class [b]functor[/b] which permits an easy functor creation for python 2. | |
Inspired by Computer Science forum post, I did this code. I prepared it Shedskin compatible, and it runs quite nicely indeed. Even interpreted the algorithm is faster than full sort. Here interpreted test for the module, shedskinning this test would show better time for sort solution. Python version has benefit … | |
Play any Sound File. Just add a reference to Microsoft.DirectX.AudioVideoPlayback(COM) | |
Gets the names of all the partitions in a system. Note that media must be in every removable drive for this to work (can be fixed easily) | |
This snippet defines a context [icode]autofilename()[/icode] to create an existing temporary file with a new name in python. Unlike the methods in the [icode]tempfile[/icode] module, it only gives a filename which exists within a 'with' block, instead of an open file. This is useful for example when a program needs … | |
Here is Mandelbrot set viewer in Tkinter and modules for shedskining (included compiled modules for windows in the zip file): [CODE]# mandelsh.py def mandel(real, imag, max_iterations=20): '''determines if a point is in the Mandelbrot set based on deciding if, after a maximum allowed number of iterations, the absolute value of … | |
As a companion article to my [URL="http://www.daniweb.com/code/snippet349081.html"]Permutation Generation[/URL], I now present Combination generation. This snippet will do a lazy generation of the combinations of a set of objects. Each combination has a grouping size (number of items in each combination). If you need a different grouping size, you'll have to … | |
View the full tutorial at [URL="http://www.effectivewebdesign.co.nz/tutorial.php"]http://www.effectivewebdesign.co.nz/tutorial.php[/URL] I have tested this many times and it works fine. Please don't complain unless you really can't get it working, Just PM me and I'll fill in the blanks Happy Coding :) | |
ShowDriveSerialNo shows it with ShowMessage GetDriveSerialNo returns a string. You don't need both. | |
This does not look very efficient with transponation, sort and transponation back, so I am happy to hear about better alternatives. | |
Another task from C++ forum is trivial in Python even taking handicap of not using Counter. | |
My not OO version of timer for work and pause time (but it does use attributes for functions, which are objects, to avoid global declarations in functions). | |
I have seen many beautiful clocks using images and and canvas and flash. So I thought of developing one with pure HTML,CSS3 and javascript, no images at all. This clock can be completely design using CSS. A brief description of Javascript used:- 'AnalogClock' is the name of the class which … | |
{-='Smallest, Largest & Sum of 5 numbers using Dev-C LaNGuaGe'=-} | |
I wanted to export a list of all email addresses I had corresponded with and was unable to find a free product to compile the list so I came up with this. You could take it a step further and scrape additional email addresses from the message body. As far … | |
Another quick code over breakfast inspired by 'spying' the other forums. | |
Short piece of code to add a "menu" to your Console application. | |
A little program I made to try and remeber C++, first program I've written in C++ in about a year. Tested and working under windows 7 64 bit, run via command line. If you have any improvements or ideas please leave a comment. Cheers K0ns3rv | |
Next quiz is posted as code snippet. It is quite interesting code. What it does? And where [B]in your system[/B] you already have this code? (in little different format) (If you have not follow tip in page [url]http://python.org/download/[/url]) | |
This is my first step towards HTML5. This is currently tested on Chrome browser where it is awesome. It will not work on FF and definitely not on IE. I am working on it. Just copy-paste the code in blank html file and run on chrome. 'Scroller' is simple menu … | |
Lets say you have lots of data your listview. Now you want to Group This data According to a Perticular Subitems. For Example: Suppose i have some books data in my ListView. this listview items contains Author name and Books Title. And there are 2000 Books in list view. Now … | |
One more application of the Python Image Library (PIL). This short code creates thumbnails from all JPEG files in the current folder. The thumbnail image file is prefixed with a T_ and saved to the same directory. The program checks for existing files with this prefix, so we don't create … | |
The code demonstrates running program limitted time by following going over endtime expressed in seconds since midnight, so might fail for playing just midnight (add check that endtime is less than 24*60*60 if you want to be sure). Exciting action :) of the program is that it shows remaining time … | |
A Simple method to create a short url using google | |
I find C# very well suited for doing math and all sorts of calculations, so here is an example. Just start a Console application and fill in the code. Have fun! The code also shows a use of delegates and some Console functions. If you don't know what the Newton-Raphson … | |
This is the code snippet used to get the files/folder present in a particular folder/sub directories. | |
There was little buggy version of Python base conversion around, so here quick hack for my own program, including test with random numbers to verify it. | |
simple Code Snippets to Convert Image to Byte Array and Vise Versa | |
Function to Convert Dataset to Excel. It will export all the table of the given dataset to the given excel. Example: [CODE]ExportDatasetToExcel(dsFinal, "d:\\my.xls") [/CODE] where dsFinal is my Datase and second parameter is the excel file location. Make sure the excel file exist. | |
Lookup table is usually the fastest method to find function value, if number of values is small. Here we demonstrate the principle by using task of showing the value of byte as binary string or transforming binary string to byte binary value. | |
Well, it bothers me to build menus for every shell application that needs one. So, I've written a module to handle that, like in the good old turbo pascal times. :) Here it is, the module comments are pretty explainatory, I think, and the sample usage if run as script … | |
I wish it show as unfulfilled:bb,cc extra provided:dd as my conditions and provided strings will be unconstant, anyone can suggest me some ways to do it? ![]() | |
Listing All The Installed Softwares In Computer Using .Net Don't Forget To add [B]using Microsoft.Win32 [/B] For Complete thread with screen shots see here:[snipped] | |
[CODE] namespace ConsoleApplication8 { class Program { static void Main(string[] args) { Person p1 = new Student(); p1.Sing(); p1.Run(); Console.WriteLine(p1.GetType().Name); Console.Read(); } } class Person { public void Run() { Console.WriteLine("Person Run"); } public virtual void Sing() { Console.WriteLine("Person Sing"); } } class Student : Person { public void Run() … | |
This code is to generate excel with grid lines in it with file name as you given in the code which will disply when you opening throug the download dialog box, Regards, khaleel | |
Code for connecting to Microsoft Access databse, opening and closing connection | |
One solitaire game practice until the first win or 'q' after game. | |
A Function To Concat String Array Values By Specified Delimiter Let 's Say I have Following Array: string[] st = new string[5]; st[0] = "Animation"; st[1] = "Action"; st[2] = "Romance"; st[3] = "Drame"; st[4] = "Comedy"; Now I want to Merge all of it with ',' Delimiter Like Below: … | |
Listing All The Installed Softwares In Computer Using .Net Don't Forget to add [B]Imports Microsoft.Win32[/B] for complete thread with screen shots check here: [snipped] | |
A Function To Find Strings Between A Given Word/String For example : let's say you have following Text: Title Author Product* ~~~~~ ~~~~~~ ~~~~~~~~ "Aurora's Eggs" Douglas Niles Story (Dragons 2) The Dragons Douglas Niles Novel The Kinslayer Wars Douglas Niles Novel The Qualinesti Paul B. Thompson Novel & Tonya … | |
Hi All, I have an xml [CODE] <?xml version="1.0" encoding="UTF-8"?> <columns> <column> <name></name> <displayname></displayname> <attributes> <attribute> <name>width</name> <value>100</value> </attribute> <attribute> <name>text-align</name> <value>left</value> </attribute> </attributes> </column> <column> <name>VersionCode</name> <displayname>Version Code</displayname> <attributes> <attribute> <name>width</name> <value>200</value> </attribute> <attribute> <name>text-align</name> <value>right</value> </attribute> </attributes> </column> <column> <name>MaterialType</name> <displayname>Material Type</displayname> <attributes> <attribute> <name>width</name> <value>100</value> </attribute> <attribute> … | |
![]() | [CODE]// create two new instances of LoadVars, one to send and one to receive data var dataOut:LoadVars = new LoadVars(); var dataIn:LoadVars = new LoadVars(); // define what should happen when the response is received, // using 'this' to refer to dataIn and get data from it dataIn.onLoad = function() … ![]() |
hi.. You will need Taglib - Sharp Library for this purpose . For Complete understanding and project Download Go to: [snipped] | |
You can use a decorator to modify the function object once, by assigning initial values to some new attributes. Then use these attributes as you would use static variables in other languages. Here is the result: (1, 1, [1]) (3, 2, [1, 2]) (6, 6, [1, 2, 3]) (10, 24, … | |
I've written a C++ function which converts an integer to a (C++-)string ... [CODE=C++] ... string s = itos(5698); cout << s << endl; /* Will print '5698' on the screen */ ... [/CODE] You MAY use this code for anything you want but [B][COLOR="Red"]you aren't allowed to sell this … |
The End.