Skip to content

Instantly share code, notes, and snippets.

@ciarancolgan
ciarancolgan / gist:f9e6543ada52f8be290539b93e57c7b6
Last active July 25, 2017 12:32
Handle if Footable column is marked as HTML but doesn't contain HTML markup and value contains special chars
parser: function (valueOrElement) {
if (F.is.string(valueOrElement)) {
// UPDATE HERE: Added a check to see if the element is marked as html, but isnt actually a HTML tag. If so, add a span tag around it.
if (!valueOrElement.startsWith('<')) {
valueOrElement = "<span>" + valueOrElement + "</span>";
}
valueOrElement = $($.trim(valueOrElement));
}
.............
@ciarancolgan
ciarancolgan / gist:f71450bf6d82327baf1d64cd96f78a7a
Last active June 30, 2017 13:13
Adding a switch to Footable.js to allow the use of sessionStorage instead of localStorage to preserve state
- HTML DATA ATTRIBUTES REQUIRED:
- In your footable html <table> tag, add the attributes:
... data-state="true" data-state-sessionstorage="true" data-state-sessionstorageexpiration="5" ...
- JS CHANGES TO FOOTABLE.JS REQUIRED:
1) In the State 'preinit' function, add:
// Determine whether to use localStorage for state preservation or sessionStorage.
self.isSessionStorage = F.is.defined(data.stateSessionstorage) && F.is.boolean(data.stateSessionstorage)
? data.stateSessionstorage
// Add this to a Js file that loads after jquery.validate.js.
// Override the 'focusInvalid' function from jquery.validate.js to a custom function which includes setting the focus for chosen dropdowns
$.validator.prototype.focusInvalid = function () {
if (this.settings.focusInvalid) {
try {
$(this.findLastActive() || this.errorList.length && this.errorList[0].element || [])
.filter(":visible")
.focus()
// manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find
.trigger("focusin");
@ciarancolgan
ciarancolgan / Extension to @ondravondra 's: "C# extension for executing upsert (MERGE SQL command) in EF with MSSQL"
Last active November 19, 2018 09:42
EF6 extension to perform an UPSERT. Original here: https://gist.github.com/ondravondra/4001192. This is actually an extension of a fork from this by @x4m, which allowed for an IEnumerable to be passed in. This version contains the additions: i) Get the name of the primary key for the table from the EntityContainerMapping as we wish to exclude th…
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Core.Mapping;
using System.Data.Entity.Core.Metadata.Edm;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
@ciarancolgan
ciarancolgan / Nullable_Value_vs_GetValueOrDefault
Created January 18, 2014 16:05
Trying to call the 'Value' property of Nullable parameters vs GetValueOrDefault
namespace Test
{
class Program
{
static void Main(string[] args)
{
int? nullableInt = null;
int? nullableInt2 = 1;
SeeIfThisWorks(nullableInt, nullableInt2);
}