2,322 Reusable Code Snippet Topics
Remove Filter ![]() | |
I borrowed this from C#, where you can easily send output, that normally goes to the ugly black console window, to a nice looking Windows MessageBox with an OK button to close after you read your results. You can accumulate your output in a string to send to one message … | |
 I was tired of always looking for a way to underline labels like in Windows property dialogs. I created this little control that allows you to set a two-tone line above, below behind or in front of a label (even through it!) to solve that problem. The image … | |
Gribouillis has allready posted code similar to this in his snippets, but here version for input suitable for for expressions, generators and list comprehensions. Need to add robustness by some try...except blocks for real world use. | |
This code snippet provides methods to convert between various ieee754 floating point numbers format. For example double precision to single precision. The format is given by a pair (w, p) giving the size in bits of the exponent part and the significand part in the ieee754 representation of a number … | |
I get tired of having to google this simple line of code all the time. My problem with memorizing it is that I switch back and forth between C# and C++ all the time, and the way you overload operators in each is different. So once I learn one again, … | |
This came up, maybe it is usefull to somebody. Later I plan to do a managing context interface to `with`statement for this. | |
Here slightly edited code from one of my earliest posts to DaniWeb. Limitted by recursion limit of Python as it uses recursion, but interesting for me. | |
Here is my take on [balanced ternary](http://en.wikipedia.org/wiki/Balanced_ternary) conversion (the base considered by [Donald Knuth](http://en.wikipedia.org/wiki/Donald_Knuth) "Maybe the prettiest") | |
Here is base conversion function written to deal also with [negative bases](http://en.wikipedia.org/wiki/Negative_base). Not yet balanced ternary, where numbers themselves can be negative, maybe later I add it.. Based on the code in the wikipedia article, which has bug for converting 0.[**Edit: I fixed the bug in wikipedia**] | |
Hello, Many guys have been asking for this sort of sms scripts! Any way i have created one for personal use but i am sharing here :) Things you need [LIST] [*]An Account in tm4b.com and PHP 5. [*]cURL or allow_url_fopen enabled in php.ini [/LIST] - [URL="http://jhbalaji.com"]Balaji J H[/URL] | |
So, basically im using the codea bove to generate coordinates for a grid, but I only want to generate coordinates for the "outer ring" of a square. SO imagine a grid of 7x7, I won't generate coordinates for the inner 5x5 square, only for the outer ring. Basically I drew … | |
I realize I haven't released anything in a while so I figure I'll just type a basic set of things for you all to use or learn from. All of the following requires XNA Framework, but can be easily ported over to .NET Framework for use with forms applications. The … | |
I have Excel like #EmpId EmpName ProjName Date JiraId ***Thursday, March 01, 2012***# 1 test3 Project Name 4/11/2012 1810 5 2 test4 Project Name2 4/11/2012 1810 6 when I read data to DataTable the result will be like #EmpId EmpName ProjName Date JiraId ***40969***# 1 test3 Project Name 4/11/2012 12:00:00 … | |
I wrote a linked list program in C++ which compiles and works well. But I have been told that a) I have to have two separate structs instead of one that contains both the info and the node; and, b) that I have to use two pointers instead of the … | |
We know we already have built-in [I]Trim methods[/I], but trimming doesn't get rid of internal, (and unwanted) extra spaces. -So this is where Normalize method comes to play. It trims left, it trims right, but most importantly it also trims on the inside, one could say: "it trims inside-out". In … | |
Simply enough: Call the function, get the returned filename. Function Variables: $file : The input file (source/background) $destination : Where you want the new watermarked image to go $overlay : The overlay image (foreground), this is default set (if not passed in) to "images/watermark.png" $X : X-Position of overlay (default … | |
Have you ever needed to open a file with your VB program? Here's a way to easily do it. (code copied from an original program written by Mike B) If the program that uses the file is installed on your workstation, the file will be opened in that application. I … | |
This snippet explores the change of a hexadecimal (base 16) string to a denary (base 10) integer and the reverse. Interestingly Python allows the representation of the hexadecimal string in two different forms. For instance 255 can be changed to 'FF' (also 'ff') or '0xff'. Any of these hexadecimal strings … | |
Start a new console application and fill in the about 70 lines of code in the Program.cs file. Run and enjoy! | |
Get the Driver's Name, Path, Description, Status, and Start Mode | |
Sometimes, before optimizing your code, you may end up to have very slow running code in list comprehension statement. Because you have not yet tested the code fully, it easy to loose patience and just interrupt the code. If you are making function, you can insert print statements for verification. … | |
this program contains a template function that can calculate determinant of any n by n matrix using permutations. it can be run in Visual C++ 2010 Express. | |
Again, for anyone working with ID3 version 1 or 1.1 tags. This class is used to store the tags associated with a given file. There is a default constructor in case you need to instantiate an 'empty' instance, but in 99% of cases you pass the filename of the audio … | |
For anyone working with ID3 version 1 or 1.1 tags in audio files, this static class may come in handy. It uses indexers to convert between the textual to the numerical representation or from numerical to textual and also accounts for unset and invalid values. Being static, it is always … | |
[I][COLOR="Green"]!below is the code snippet [/COLOR][/I] This is a multi-use property toggler. In the given example we are toggling a sub property of an element. e -is the property owner to be targeted; p - is the property name to be set; v - is the property value; henceforward changing … | |
Just a quick snippet for beginners | |
This Code is easy way to load / show data in Datagrid. This Code write in vb.net 2003 and use sqlserver 2000 as database. I use module to connected VB.Net with SqlServer 2000. so the function to connected can be use in every form in this project. | |
I have seen several posters asking for help on programs converting an Infix expression to a Postfix one. I have written a program to convert a simple Infix expression to a Postfix one so that people here can be directed towards some sample code from which they get the idea … | |
All the webpage data will be converted into PDF file, You can also add details such as ur name etc by using Chunk chunk1 = new Chunk("By Vishal RAne, [email]vishalrane50@example.com[/email] \n",FontFactory.GetFont("Verdana", 8)); The pdf will be saved on desktop.... u can change location by using PdfWriter.GetInstance(Doc, new FileStream(Environment.GetFolderPath (Environment.SpecialFolder.Desktop)+ "\\VishalRane.pdf", … | |
Ever Thought if it was possible to not WebBrower control and use the Firefox Browser in your c# window Application...?? Yes ,, It is possible using GeckoFx wrapper class for C#.net and vb also. You will need the Followings: 1. [URL="http://code.google.com/p/geckofx/downloads/list"]GeckoFx Wrapper[/URL] 2. [URL="http://mirrors.directorymix.com/mozilla/xulrunner/releases/1.9.1.2/runtimes/"]Xul Runner[/URL] (Download the zip file from … | |
here is my code i want update the two fields without refreshing whole page.... | |
I hate websites that timeout and don't let you know about it this script pops up a message when you timeout and allows you to re-login in place | |
The code shows a fast prime number generator using a sieve algorithm. It looks at only odd numbers. Technically 1 and 2 are prime numbers too, since they are only divisible by unity and themselves, exceptions are made for 1 and 2. Zero and negative numbers return an empty list. … | |
While surfing the web I got to this site: [url]http://en.wikipedia.org/wiki/Fourier_series[/url] “Hey, I why not write something like this in C#!” The rather scary looking formulas did not withhold me to start coding (see below Fig. 1 and Fig. 2) The formula from Fig. 2 is hidden under one of the … | |
I discovered and installed a firefox addon called Remote Control. This addon starts a telnet server which lets you send javascript commands to the firefox web browser. Combined with python telnetlib module, it becomes very easy to reload or change the content of a tab in a running firefox from … | |
Hi, This code checks the availability of username from the database. | |
Query your datatable like sql's "select distinct" statement | |
These two functions compute the orders of the lowest bit and the highest bit set in the binary representation of an integer. I expect them to handle securely very large integer values. | |
below is a very simple encryption class which shows how to encrypt sensitive data (very simply) this example converts a string to hexadecimal form and back again with some simple error handling. please leave some feedback if you find this useful | |
Hay guys, i wanted to get the code for a very large factorial but i was unable to do so. Now, i had to work and develop the code myself, which i did. This code calculates factorial of numbers uptil 14000. . i havent tried more. But i guarantee this … | |
I've written a program to add two hexadecimal numbers ... Njoy ! tux4life | |
I haven't tested this yet but it should work. The implementation is fairly simple. I don't have my laptop so I can debug the code at the present time. This basically increments the frame count everytime the game draws itself (allowing us to calculate frames per second considering the draw … | |
I've developed a simple class and enum that will make ammunition creation and usage simpler in game development for those who are interested. I will be making a tutorial video on how I made this so that you will fully understand how the code works if you do not. Simply … | |
I used a label inside my snippet just to test it; but this will simply increment and decrement a float value by 0.2f between the values specified in the conditionals. I have it updating between 8f and 15f. Must be run on a timer (make sure the interval is low … | |
Just came across a code of compressing file thought to share :). Code for text file only can be changed for other filetypes....It reduces nearly 97% of the file size ... [CODE]OpenFileDialog opd = new OpenFileDialog(); FolderBrowserDialog fbd = new FolderBrowserDialog(); textBox1.Text="Path + File To compress";//open file by open file … | |
Take a look at a typical Windows GUI frame (form) with a menubar, statusbar, panel, label and buttons. Set the font and size of text, click the buttons to create some events. All of this and much more is in the free wxPython package. | |
There only two glitches within this code that I can't seem to get 100% spot on. However, this will create a functioning menu (text based) on your form at runtime. I plan to develop an actual control exactly like it. It uses a custom class I developed called LocationBounceEffect that … | |
Short snippet on how you could remove all occurrences of a char from a string using LINQ. | |
XNA Game Studio is not required to use this functionality. This example is very basic, and I typed it up because I was bored. It does not contain functionality for navigation through the menu, but it will display the menu as it should at the specified location. Please enjoy it, … | |
eg. 14 and 15 Find all the factors of 14 and 15. 1,2,7,14 are factors of 14 1,3,5,15 are factors of 15 Sum all the factors of two numbers and if sum of factors of two numbers taken are respectively equal they are Amicable numbers. |
The End.