Skip to content

Instantly share code, notes, and snippets.

@karlitros
karlitros / PredicateBuilderExample
Created February 20, 2015 17:36
An example of how you can use predicate builders
var predicate = PredicateBuilder.False<Donation>();
var selectedItemList = new List<string>();
foreach (ListItem item in lstfilter_keywords.Items)
{
if (item.Selected)
{
predicate = predicate.Or(p => p.Keywords.name.ToLower().Contains(item.Value.ToLower()));
@karlitros
karlitros / CheckForConsole.js
Created February 20, 2015 17:22
Checks to see if console exists before writing to it. IE9 doesn't have a console when the console window is closed.
function reportError(errorMessage)
{
if(console != undefined) {
console.log(errorMessage);
}
else {
alert(errorMessage);
}
}
@karlitros
karlitros / CORS_Web.Config(2)
Created February 20, 2015 17:13
A snippet of the web.config that partly enables CORS
<webServices>
<protocols>
<add name="HttpGet" />
<add name="HttpPost"/>
@karlitros
karlitros / CORS_Web.Config
Created February 20, 2015 17:12
A snippet of the web.config that partly enables CORS
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=9" />
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
</customHeaders>
@karlitros
karlitros / CheckWindowConsole.js
Created September 18, 2014 16:08
Check to make sure window.console is not undefined before writing to console.log for Internet Explorer
if(window.console != undefined)
{
console.log('test!');
}
@karlitros
karlitros / bindWithDelayExample.js
Last active August 29, 2015 14:02
Demonstrates how bindWithDelay could be used for validating a password after the user's finished entering it
$("input.myTextField").bindWithDelay("keyup", function() {
console.info('We\'re now ready to validate the password');
passwordValidationFunction(this.val());
}, 1000);
@karlitros
karlitros / UmbracoSitemapProviderReference.xml
Last active August 29, 2015 14:00
Comment this bit out of an umbraco web.config file when you want publishing times to improve when publishing large amounts of content
<siteMap defaultProvider="UmbracoSiteMapProvider" enabled="true">
<providers>
<clear />
<add name="UmbracoSiteMapProvider" type="umbraco.presentation.nodeFactory.UmbracoSiteMapProvider" defaultDescriptionAlias="description" securityTrimmingEnabled="true" />
</providers>
</siteMap>
using System.Collections.Generic;
using System.Globalization;
public static IEnumerable<string> GetCountryList()
{
List<string> cultureList = new List<string>();
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
foreach (CultureInfo culture in cultures)
@karlitros
karlitros / HSSFTextbox.cs
Created October 19, 2012 12:51
Creates a textbox for NPOI, and puts something in it.
HSSFTextbox myTextBox = _patriarch.CreateTextbox(anchorpoint) as HSSFTextbox;
myTextBox.String = new HSSFRichTextString("Your text goes in here!");
@karlitros
karlitros / IClientAnchor.cs
Created October 19, 2012 12:45
Creates an anchor point that your textbox will belong to.
IClientAnchor anchorpoint = new HSSFClientAnchor(0, 0, 1023, 255, startingColNum, startingRowNum, endColNum, endRowNum);