2,322 Reusable Code Snippet Topics
Remove Filter ![]() | |
Efficient code for extracting unique elements from sorted array. Time Complexity is O(n) | |
This function I did to improve calculator program by eliminating problems with Pythons problem of dividing integer with integer and giving integer division result. | |
A short look at creating lists of file names or full path names using the versatile Python module glob. Glob follows the standard wildcard protocol. | |
Hi i am new at python,i am getting problem in the above code,the problem reads as follows: Having several accounts on several servers, one has to remember many passwords. You can imagine a situation where someone forgets one of them and he or she only remembers that it consisted of … | |
This is a text based solitaire game I wrote. It tested it on Ubuntu Linux and Windows and it worked okay for me. Move cards between rows using their row number (7 for the deck) Let me know what people think. Critiques welcome..... don't be too harsh ;) | |
The other code snipplets I found were either recursive or too complex. I therefore developed a simple, fast and yet non-recursive method; thats useful especially when working on the graphics card with CUDA as recursion is not possible there. (c) Sven Forstmann | |
Here tool functions, which came up during discussions earlier. Expanded slightly, added elimination of traceback prints by try..except. Added dd.mm.yy routine as that is format in my home country Finland. Optimized docstring beginnings to be informative in editor tooltip (at least IDLE shows, but code must be run or imported … | |
Do you work with datasheets regularly ? Always getting .pdf files open in your browser and having to wait EONs for them to download/display ? Well here is a resolve for that most frustrating of problems with Adobe's "Handy file intercept" feature. Use this script to FORCE the browser to … | |
This is an automated system for Bank Management. It uses files to handle the daily transactions, account management and user management. Nice graphical layout and mouse functionality. Manager can add, edit and delete the users and manage the user accounts. Code From: <URL SNIPPED> | |
Also demonstrate changing the text of the widgets label dynamically. | |
In my current project we need to provide drag&drop functionality of items from left to right and vice-versa and on click of the button send array of item IDs to server. Main problem was that we couldn't get array across to server and online examples that we found did not … | |
Drawing on a Form does not always happen when you want it. The Refresh() method of a control comes in handy here. See the following snippet and experiment by commenting out the Refresh. Start a new WindowsForm project. From the toolbox, add a Label, ProgressBar and Button control on the … | |
Heres a code that allows you to manually change the sensitivity of the mouse by using windows hooks. | |
Most people would do something like this: [icode]input("Press any key to continue") #or raw_input[/icode] This way, if the user presses a key other than the Enter (return) key, then the program will still continue. It looks something like this: [URL="http://i42.tinypic.com/2yvp9hj.png"]http://i42.tinypic.com/2yvp9hj.png[/URL] | |
Since no one has posted in this forum as of yet, I decided to tap out a quick scheme. This program, when run through the Mr Ed part of dr scheme available from [url]www.drscheme.org[/url] , will cause a window to pop up with text and a button. By clicking the … | |
This simple class encapsulates the exAnimatewindow api call. I got tired of adding all the jazz to every form I need to use as a pop up, or any borderless forms I used. (Windows 7 and vista don't animate windows with no border by default) This class could easily be … | |
Looking at the First In First Out (FIFO) data situation. Just like a line at the grocery store check-out. Its counterpart FILO would be like a stack of dinner plates. | |
Hi, I have made an encryption and decryption script for those who want to encode data and decode the encoded data. This script may especially be useful for those who do not have the mbstring library installed as it uses a math grid. So for example you can store the … | |
This particular snippet will display a chessboard in a new frame. Needless to say save it in a file named "chessboard.java". | |
This snippet shows how to open, read, write and close text files. This skeleton can be modified to handle any type of file, from untyped to text to typed files. | |
Swaps Two Elements Of An Array (So that say, indice1's value would become indice2's value, and vice versa). Simple Code Piece Really... | |
A demo of the Tkinter listbox widget that shows you how to create the listbox, make it scrollable, position it within a grid, load it with data from a file, select a line of data with the mouse and display it. Also, sort the lines, add a line, delete a … | |
Imports System.Data Imports System.Data.SqlClient Public Class Form2 Dim myconnection As SqlConnection Dim mycommand As SqlCommand Dim dr As SqlDataReader Dim dr1 As SqlDataReader Dim ra As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click myconnection = New SqlConnection("server=Pakistan;Initial Catalog=Mumtaz;database=Mumtaz") myconnection.Open() mycommand = New SqlCommand("insert into … | |
My friend gave me 10,000+ ROM's for Sega, SNES, NES, and GBA. They where all individually zipped. I go fed up trying to unzip them one by one, and decided to write a script to do it for me. It unzipped about 5,000 in under a minute. Python's zipfile module … | |
Hello All, Can anybody help me, i am having challenges getting collections value into the database Here is my sample code. but is not working at all rather is crashing the applications Dim collections As New System.Enrolment.CustomerBiometricsCollection() collections = Me.PrintCaptureWizard1.ShowDialog() Dim dbs As New DBClass Dim mee As String mee … | |
This is a nice command prompt I wrote up a month ago. It's still in the Beta stages however. Anyways, here's a brief overlay of what it does: 1) Takes user input of a function, creates an x/y table and plots it 2) Change the x-range 3) Graph waves (Main … | |
There seems to be a lot of shuffling going around here lately. So I looked [url=http://en.wikipedia.org/wiki/Shuffling]here[/url] to learn about the Fisher-Yates shuffle etc. But unless my English is not good enough I did not find anything about the way we shuffle a card deck here. Take a deck in your … | |
We take a look at the various functions of module time, counting seconds and milliseconds, measuring the time a simple for-loop takes, inspect a list of time data and ways to display it in a useful manner. An attempt is made to find the day of the week, given a … | |
[CODE] int[][] jaggedArray = (from line in File.ReadAllLines(fileName).Skip(1) select (from item in line.Split('\t').Skip(1) select int.Parse(item)).ToArray()).ToArray(); [/CODE] This is a crazy example. It was sparked by what is probably a homework thread on another forum here, but it is basically reading in a tab-delimitted text file, stripping out the first row … | |
Hi and this function I wrote as part of a larger project and acts exactly like the php explode function. Although there a few slight differences between this function and the php explode function it can easily be tweaked to act identical. Also with this function it does not use … | |
I used [URL="http://www.parallax.com/Store/Education/KitsandBoards/tabid/182/CategoryID/67/List/0/SortField/0/Level/a/ProductID/313/Default.aspx"]Parallax's Basic Stamp Homework Board[/URL] and an [URL="http://www.radioshack.com/product/index.jsp?productId=2909788"]accelerometer[/URL] to use as a mouse. It works better than I thought it would. [URL="http://sourceforge.net/projects/pyserial/"]PySerial[/URL] is used to grab the debugged values from the stamp. The circuit is compiled of two push buttons, 2 LEDs to tell when a button is … | |
The top code is my Loop for the mortgage program. The second code is my Array list for the Mortgage program. Is there a way to combine the 2 to do the following:* Use an array for the different loans. Display the mortgage payment amount for each loan. Then, list … | |
This snippet defines a class LebsegueSet which instances represent sets of real numbers, namely finite unions of intervals. Set theoretical, topological and measure theoretical operations are implemented in pure python. Use freely and enjoy ! | |
Another Small And Simple Function To Take Each Character of a string, and put it into an Array, This helps significantly when you need to sift through a string. This Function Uses The spush (String Push) Function, Also In Code Snippits. | |
this script, made by me, lets you resize an image propotionally! | |
This simple script will copy all music files that were not purchased from the iTunes store to a directory of your choosing. It requires the ID3 module (Created by some person, from somewhere, I forget where, but I DID NOT make this module). The syntax is as follows: [code] ipoddir … | |
| |
Lets say that you are working on a program such like Notepad, for instance. You want to make a Ctrl+S key event to save your work. This is the ONLY way I have found out that does not cause any conflictions at all. In the KeyUp Sub of, leys say, … | |
here is a javascript code for puting a message in your status bar on your website.Just change testing 123 to your message.:) | |
This code snippet convert Number to String in VB6. For instance input 100 will be return as Hundred, It converts upto Core.... | |
[I][COLOR="Red"]This code enables the user to enter a number and finds the prime from 2 to the entered number..Please name it PrimeNumbers.java Hope it'll help u..[/COLOR][/I]:D | |
This program creates 2 methods for convenience: menu() and binaryQ(). The menu method accepts several strings as its parameters. The first of the strings is the question to be displayed at the top of the menu. The following strings are the menu choices. For instance, if you call [icode]Confirmer.menu("What is … | |
Thanks to the MS [ICODE]filter[/ICODE] property that disables Cleartype while applying effects. [B]Instructions:[/B] [LIST=1] [*]Paste the snippet to HEAD section of your document. [*]Paste this HTML to HEAD section of your document: [CODE=CSS] <style type="text/css"> .faded { filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=90); } .okay { filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=100); } </style> [/CODE] [*]Add these class, … | |
Here I have a simple range function that can use floats as steps or increments. In a time test (using Psyco 1.6, python 2.5, and a basic PC), the normal frange function was able to go up to 1,000,000 from 0, by .3 , and finish that in about 0.5929 … | |
You can use Python modules math, wave, and struct to create and save a synthetic sine wave of given frequency and duration (size) ... | |
Greetings, String parsing isn't always an easy task. Especially in cases where you need to split a single string into a great multitude, but also accounting for maximum performance. The following code presented does this task simply. Using precise allocation techniques perform greatly when writing an algorithm to precision. | |
This simple library containing some methods of Ajax. Example about addContent(url, target): With this function you can change the content of the someone DIV tag. E.g: index.php [CODE=php] <html> <head> <title>Untitled Document</title> <script type="text/javascript" src="ajax.js"></script> </head> <body> <div id="test"> <a href="javascript: addContent('test.php', 'content')"> Change </a> </div> <div id="content"> <label> This … | |
Hello! I started to create my own tiny 'framework' mainly built on the socket and the thread module. I haven't been doing too much thread programming before. My problem is that when I try server.waitForConnections(2), at the second connection, it says [code] Unhandled exception in thread started by Error in … | |
Some things you need to know: [LIST] [*]This code is not efficient, if you want a more efficient solution, then turn to the STL algorithm [URL="http://www.cplusplus.com/reference/algorithm/next_permutation/"]next_permutation[/URL]. [*]When there are double characters (i.e. characters which occur multiple times) in the string to permute then some permutations will be generated multiple times. … |
The End.