2,322 Reusable Code Snippet Topics
Remove Filter ![]() | |
Here some experiments to pretty print polynomials with help of vegaseat's tip of wx.lib.fancytext. | |
![]() | This snippet shows you how to connect to a database using ODBC in vb.net 2005 |
above code not working, y is 2010 and year0 is also 2010, as per my knowledge Equal should be displayed as output, but the condition does not get equal. Pls help me for this. | |
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 … | |
The map() function applies a function to every member of a list. Here a list of numbers 32 to 255 is changed to a list of the corresponding ASCII characters. Then map() is used in a more complex application to combine the two lists to form a dictionary containing number:character … | |
Hello All, Inheritance in WPF application -- Create a window with all possible controls and functions which can be act as base form. then save it as template. Next time when u create a new form the saved template will appear on items. Create Window -> save it as template(File->export … | |
Hi....... This code is useful to check given string is palindrome or not. Actually, there are some other way also to check palindrome. So, be careful which code gives better efficiency. You can [COLOR="Red"]comment the line[/COLOR][COLOR="Green"]-bool caseignore= str.Equals(revstr, StringComparison.OrdinalIgnoreCase);[/COLOR] and in [B][COLOR="Red"]if[/COLOR][/B] condition you can use- if(string.Compare(str,revstr,true)==0) | |
I absolutely hate it when I trust a person and never collect a deposit on work only to NOT be paid when I'm done. I recently designed a flash page turn effect that is all XML controlled for a Realtor where the agents could simply upload the images to a … | |
Hello friends, I wrote a simple class for string validation and now I want to share with you. The class contains: - Constructor(s) public Validator() public Validator(string text) - Properties private string strText = string.Empty; - Method(s) public bool isNullOrEmpty() public bool isNullOrEmpty(string str) public bool isLengthMax(int maxLength) public bool … | |
well PHP is a powerfull text processing language designed mainly as a CGI ( common Gateway Interface ) programming language. But PHP supports rest of other features using the library extensions. For a example you can call any win32 API call in your PHP script using the win32 API library … | |
This is used for finding the roots of a parabola. The parabola must have a number in front of x2 (x squared), a number in front of the single x, and a following number, or you can have a perfect square parabola. (in the form "number x2 - number") This … | |
The with statement allows all sorts of syntactic sugar in python. This snippet defines two contexts: [icode]inevitably[/icode] and [icode]preferably[/icode] which register a function call to be executed at the end of a block of statement. Although they are not very useful (the function call could be written directly at the … | |
I've heard the curses library can be useful when trying to implement the handy DOS-only tools of gotoxy() and clrscr() using move() and initscr(). Though, there is a way to write your own gotoxy() in the Linux environment. This topic isn't touched often, so I would like to change that. … | |
hi...... i am using window xp.....apache server m new in php i inserted record in database through forms .now i m facing problem to delete the records from database in php code..... above code is not working properly...give me solution within 2 days.... | |
The above classes provide an interface for reading the PHP session data. PHP alone only gives you access to the current users session. This class allows you to read all session files, and thus allow you to read session data across different users. This may be useful if you want … | |
Hello All, Open Destination Folder programmatically using Folder Browser Dialog. [U][B][COLOR="Green"]CodeSnippet attached below[/COLOR].[/B][/U] Usually all know about the dialogs available in .net like savefiledialog, openfiledialog, printfiledialog etc; but many of us dont know about folderBrowserdilaog. Me too was unaware of it, and searched a lot to get code to open … | |
I previously posted an MS-Windows example program about how to recursively search folders and create a list of their filename. This program is similar in concept but is for linux. It c++ and uses std::string and std::vector classes to hold the strings. When the program encounters a directory it will … | |
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 … | |
From [url]http://stackoverflow.com/questions/228181/zen-of-python[/url] Tells you what is Zen of Python Actually this is enough to print the Truth: [CODE]import this[/CODE] Loop version from [url]http://stackoverflow.com/questions/3559124/dissecting-a-line-of-obfuscated-python[/url] [CODE]result = [] for c in this.s: ## fixed tonyjv if c in this.d: result.append(this.d[c]) else: result.append(c) print "".join(result) [/CODE] | |
wordify: Converts any integer number (such as 123456000999) into a string ("one billion two hundred ninety-three million one hundred two thousand one hundred"). | |
This snippet defines a function [icode]exc_browse()[/icode] which displays the current python exception in the web browser. This can be useful to non web programmers who want a nicely displayed exception traceback (web frameworks usually include this feature). The idea of this function is to store the html code generated by … | |
this application shows you how to declare variables and display variables. the end result of this code is showing you the total price after tax. this is mainly for beginners. | |
Here is simple c++ program to demonstrate matrix rain. Compiler:TurboC | |
This code calculates and the average waiting time of the process given acc to their burst time..It is a famous scheduling algorithm for process scheduling in operating sysytem . After calculating waiting time it also generates the gantt chart for the process given . | |
this code is for bessel function Y n (x) 2nd kind I'm in the level 4 at computer engineering my prof. gave me that assignment , I want help to improve it to get an accurate results thanks! | |
This is my Cogwheel Encryption Method to encrypt and decrypt strings. Wheel1 is Replace by Wheel2 when Encrypting and Wheel2 is Replace by wheel1 when you are decrypting... To Encrypt a string, just call the EncryptString function [CODE=vb] Text2.Text = EncryptString(Text1.Text) [/CODE] To Decrypt a string, just call the DecryptString … | |
This program will use arc-consistency to remove the invalid values from the variable domain and generate the permutations for the 8 queen problem. Here is the source code with the make file. chessboard.h [code] #include <iostream> // uses std::cout std::cin #include <stdlib.h> #include <stdio.h> // uses exit(0) and fprintf #include … | |
you can do this dim i as integer = 0 Public Sub Addtab() Dim browser As New webbrowser browser.Dock = DockStyle.Fill 'docking it browser.ContextMenuStrip = main.cms 'adding a context menustip to it Dim tab As New TabPage tab.Controls.Add(browser) main.Tabs.TabPages.Add(tab) 'IMPORTANT you must select the tab main.Tabs.Select(i) i += 1 End … | |
Procedure which checks the number of eating properly entered in edit box with a comma | |
The RLE (Run length encoding) compression method compresses a file by writing repeated data as a byte containing the length, then a byte of the data itself. The 'real' RLE method involves writing control bytes. The first bit says whether the following data is compressed or uncompressed. The remaining bits … | |
Here is code which I wrote to experiment how hard it is to get Royal Flush in Poker. | |
A C# snippet demonstrating how to merge 2 files (of any type) into a single file. Need a reference to the System.IO Namespace | |
For those that want to directly execute a .class file in a command prompt window. Here is a way: Create the following batch file. Use the Windows Explorer Tools to add a commandline for the .class file: C:\BatchFiles\ExecClass.bat "%1" Give it a name like: Execute class file The batch file … | |
This will count number of page views in a session. Simple, to add on the page just add the code on the top of the page and make sure it is before any html. | |
short program that will build a stl::list of directory names and all the files they contain. recursively calls itself when a new directory is encountered. This has been compiled with both VC++ 6.0 and Dev-Shed compiles on MS-Windows XP Pro. It will not work on *nix or probably MAC computers. … | |
Two litle functions to help on text slice and spliting. The code comments say it all. [CODE]# Slicer takes as arguments a tuple containing the string before, # the string after and the string to truncate. It returns the string # between the two given strings Slicer = lambda((b, a, … | |
[B]INTRODUCTION[/B] Have you ever wanted to pass data from one web page to another when server-side scripting is unavailable, and without setting a cookie? Ever wanted an efficient way to build url query strings? Well now you can. [B]SOLUTION[/B] It is maybe little realised is that data can be successfully … | |
Compress and decompress files using the popular pkzip format and the Python module 'zipfile'. [B][COLOR="Red"]Concept Error! This code just does archiving into a zip file, no compression![/COLOR][/B] To compress and archive files it is best to use module tarfile, see the snippet at: [url]http://www.daniweb.com/code/snippet216860.html[/url] | |
Hey people. What I'm trying to do is get a String input from the user. And then displaying that string. I have no idea how to do it. I have most of the code figured out except that one part. Any help will be greatly appreciated! Thanks!! (By the way … | |
This is about as simple as it gets with menu generators. Everything is explained in the code. Note that the menu is simply an unordered list so to pretty it up it really relies on the CSS. If you don't want to write any CSS of your own here is … | |
[CODE]Dim tp As Integer Dim str, flt(), strflt, sflt As String Dim l, l1, l2, l3, i, j, t As Integer 'Title code Private Sub Title_Change() Dim commas As Integer Dim pos As Integer Dim str As String l = Len(Title.Text) If l >= 80 Then MsgBox "Title Exceeded the … | |
This script is something i wrote during work, as I often need to do this (concatenate strings via multiple lines so it's clearer). Hopefully you guys like it. | |
A very simple MySQL database class. [B]Usage:[/B] [CODE]// connect $config = array( 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database); $DB = Database_MySQL::getInstance($config); // set query $DB->query("select * from table1 where col1 = %d and col2 = '%s' LIMIT 1", 5, 'a'); // get rows $rows … | |
If you bind a Tkinter widget to an event, normally only the event information is passed to the function responding to the specific event like a mouse click. Python allows you to expand the event handler to include any number of values to be passed on. Here is a typical … | |
This is a simple-web-server made in C.. [COLOR="Red"]Supported OS :[/COLOR] I have made it on Ubuntu 9.10 ... and i think it will run on all linux system .... [B]Windows is not supported[/B] [U][B][I][COLOR="Red"]Compiler Instructions : As this is a web server so it will host on port 80 to … | |
C# code snippet demonstrating how to set the status of a specified Windows service. Provide the name of the service and it's value (it's an integer value described in the comments) | |
This is a snippet that will get either all the child controls of a form (other other control) or controls of a specified type. This is for C# 4.0 as it utilizes an optional parameter. | |
This code sample shows how to represent employee data as a list of dictionaries. This list can be sorted and grouped by dictionary keys. In this particular example, I demonstrate how to calculate each department's average age from the data after sorting and grouping. The code is heavily commented to … |
The End.