Format:
Recent snippets for: Al Gonzalez
To Encrypt, run the following from the Visual Studio command prompt: aspnet_regiis -pe "connectionStrings" -app "/AppName" -prov "RsaProtectedConfigurationProvider" To Decrypt, run the following from the Visual Studio command prompt: aspnet_regiis -pd "connectionStrings" -app "/AppName"
32 Views
no comments
var procs = Process.GetProcessesByName("msnmsgr"); if (procs.Length > 0) { var proc = procs[0]; proc.Kill(); }
31 Views
no comments
public static PerpetualEnumerator<T> GetPerpetualEnumerator<T>(this IEnumerable<T> items) { return new PerpetualEnumerator<T>(items); }
35 Views
no comments
using System.Collections; using System.Collections.Generic; namespace nl4net { /// <summary> /// Wraps a standard IEnumerator<T> to provide /// iteration over a generic collection that automatically /// resets to the beginning once it reaches the end. /// </summary>
28 Views
no comments
see http://www.fiddler2.com/fiddler2/
NOTE: When using the Visual Studio Developer Web Server you
will need to do one of the following:
1. Call the web services using http://127.0.0.1.:55555/ (note the period after the 1)
2. Add the following to the Fiddler Rules in OnBeforeRequest function,
remembering to change {machinename} to your computers name
// [CUSTOM] Added to remap call from machine back to localhost
if (oSession.host=="{machinename}:55555"){
71 Views
no comments
public static void Copy(string sourceDirName, string destDirName, bool excludeSubdirectories) { // Style #1: fluent Guard.MethodArgument("sourceDirName").IsNotNullOrEmpty(sourceDirName); Guard.MethodArgument("destDirName").IsNotNullOrEmpty(destDirName, "The destination directory is required!"); // Style #2: lambdas and expressions Guard.Argument.IsNotNullOrWhiteSpace(()=>sourceDirName); Guard.Argument.IsNotNullOrWhiteSpace(()=>destDirName, "The destination directory is required!");
67 Views
1 comments
public class ConsoleSpinner { const int MaxSegmentIndex = 3; readonly char[] _segments = new [] { '\\', '|', '/', '-'}; readonly int _left; readonly int _top; int _curIndex;
116 Views
no comments
// Comparing C# to the "Java’s toLowerCase() has got a surprise for you!" article: // http://javapapers.com/core-java/javas-tolowercase-has-got-a-surprise-for-you/ // ------------------------------------------------------------ // NOTE: C# doesn't seem to exhibit the same issue. // ------------------------------------------------------------ static void Main(string[] args) { // setting Lithuanian as locale System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("lt");
35 Views
no comments
using System; using System.Runtime.Serialization; public class ArgumentExceptionTemplate : ArgumentException { public ArgumentExceptionTemplate() { } public ArgumentExceptionTemplate(string message)
47 Views
no comments
using System; using System.Runtime.Serialization; public class ExceptionTemplate : Exception { public ExceptionTemplate() { } public ExceptionTemplate(string message)
58 Views
no comments
/// <summary> /// Determine if the specified string is blank, where blank is defined /// as null, empty or containing only whitespace characters. /// </summary> /// <param name="value">string to be evaluated</param> /// <returns> /// true if the value is null, empty or contains only /// whitespace characters; otherwise false /// </returns> static bool IsNullOrWhiteSpace(string value)
71 Views
no comments
/// <summary> /// Returns a page worth of items from the specified collection. /// </summary> /// <typeparam name="TSource">the type of the items in the collection</typeparam> /// <param name="source">an IEnumerable>TSource< of items to page</param> /// <param name="pageNumber">the number of the page to return</param> /// <param name="itemsPerPage">the number of items that make up a page</param> /// <returns> /// An IEnumerable>TSource< the contains the specified number of items for the specified pageNumber. /// If pageNumber exceeds the number of available pages, the returned collection will be empty.
66 Views
no comments
@echo off if (%1)==() goto end if not exist %1 goto createEmpty :touch copy /b %1+ > nul echo %1 was touched! goto end :createEmpty type %1>%1 echo %1 was created!
52 Views
no comments
rem Replace {folder} with the folder whose content you want to delete
rem Replace {folderToKeep} with the folder under {folder} you DON'T want to delete
del /F /Q {folder}\*.*
for /D %i in ({folder}\*.*) do if /I NOT (%i)==({folder}\{folderToKeep}) rd /s /q %i
43 Views
no comments
mtsd=for /F "tokens=2,3,4 delims=/ " %i in ('date /t') do set dtName=%k%i%j$Tfor /F "tokens=1,2,3 delims=: " %i in ('time /t') do set dtName=%dtName%_%i%j%k$Tmd %dtName%$Tset dtName=
50 Views
no comments
[alias] # show author and revision number blame = annotate -u -n # clearer Git style diff output dif = diff --git log5 = log --limit 5 log10 = log --limit 10 log25 = log --limit 25
49 Views
no comments
syntax: glob #-- Files *.bak.* *.bak thumbs.db *.msi #-- Directories App_Data/* bin/
139 Views
no comments
@echo off rem Shell wrapper for Mercurial Distributed SCM setlocal rem ######################################## rem NOTES: rem /I flag on if forces case-insensitive comparisons for == rem ######################################## rem ######################################## rem Set the following variables to the
159 Views
4 comments
Sub ToggleMvcBuildViews() DTE.ExecuteCommand("Project.UnloadProject") DTE.ExecuteCommand("OtherContextMenus.StubProject.EditProjectFile") Dim wasSetToTrue As Boolean = SetMvcBuildView(True) Dim wasSetToFalse As Boolean If Not wasSetToTrue Then wasSetToFalse = SetMvcBuildView(False) End If
179 Views
no comments
/// <summary> /// Writes the text (expression body) of the function being called, followed by its output. /// </summary> /// <typeparam name="T">The return type of expression/function.</typeparam> /// <param name="expression"> /// The expression/function to be evaluated and whose output will be displayed. /// </param> /// <remarks> /// Useful in seeing the results of function calls while debugging or /// working on spike solutions (see http://www.extremeprogramming.org/rules/spike.html).
80 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
