Save Our Tigers
Yesterday, I saw a commercial on Saving Tigers in India. I have already pledged my support for the cause and urging everyone to do the same.
Yesterday, I saw a commercial on Saving Tigers in India. I have already pledged my support for the cause and urging everyone to do the same.
If you want to import data from an excel sheet then use this (the first row will be taken as column headers):
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Excel.xls; Extended Properties=""Excel 8.0; HDR=Yes; IMEX=1"""
If you want to export data to an excel sheet then use this:
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Excel.xls; Extended Properties=""Excel 8.0;"""
Download: DLL, Code, Zip
There are many ways to do it. You can use the WebProxy class. But the easiest way is to specify the defaultProxy element in your application’s configuration (web.config or app.config) file. The following example uses the defaults from the Internet Explorer proxy, specifies the proxy address, and bypasses the proxy for local access and demo.com
Read more
If the proxy requires authentication then there is an additional step. You will need to create a class library consisting of only a single class that implements the IWebProxy interface.
Read more
This function will resize any image (web formats, stream) to desired width and height preserving the aspect ratio. The returned image format is PNG.
public static Image ResizeImage(Stream pImage, int pWidth, int pHeight) { Image imgUploaded; imgUploaded = Image.FromStream(pImage); if (imgUploaded.Width > pWidth || imgUploaded.Height > pHeight) { int Width = 0; int Height = 0; if (imgUploaded.Width == imgUploaded.Height) { Width = pWidth; Height = pHeight; } else { double AspectRatio = 0; if (imgUploaded.Width > imgUploaded.Height) { AspectRatio = (double)imgUploaded.Height / (double)imgUploaded.Width; Width = pWidth; Height = Convert.ToInt32(AspectRatio * pHeight); } else { AspectRatio = (double)imgUploaded.Width / (double)imgUploaded.Height; Width = Convert.ToInt32(pWidth * AspectRatio); Height = pHeight; } } return imgUploaded.GetThumbnailImage(Width, Height, null, IntPtr.Zero); } else { return imgUploaded; } }
The following function will return this long string HyphenLongStringinC#HyphenLongStringinC# as
HyphenLong – StringinC# – HyphenLong – StringinC# (10 chars limit).
public static string HyphenText(string pText, int pLength) { if (pText.Length > pLength) { string[] WordList = pText.Split(' '); string RetVal = ""; string Word = null; for (int i = 0; i < WordList.Length; i++) { Word = WordList[i]; if (Word.Length > pLength) { while (Word.Length > pLength) { RetVal = RetVal + Word.Substring(0, pLength) + " - "; Word = Word.Remove(0, pLength); } if (Word.Length > 0) { RetVal = RetVal + Word + " - "; } RetVal = RetVal.TrimEnd(' ').TrimEnd('-'); } else { RetVal = RetVal + Word + " "; } } return RetVal.TrimEnd(' '); } else { return pText; } }
Example:
HyphenText("HyphenLongStringinC#HyphenLongStringinC#", 10);
The original article is here.
This update allows to optionally specify the linking URL of a page for an image.
var RND = new Array(); RND[0] = new Array( "http://gallery.ramansingla.com/img/pg", "1", "5", "t.jpg", "pic", "3", "Himalayas", "http://gallery.ramansingla.com/himalayas-1.html" ); RND[1] = new Array( "http://gallery.ramansingla.com/img/pg", "6", "9", "t.jpg", "pic", "3", "Himalayas", "" );
Please note that you must specify the last parameter (i.e. the URL). You can specify an empty string if you don’t want to link to any page.
Use this modified script
<script type="text/javascript" language="javascript" src="http://data.ramansingla.com/js/rnd_img_lnk_comp.js"></script>
You wrote a stored procedure, some days pass, now you don’t remember the name of the stored procedure. How to find it?
Just run the following (against the database which contains the forgotten stored procedure):
1 2 3 | SELECT DISTINCT [Name] FROM sysobjects A INNER JOIN syscomments B ON A.[ID] = B.[ID] WHERE A.Type = 'p' AND (B.[TEXT] LIKE '%test%') |
Look carefully at the third line, replace “test” with anything that might be a part of the forgotten stored procedure (it could be table name, variable name, etc.).
Note: You may get a list of stored procedures as the search term might be part of numerous stored procedures.
CPU: Intel Core 2 Duo P8600 (2.40GHz/1066 FSB/3MB Cache)
Graphics: 512MB ATI Mobility Radeon HD 4570 (with HDMI)
Sound: CREATIVE Sound Blaster X-Fi MB
Monitor: 15.6″ 720p WLED (with TrueLife)
RAM: 4GB 667MHz Dual Channel DDR2
HDD: Western Digital 250GB 7200RPM (with Free Fall Sensor)
Power: 85 WHr 9-cell Lithium Ion Battery
Wireless: Intel WiFi Link 5100 (802.11a/g/n)
Bluetooth: Dell Wireless 370
Optical: Slot Load DVD RW 8X
Webcam: Creative 2.0 MegaPixel
Input: Dell Backlit Keyboard with Touchpad + Dell Laser Mouse
OS: Windows 7 Ultimate (with XP Mode)
Community Forums are strange places. Sometimes you find wealth of information along with superb graphics (read avatars and sigs) while other times it’s all crap. Yesterday, I was visiting some hosting forums and was surprised to see a different avatar of a poster with every post. After some thought I developed a small trick using PHP and mod_rewrite (Apache).
To see the demo in action click here (Please hit the F5 key or reload your browser a few times to see the random effect).
Read more
Sometime back I was looking for a small script to display multiple random images from my gallery. After quick searching I decided that it’s better to code it myself. The main goals were
Features:
Requirement:
Just a small requirement that the images in your gallery be named sequentially (ex1.jpg, ex2.jpg, ex3.jpg, …).
Cons:
As it’s javascript, the biggest drawback is the SEO unfriendliness, as search engines won’t parse the javascript and will never see the content.
Demo
Read more