eliminate .net lambda expression

I’m assessing a performance issue in my C# .NET web application and have traced the bottleneck to a chained lambda expression. I would like to remove the lambda expression entirely so I can evaluate the performance of each step in the chain however I am relatively new to lambda expressions. Does anyone have any thoughts on how the second lambda express could be refactored into more traditional code so that each step or action can traced?

IEnumerable<OurPerformance> validPerformances = package.TimeFilteredValidPerformances(visitDateAndTime);

IEnumerable<WebPerformance> webPerformances = performanceGroup.RegularNonPassedPerformances
            .Where(performance => validPerformances.Select(perf => perf.PerformanceId).Contains(performance.PerformanceId))                
            .Select(performance =>
                new WebPerformance
                {
                    Date = performance.PerformanceDate.ToJavaScriptDateString(),
                    PerformanceId = performance.PerformanceId,
                    Title = performance.UserFriendlyTitle,
                    ProductionSeasonId = performance.ProductionSeasonId,
                    AvailableCount = performance.AvailableCount
                });

**IEnumerable<WebProduction> webProductions = webPerformances
            .GroupBy(performance => performance.ProductionSeasonId)
            .ToDictionary(grouping => SheddProduction.GetOurProduction(grouping.Key), grouping => grouping.ToList())
            .Select(perfsByProduction =>
                new WebProduction
                {
                    ProductionSeasonId = perfsByProduction.Key.ProductionSeasonNumber,
                    Duration = perfsByProduction.Key.Duration,
                    Title = perfsByProduction.Key.UserFriendlyTitle,
                    Synopsis = perfsByProduction.Key.UserFriendlySynopsis,
                    ThumbnailImage = perfsByProduction.Key.PreviewImage,
                    Performances = perfsByProduction.Value
                });**

read more

eliminate .net lambda expression

I’m assessing a performance issue in my C# .NET web application and have traced the bottleneck to a chained lambda expression. I would like to remove the lambda expression entirely so I can evaluate the performance of each step in the chain however I am relatively new to lambda expressions. Does anyone have any thoughts on how the second lambda express could be refactored into more traditional code so that each step or action can traced?

IEnumerable<OurPerformance> validPerformances = package.TimeFilteredValidPerformances(visitDateAndTime);

IEnumerable<WebPerformance> webPerformances = performanceGroup.RegularNonPassedPerformances
            .Where(performance => validPerformances.Select(perf => perf.PerformanceId).Contains(performance.PerformanceId))                
            .Select(performance =>
                new WebPerformance
                {
                    Date = performance.PerformanceDate.ToJavaScriptDateString(),
                    PerformanceId = performance.PerformanceId,
                    Title = performance.UserFriendlyTitle,
                    ProductionSeasonId = performance.ProductionSeasonId,
                    AvailableCount = performance.AvailableCount
                });

**IEnumerable<WebProduction> webProductions = webPerformances
            .GroupBy(performance => performance.ProductionSeasonId)
            .ToDictionary(grouping => SheddProduction.GetOurProduction(grouping.Key), grouping => grouping.ToList())
            .Select(perfsByProduction =>
                new WebProduction
                {
                    ProductionSeasonId = perfsByProduction.Key.ProductionSeasonNumber,
                    Duration = perfsByProduction.Key.Duration,
                    Title = perfsByProduction.Key.UserFriendlyTitle,
                    Synopsis = perfsByProduction.Key.UserFriendlySynopsis,
                    ThumbnailImage = perfsByProduction.Key.PreviewImage,
                    Performances = perfsByProduction.Value
                });**

read more

Printing prime numbers up to n

I have written some code to ask the user for n, then print the prime numbers up to n. However when I use it, i.e with 10, it only prints the non-prime numbers

 /* Asks for the amount of prime numbers you would like to print, then prints them */

#include <stdio.h>

int main(void)
{
    int n, i, j, check;
    printf("How many prime numbers would you like to print? ");
    scanf("%d", &n);

    for (i = 2; i <= n; i++) {
        check = 0;

        for (j = 2; j < i ; j++) { 
            if (i % j == 0) {
                check = 1;              
                if (check == 1) {
                    printf("%d\n", i);
                }
            }
        }
    }       

    return 0;
}

How many prime numbers would you like to print? 10
4
6
6
8
8
9
10
10

read more

How do I set styles in qTip2 jquery plugin?

I have the following code:

$('a.phonetooltip').qtip({ // Grab some elements to apply the tooltip to
content: {
    text: 'Clicking this link will only work on mobile devices',
    style: { classes: 'qtip-dark' }

}
})

I have been trying for ages to change the default styling to the dark style, but I can’t get it to work. It always shows up with the default style.

On the qTip2 guides it says:

/* Basic styles */
.qtip-light{} /* Light coloured style */
.qtip-dark{} /* Alternative dark style */
.qtip-cream{} /* Cream-esque style, similar to the default */
.qtip-red{} /* Alert-ful red style */
.qtip-green{} /* Positive green style */
.qtip-blue{} /* Informative blue style */

/* CSS3 styles */
.qtip-rounded{} /* CSS3 border-radius class for applying rounded corners to your tooltips */
.qtip-shadow{} /* CSS3 box-shadow class for applying shadows to your tooltips */
.qtip-bootstrap{} /* Twitter Bootstrap style */
.qtip-youtube{} /* Google's new YouTube style  */
.qtip-tipsy{} /* Minimalist Tipsy style */
.qtip-tipped{} /* Tipped libraries "Blue" style */
.qtip-jtools{} /* jTools tooltip style */
.qtip-cluetip{} /* Good ole' ClueTip style */

read more

How do I set styles in qTip2 jquery plugin?

I have the following code:

$('a.phonetooltip').qtip({ // Grab some elements to apply the tooltip to
content: {
    text: 'Clicking this link will only work on mobile devices',
    style: { classes: 'qtip-dark' }

}
})

I have been trying for ages to change the default styling to the dark style, but I can’t get it to work. It always shows up with the default style.

On the qTip2 guides it says:

/* Basic styles */
.qtip-light{} /* Light coloured style */
.qtip-dark{} /* Alternative dark style */
.qtip-cream{} /* Cream-esque style, similar to the default */
.qtip-red{} /* Alert-ful red style */
.qtip-green{} /* Positive green style */
.qtip-blue{} /* Informative blue style */

/* CSS3 styles */
.qtip-rounded{} /* CSS3 border-radius class for applying rounded corners to your tooltips */
.qtip-shadow{} /* CSS3 box-shadow class for applying shadows to your tooltips */
.qtip-bootstrap{} /* Twitter Bootstrap style */
.qtip-youtube{} /* Google's new YouTube style  */
.qtip-tipsy{} /* Minimalist Tipsy style */
.qtip-tipped{} /* Tipped libraries "Blue" style */
.qtip-jtools{} /* jTools tooltip style */
.qtip-cluetip{} /* Good ole' ClueTip style */

read more