2,322 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for TrustyTony

Here some experiments to pretty print polynomials with help of vegaseat's tip of wx.lib.fancytext.

Member Avatar for Gribouillis
1
765
Member Avatar for iamthwee
Member Avatar for sukanya1990
0
5K
Member Avatar for snehalj

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.

Member Avatar for snehalj
0
553
Member Avatar for TrustyTony

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.

Member Avatar for griswolf
3
2K
Member Avatar for Geekitygeek

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 …

Member Avatar for beetscodes
3
1K
Member Avatar for vegaseat

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 …

Member Avatar for Gribouillis
0
439
Member Avatar for AntonyLini

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 …

0
312
Member Avatar for ashishkumar008

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)

Member Avatar for vijaykrishnabor
0
307
Member Avatar for php4ever

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 …

Member Avatar for dennishall
0
152
Member Avatar for Krstevski

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 …

Member Avatar for Momerath
1
245
Member Avatar for NicAx64

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 …

Member Avatar for psharma
0
703
Member Avatar for redyugi

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 …

Member Avatar for redyugi
0
454
Member Avatar for Gribouillis

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 …

1
550
Member Avatar for Stack Overflow

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

Member Avatar for sudheer51
0
2K
Member Avatar for preetg

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

Member Avatar for didier_m
0
416
Member Avatar for digital-ether

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 …

Member Avatar for digital-ether
2
1K
Member Avatar for AntonyLini

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 …

0
311
Member Avatar for Ancient Dragon

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 …

Member Avatar for Ancient Dragon
0
964
Member Avatar for avirag

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 …

Member Avatar for Problem Solwer
3
580
Member Avatar for TrustyTony

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]

Member Avatar for TrustyTony
0
534
Member Avatar for Rashakil Fol

wordify: Converts any integer number (such as 123456000999) into a string ("one billion two hundred ninety-three million one hundred two thousand one hundred").

Member Avatar for v6ak
0
350
Member Avatar for Gribouillis

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 …

0
248
Member Avatar for serkan sendur
Member Avatar for mikeandike22

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.

Member Avatar for jsmall26
0
89
Member Avatar for Luckychap
Member Avatar for burcin erek
0
1K
Member Avatar for harshchandra

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 .

Member Avatar for ezkonekgal
-2
2K
Member Avatar for sniper6560

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!

Member Avatar for sniper6560
0
2K
Member Avatar for jhai_salvador

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 …

Member Avatar for AndreRet
1
501
Member Avatar for NicAx64

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 …

Member Avatar for Ancient Dragon
0
654
Member Avatar for choover12

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 …

0
307
Member Avatar for alenturuskovic
Member Avatar for Wolfgan
0
177
Member Avatar for 1o0oBhP

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 …

Member Avatar for Thokozani
1
2K
Member Avatar for TrustyTony
Member Avatar for TrustyTony
0
592
Member Avatar for PsychoCoder

A C# snippet demonstrating how to merge 2 files (of any type) into a single file. Need a reference to the System.IO Namespace

Member Avatar for srps.software
2
209
Member Avatar for NormR1

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 …

0
655
Member Avatar for ApocDen

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.

Member Avatar for kyrilkong
0
1K
Member Avatar for Ancient Dragon

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

Member Avatar for ll_MORTAL_ll
0
854
Member Avatar for Beat_Slayer

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

Member Avatar for Beat_Slayer
1
570
Member Avatar for Airshow

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

Member Avatar for jadhav vijay
2
1K
Member Avatar for vegaseat

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]

Member Avatar for tudza
0
871
Member Avatar for Jreynolds3

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 …

Member Avatar for vhan
0
6K
Member Avatar for ShawnCplus

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 …

Member Avatar for TonyAR
0
733
Member Avatar for harikumar86

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

Member Avatar for harikumar86
0
325
Member Avatar for ultimatebuster

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.

Member Avatar for TrustyTony
0
185
Member Avatar for digital-ether

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 …

Member Avatar for benjaminFowl87
0
238
Member Avatar for vegaseat

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 …

Member Avatar for bvdet
1
1K
Member Avatar for lionaneesh

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 …

Member Avatar for challarao
0
2K
Member Avatar for PsychoCoder

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)

0
769
Member Avatar for PsychoCoder

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.

0
3K
Member Avatar for vegaseat

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 …

Member Avatar for shahjapan
1
6K

The End.