2,322 Reusable Code Snippet Topics
Remove Filter ![]() | |
This Python Tkinter GUI toolkit code draws a shape, and shows you when and where the mouse has been clicked within the shape. | |
There is always room for optimizing primelist functions. Here is an assortment timed with Python module timeit ... | |
This code to save, Edit and delete data in VB.Net using SQLServer as backend. this code is continuance from my previous post "Show Data in DataGrid with VB.Net 2003 and SQLServer 2000". so i didn't write code how to connect SQLServer 2000 with VB.Net 2003 cause this already in there. … | |
This program in C finds 2 Longest common subsequence of 2 given strings(say X and Y),entered without any space on the screen individually,altering X and Y strings.I compiled and executed this above program successfully in Dev Cpp compiler as a C file(not a c++ file). | |
While at work i had nothing to do so i wrote this simple python script that uses the dbm module to store user information its not perfect but im sure someone will find it helpful. | |
This snippet defines a `dir()` function which extends python's builtin `dir()` function by adding options to filter the returned sequence of strings by the means of regular expressions. The main use case is live inspection of python objects and modules during an interactive session with the python interpreter. The idea … | |
Here improved example based on MITx course of using the bisection method for root finding. | |
I am exploring some of the PySide (PyQT public) widgets like the combo box, and how colors are applied ... | |
This Python code shows you how to get a current list of currency values (Canadian Dollar = 1.00) via the internet. | |
Tablesorter (currently v2.0.5) includes an "update" method. This method keeps a Tablesorter object up to date with dynamic changes made to its table(s). Like other Tablesorter methods "update" is implemented in the form of a custom event. A typical method call would be $table.trigger("update"); , where $table is a jQuery … | |
Below is a documented code example showing how to use the [PDO](http://php.net/pdo) classes/objects to connect and query your database (and check for errors). If there are any questions, or you want to see different features, let me know. UPDATE: I've encountered a problem with PDO and bit fields (MySQL). If … | |
This snippet allows one to implement an equivalent of a `__getattr__()` function in a python module. The module can then define its own way to lazily import abitrary symbols. For example the module can contain infinitely many names or load values from other modules on demand. There are many implementations … | |
This snippet could be a problem solver for a tricky programing problem in entrance exams. Hoping that this has no buggs. haha. Didn't use compiler for this ![]() | |
Below is a documented code example showing how to use the [MySQLi](http://php.net/manual/en/book.mysqli.php) (MySQL improved) classes/objects to connect and query your database (and check for errors). If there are any questions, or you want to see different features, let me know. | |
Below is a documented code example showing how to use the [MySQL functions](http://php.net/manual/en/book.mysql.php) to connect and query your database (and check for errors). Please note that using the MySQL extension is **NOT RECOMMENDED**. This extension is no longer maintained and will be deprecated soon. If you want your scripts to … | |
# This is a simple HTML String Sanitizing tool. # ## It allows a highly rich,- but safe - html content input to be published on your pages. ## **The script code is very light and to some degree customizable.** * This function takes care of blacklisted tags, which are … | |
A program which displays the prime factors of a given number, all the 'hard' work is done by the [B]factorize()[/B] function: [CODE=c] /* Find out the prime factors * of a given number and print * them on the screen */ void factorize(int n) { int d = 2; if(n … | |
The Tkinter library folder \lib-tk contains a module called turtle. You can import this module and experiment with turtle graphics. Tell the turtle to move and draw circles, lines, rectangles and more, and watch it, as it performs on a Tkinter canvas. In typical turtle fashion it moves at its … | |
Encoding and decoding functions for RFC 4648 compliant base-64. The code is written in standard conforming C11 and backward compatible with C99 (pre-C99 is *not* supported without code changes). | |
JavaScript doesn't actually have a sleep() function corresponding to what is available in other languages. We can easily implement one though. The following code uses afunc as an example function where we want to be able to have the code sleep for a number of milliseconds between sections of code. … | |
| |
With this *Spartan*, we can destructively disable all the links on the page. (Or whatever link collection we feed the Fn.arg.) ![]() | |
This is a simple hangman game that I wrote using my beginner python skills. Though this game is playable, there must be lots of things I must've been doing wrong or the methods I'm using here may be not so pythonic. So I want some suggestions on how to improve … | |
Here I am Sending you my code ,wherein I want to have total of examfees(column),PromotionFees(column),Totalfees(column) and Balance(column).Examfees are paid in installment in my project The idea if single record is found then it doing calculation of balance=promotionfees-totlafees and if anywhere due to mistyping is value is higher then the respectively … | |
Here is slow brute force way to find the largest palindromic product of three digit integers. You could do loop and break out of it if you go under the smaller number (the second one) of best solution found so far to be more efficient etc. | |
Ok, so, this code snippet is a reply to this thread: http://www.daniweb.com/software-development/cpp/threads/425821/prime-number-c From what I understood form the OPs request, is that, he wanted an algorihm which would check for prime numbers in a given range, applying these conditions: a number is to be considered valid if: a. the number … | |
Just a few more explorations using a Python class to mimic a C Structure or Pascal Record. Loading the record from a csv type data file, displaying the data and sorting and searching the data in various ways. | |
Eg.407 4*4*4=64 0*0*0=0 7*7*7=343 now 64+0+343=407. Any number which satisfies the above condition is called as Armstrong | |
What is it : A simple logic (text based) game, in which you are required to identify the counterfeit coin within 3 chances. How it works : You are given 'x' coins ( best is to play it with 12 coins ). You are asked how many coins you want … | |
Just a simple text editor using the Tkinter expansion TIX. You are encouraged to improve this program with added functions. TIX is included with the latest Python distributions. | |
This is a very simple Rock Paper scissors game i made. i showed it to my cousin and he played it for like 20 mins lol. Its against an AI and you pick by number, not words. | |
| |
Use regular expressions, regex, to create an efficient textbox that only takes in digits as input. | |
There was discussion thread http://www.daniweb.com/software-development/python/threads/424953/polynomial-division for class based implementation for polynomials, and I developed a version utilizing the magic methods to enable operation with normal arithmetic operation. I only inherited sequence structure from list type. Interoperability with scalar types is not implemented to avoid too complicated type checks of the … | |
This is a short bit of code that shows how to implement sorting on columns in a details-mode ListView. Suggestions for improvement are always welcome. One possible improvement would be to modify the column headers to indicate which column is being sorted and in which direction. | |
Hello everyone, I stumbled upon a video about the monty hall problem, which I found very well explained, and a lot of comments below the video that were against the conclusion that it **is better to switch**. To clarify, I wrote this small program that simulates the game and allows … | |
This post is a followup to an older dicsussion [on recordmanaging](http://www.daniweb.com/software-development/python/code/429753/custom-named-tuples-for-record-storage). I am writing this to share with colleagues, so it may be a bit fluffy and not straight to the point. I apologize to all the experts. Good programs always start by managing data in a flexible and robust … | |
These are just some of the more useful #define statements I've used in C++. These are some of the statements you'll use the most (in the case of template<typename T> when you use it, you use it a lot!). So I figured I'd post it for others, even though a … | |
In addition to [my post in this thread](http://www.daniweb.com/web-development/php/threads/429740/php-best-practice#post1841569) I've decided to post an extended example, which also implements functions for inserts and updates. I hope the code is straightforward enough. If not, reply and let me know. The table structure I've used for my test is the following: CREATE TABLE … | |
This code was inspired after several discussions on the forum, and I'm especially indebted to PyTony for all of his help with these aspects. The motivation behind this code is quite simple. I wanted a robust, light and general way of storing CSV data that could be used over and … | |
Sometimes sorting data can be easy and sometimes it can be difficult. If you have data in a listview you can spend a great deal of time writing ICompare functions. This is appropriate for non-trivial applications but can be a little intimidating for inexperienced programmers. Also, it is a problem … | |
This is a piece of code I wrote a long time ago when I saw someone make a "guess this scrambled word" game. The program didn't have to unscramble the word to know what the answer was, but I wanted to do it anyways. I wanted an algorithm that could … | |
Hey everybody, Lately I have written the game Hangman in many different languages (C, JavaScript, Java and PHP so far). Here is the code snippet for JavaScript! It uses a words file, on the bottom of this post you will see a small example of a few words. The source … | |
You have to mildly trick Windows, but it is possible to put a bitmap image on your console. Uses a flock of WinApi calls. Works well with the free PellesC compiler and Dev-C++. This is a Windows Console Application. Drop me a comment, if you have luck with another compiler. ![]() | |
This is how mine [B]strcmp[/B] function would look like if I'd to implement it from scratch :) | |
This is a very simple statistics script that provides for services on/offline, memory info, server load averages and uptime and lastly drive info. Its easily customised and i have usef <font> alot where you could have set come css and have it all done easily and look a bit more … | |
The computer is a binary beast. We want to go from the one-fingered digital box to the ten-fingered human being and convert binary to denary(base 10) numbers. This is how it works, for instance, binary 10010 is calculated as 1*16+0*8+0*4+1*2+0*1 = decimal 18. Just because it's easy, let's throw in … | |
Hi. Here is a simple beginners program. It uses "if_else" and returns no information. After execution, it deletes files within the same directory as the exe. Enjoy. |
The End.