CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets for: Rick Strahl
FUNCTION GetCollectionFromUrlEncodedValues(lcVars,lcPrefix)
LOCAL loVars, lnX, lnAt, lcPoint,lnEqual,lcKey, lcValue
 
loVars = CREATEOBJECT("wwNameValueCollection")
  
IF EMPTY(lcPrefix)
    lcPrefix = ""
ENDIF
  
lcPointer = "&"+lcVars
by Rick Strahl   May 11, 2012 @ 8:20pm
Tags: FoxPro
10 Views
no comments
 
C#
/// <summary>
/// This method is used to write out attribute values using
/// some funky nested tuple storage.
/// 
/// Handles situations like href="@Model.Entry.Id"
/// 
/// This call comes in from the Razor runtime parser
/// </summary>
/// <param name="attr"></param>
/// <param name="tokens"></param>
by Rick Strahl   May 04, 2012 @ 5:05pm
193 Views
no comments
 
<html>
<head>
    <link href="scripts/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css" rel="stylesheet"
        type="text/css" />        
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        
    <link href="Css/Reset.css" rel="stylesheet" type="text/css" />
    <link href="Css/Standard.css" rel="stylesheet" type="text/css" />    
    <link href="Css/Classifieds.less.css" rel="stylesheet" type="text/css" />
by Rick Strahl   May 02, 2012 @ 8:29pm
Tags: plUpload, Bug
35 Views
no comments
 
C#
    public static class NetworkUtils
    {
 
        /// <summary>
        /// Retrieves a base domain name from a full domain name.
        /// For example: www.west-wind.com produces west-wind.com
        /// </summary>
        /// <param name="domainName">Dns Domain name as a string</param>
        /// <returns></returns>
        public static string GetBaseDomain(string domainName)
by Rick Strahl   April 24, 2012 @ 8:49pm
209 Views
no comments
 
C#
// Predicate Builder code
// Produces match only on LAST match - INCORRECT
var predicate = PredicateBuilder.False<Entry>(); 
foreach (string phrase in searchPhrases)
{
    predicate = predicate.Or(ent => (ent.Title.Contains(phrase) || ent.Keywords.Contains(phrase) || ent.Description.Contains(phrase)));
}
entries = entries.AsExpandable().Where(predicate);
 
by Rick Strahl   April 10, 2012 @ 3:41pm
59 Views
no comments
 
C#
if (searchPhrases.Count() > 0)
{
    var whereParms = new List<string>();
    StringBuilder sb = new StringBuilder();
    int counter = 0;
    foreach (string phrase in searchPhrases)
    {
        string num = counter.ToString();
        
        sb.Append("title.Contains(@" + num + ") || " + 
by Rick Strahl   April 09, 2012 @ 9:09pm
Tags: LINQ, EF, Query, OR
224 Views
no comments
 
C#
// search all search phrases
foreach(string phrase in searchPhrases)
{
    if (parms.SearchDescription)
        entries = entries.Where(ent => (ent.Keywords.Contains(phrase) || ent.Title.Contains(phrase) || ent.Description.Contains(phrase)) );
    else
        entries = entries.Where(ent => (ent.Keywords.Contains(phrase) || ent.Title.Contains(phrase) ) );
}
by Rick Strahl   April 09, 2012 @ 7:52pm
Tags:
206 Views
1 comments
 
C#
/// <summary>
/// This method is used to write out attribute values using
/// some funky nested tuple storage.
/// 
/// Handles situations like href="@Model.Entry.Id"
/// 
/// This call comes in from the Razor runtime parser
/// </summary>
/// <param name="attr"></param>
/// <param name="tokens"></param>
by Rick Strahl   April 06, 2012 @ 8:26pm
221 Views
no comments
 
C#
void Main()
{
    Environment.Version.ToString().Dump();
    Environment.Version.Build.Dump();
    Environment.Version.Revision.Dump();
    Environment.Version.Major.Dump();
    
    IsDotNet45().Dump();
}
by Rick Strahl   April 02, 2012 @ 3:00pm
Tags: CLR, Version
158 Views
no comments
 
SQL
-- generated from  Context.ReportedAbuses.Where(ab => ab.EntryId == entryId).Count() > 0;
exec sp_executesql N'SELECT 
[GroupBy1].[A1] AS [C1]
FROM ( SELECT 
    COUNT(1) AS [A1]
    FROM [dbo].[ReportedAbuses] AS [Extent1]
    WHERE [Extent1].[EntryId] = @p__linq__0
)  AS [GroupBy1]',N'@p__linq__0 int',@p__linq__0=3
 
by Rick Strahl   March 29, 2012 @ 6:59pm
239 Views
1 comments
 
C#
using System;
using System.IO;
using System.Net;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Web;
 
namespace Thinktecture.Web.Http.Formatters
{
by Rick Strahl   March 22, 2012 @ 2:52am
Tags: WebAPI
63 Views
no comments
 
C#
// this will never get called with JSON/XML content body   
// parameter works from route or query string but not complete content
public string  ReturnString(string message)
{            
    return message;
}
 
// Using [FromBody] is required to make this work
public string  ReturnString([FromBody] string message)
{            
by Rick Strahl   March 21, 2012 @ 2:56pm
Tags: WebAPI
156 Views
no comments
 
C#
// JavaScript Code
$().ready(function () {
 
    ajaxCallMethod("CallbackHandler.ashx?", "GetDate",
    [{ Name: "Rick", Entered: new Date(2012,0,1) }],
    function (result) {
        alert(result);
    });
 
    ajaxCallMethod("CallbackHandler.ashx?", "GetDate",
by Rick Strahl   March 19, 2012 @ 4:38pm
104 Views
no comments
 
 ajaxCallMethod("CallbackHandler.ashx?", "Test",
             [{ Entered: "03/15/2010", Name: "Rick"}],
             function (result) {
                 alert(result);
             });
ajaxCallMethod("CallbackHandler.ashx?", "Test",
             [{ Entered: new Date(2010,2,15), Name: "Rick"}],
             function (result) {
                 alert(result);
             });
by Rick Strahl   March 19, 2012 @ 2:10pm
57 Views
no comments
 
C#
using System;
using System.Net.Http.Formatting;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Json;
using System.IO;
 
namespace Westwind.Web.WebApi
{
    public class JavaScriptSerializerFormatter : MediaTypeFormatter
by Rick Strahl   March 08, 2012 @ 5:17pm
378 Views
no comments
 
C#
var reader = new StreamReader(HttpContext.Current.Server.MapPath("~/symbollist.txt"));
 
string current = string.Empty;
while(current != null)
{
    current = reader.ReadLine();
    if (current == null)
        continue;
 
    var tokens = current.Split(',');
by Rick Strahl   March 07, 2012 @ 1:24pm
Tags:
59 Views
no comments
 
@model ClassifiedsWeb.EntryViewModel
 
@{    
    ViewBag.Title = "New Message"
}
 
...
    <div class="fieldarea">
        <!--  this always renders 'New Message' rather than 
              Model.Entry.Title -->
by Rick Strahl   February 25, 2012 @ 2:24pm
Tags: Razor, Bug
308 Views
no comments
 
<div id="PostItemContainer" style="height: 300px;overflow-y: scroll;">
    @{
        int catId  = -1;
        foreach (var entry in Model)
        {         
            if (catId != entry.Category.Id) 
            {                
              <div class="listcategoryheader">@entry.Category.Name</div>
              <text><div class="listcategorycontent"></text>
            }
by Rick Strahl   February 22, 2012 @ 6:52pm
316 Views
no comments
 
C#
// this code requires a reference to JSON.NET in your project
#if true
 
using System;
using System.Net.Http.Formatting;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Json;
using Newtonsoft.Json;
using System.IO;
by Rick Strahl   February 21, 2012 @ 6:23pm
669 Views
no comments
 
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Dynamic;
using System.Reflection;
using System.Collections;
 
namespace Westwind.Utilities.Dynamic
{
    /// <summary>
by Rick Strahl   January 31, 2012 @ 5:48pm
Tags: C#, Expando, MixIn
569 Views
2 comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate