ASP.NET Cafe
new tricks every week

How to Speed up aspnet_compiler

Monday, 16 November 2009 21:49 by dmitriy

Here is one trick to greatly speedup asp.net compiler. First of all, assume you have enough RAM to give about 512Mb for this. RAM is cheap, so you always can visit store and buy it. And your time is priceless. 

Idea is in creating RAM drive and pointing asp.net compiler temp there. To create RAM drive you need to download following free software

http://www.ltr-data.se/opencode.html#ImDisk

IMDisk - awesome thing. Install it.

Now create ramdrive.cmd somewhere ( for example c:\ramdrive.cmd ) with following content

imdisk -a -s 512Mb -m R: -p "/fs:ntfs /q /y"  

create a shortcut and add it to Startup

Now everytime you start PC you'll see quick console window and you'll got a new drive "R"

Ok. Now you need to change your temp settings

Edit this file: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config  

( I assume that you've Windows installed in C:\Windows . Change path if it's different )

 In this file you need to add attribute to <compilation> tag

After change it should look like this: 

        <compilation tempDirectory="r:/asp.net_temp" > 

That's all. Now you can build your asp.net projects much faster. You can try to point all windows Temp on that RAM drive, but I haven't gone this far yet. 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   ASP.NET | Main
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (1) | Comment RSSRSS comment feed

H.264 vs VP 6 in hd online video

Monday, 2 March 2009 10:00 by dmitriy

What's better for your online video?

VP 6 is faster ( works on most pcs ) and requires only flash player 8. 

The BAD side of VP6 - it's hard ( or even impossible ) to find free (opensource) encoding solution for it. You need to ask on2.com guys to give you their framework or for personal use you can buy something like "Flix Standard" for $39. That's really nothing even for poor blogger.

H.264 is slower. Only last fast pcs can run it without delays. For example, I've old Celeron 2.4 and it can't handle h264, but good with vp6. But my Core2duo is good with h.264. Another problem of h264 is loosing of smoothness on low bitrate. Picture is quite good, but action is not... if you encode 1280x720 with 1Mbit/s bitrate you can see the problems with slow zooms... it jumps. Usually you can play with complicated settings, but in the end it does not matters. The good enough bitrate for h.264 if you are using 1280 x 720 is about 2-3 Mbit/s.

More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Flash | Main
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

MailEnable - How to add new mailbox from code

Tuesday, 10 February 2009 03:49 by dmitriy

Mailenable is quite good Mail Server for windows. It has a free version ( and that's version works good if you don't need WebMail ).

Here is some code to add mailbox to PostOffice.

More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   ASP.NET | C# | Main
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

MS SQL. Get rows in random order.

Monday, 15 September 2008 06:42 by dmitriy

During web development often task is to get some stuff in random order. For example, to display random articles, products, testimonials and so on.

First thing you want to do is to write something like this:

SELECT TOP 10 * 
FROM Articles 
ORDER BY RAND() 

And previous query DOES NOT work. It shows records in regular order. Why? Because RAND() calculated once, not in each row.

The following way works fine:

SELECT TOP 10 * 
FROM Articles 
ORDER BY NEWID() 

That's all. Nice and easy. Not recommended for HUGE tables... but this is crazy to try show something randomly from the huge table. Use other ways. For example sub queries.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Main | SQL
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

Google Chrome fails ACID 3 test and pass ACID 2

Tuesday, 2 September 2008 10:03 by dmitriy

We used this test to try IE 8 sometime ago... it failed. 

http://acid3.acidtests.org/

More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Google | Main
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

Google Chrome Beta Available For Download

Tuesday, 2 September 2008 09:27 by dmitriy

 

 Woo Hoo! Just get it!

http://www.google.com/chrome

Fisrt impression - very fast...

 More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Main
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

23 august FFMPEG Win32 build (updated)

Wednesday, 27 August 2008 06:31 by dmitriy

 

If you don't know what is FFMPEG... you possible don't need this.

Or can check out http://ffmpeg.mplayerhq.hu/ 

More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Main
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

Credit Card number validation in C#. Visa and MC.

Monday, 12 May 2008 12:25 by dmitriy

Credit card numbers are full of magic. First of all not every 16 digit is CC number, but only by number you can know the issuer. So no need to place on the web form "Visa" / "MasterCard" radio button. Ok, so what's interesting. I found two great articles that helped me with this:
http://www.merriampark.com/anatomycc.htm and http://www.beachnet.com/~hstiles/cardtype.html .

And what now ? I just finished small helper class to validate Credit Cards. Here is the source.

[code=csharp]public enum CCType
    {
        VISA, MC
    }

    /// <summary>
    /// Credit card validation.
    /// Supports : VISA and MasterCard
    /// Reference: http://www.merriampark.com/anatomycc.htm
    /// Contains LUHN (mod 10) check
    /// by D.S.
    /// http://aspnetcafe.com
    /// </summary>
    public class CreditCardValidator
    {
        protected string _CardNumber = "";

        public CreditCardValidator(string aCardNumber)
        {
            _CardNumber = aCardNumber.Replace(" ","").Replace("-","");
            ProcessValidation();
        }

        protected bool _IsValid;

        public bool IsValid
        {
            get { return _IsValid; }
            set { _IsValid = value; }
        }

        private CCType _CardType;

        public CCType CardType
        {
            get { return _CardType; }
            set { _CardType = value; }
        }
       
        protected void ProcessValidation()
        {
            bool passRegEx = false;
            bool passIssuer = false;
            bool passLuhn = false;
            IsValid = false;

            do
            {
                // Reg Ex check //
                Regex RegExNumber = new Regex(@"(?<firsttwo>(?<firstone>\d)\d)\d{11,14}");
                Match m = RegExNumber.Match(_CardNumber);
                passRegEx = m.Success;
                if (!passRegEx) break;
                string number = m.Groups[0].Value; // only digits //
                string firstNum = m.Groups["firstone"].Value;
                int firstTwoNum = int.Parse(  m.Groups["firsttwo"].Value );
                passIssuer = (firstNum == "4") || ((firstTwoNum >= 51) && (firstTwoNum <= 55));
                if (!passIssuer) break;
                if (firstNum == "4") CardType = CCType.VISA;
                if ((firstTwoNum >= 51) && (firstTwoNum <= 55)) CardType = CCType.MC;
                // Now make Luhn check //
                passLuhn = LuhnCheck(number);
                if (!passLuhn) break;
                //
                IsValid = true;
            } while (false);          
        }

        /// <summary>
        /// Performs mod 10 check
        /// </summary>
        /// <param name="cardNumber">Card Number with only numbers</param>
        /// <returns></returns>
        protected bool LuhnCheck(String cardNumber)
        {
            int sum = 0;
            int digit = 0;
            int addend = 0;
            bool timesTwo = false;

            for (int i = cardNumber.Length - 1; i >= 0; i--)
            {
                digit = int.Parse(cardNumber.Substring(i, 1));
                if (timesTwo)
                {
                    addend = digit * 2;
                    if (addend > 9)
                    {
                        addend -= 9;
                    }
                }
                else
                {
                    addend = digit;
                }
                sum += addend;
                timesTwo = !timesTwo;
            }

            int modulus = sum % 10;
            return (modulus == 0);
        }
    }[/code]

The code is quite simple. But works good for me. I'm not providing you with a sample application, you know there are my credit card number :)

Check the articles at the top of the page if you want to know how it's works. And what is Mod 10 check.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   ASP.NET | ASP.NET | C# | C# | Main | Main
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

Some notes about your video for the web

Wednesday, 7 May 2008 12:26 by dmitriy

Recently faced the problem to quickly insert video inside web page. Here are the things I found and you need if you wish to start with that deal.

First of all, we are going to insert FLV video. But sources in avi or m4v, mov... To convert them we need some kind of converter. Awesome project FFMPEG is best for this. Binaries for windows here: ffmpeg.rev12665.7z (2.46 mb)
Frankly, I forgot the URL to download this, but this file is unchanged.

More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Main | Main
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed

Chess Titans from VISTA - 3 Queens on board.

Wednesday, 9 April 2008 03:51 by dmitriy

Just played Chess :) with 3 Queens.

If you want to make your own 3 queens. You need to: take a black queen and promote as much pawns as you want to Queens!

chess.jpg (96.25 kb)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Main
Actions: E-mail | del.icio.us | Kick it! | DZone it! | Permalink | Comments (0) | Comment RSSRSS comment feed