Skip to content

Instantly share code, notes, and snippets.

View sotirisf's full-sized avatar

Sotiris Filippidis sotirisf

View GitHub Profile
@sotirisf
sotirisf / Parse Delimited Strings
Created February 23, 2015 19:54
UDF that gets a delimited string and returns a table variable with the values of the string as rows
CREATE Function [dbo].[fn_ParseDelimitedStrings]
(
@String nvarchar(max),
@Delimiter char(1)
)
Returns @Values Table
(
RowId int Not Null Identity(1,1) Primary Key,
Value nvarchar(3000) Not Null
)
@sotirisf
sotirisf / Match at least one element from a comma delimited string with a second comma delimited string
Last active August 29, 2015 14:15
Compares two comma delimited strings in order to find at least one matching element (an element both strings contain)
/// <summary>
/// Compares two comma delimited strings in order to find at least one matching element
/// </summary>
/// <param name="sourceElements">The first comma delimited string</param>
/// <param name="searchElements">The second comma delimited string</param>
/// <returns>True if there is at least one match</returns>
public static bool MatchesAtLeastOne(this string sourceElements, string searchElements)
{
if (string.IsNullOrEmpty(sourceElements) || string.IsNullOrEmpty(searchElements)) return false;
@sotirisf
sotirisf / Update Querystring Parameter
Last active August 29, 2015 14:15
Updates a querystring parameter with a new value
/// <summary>
/// Updates a querystring parameter with a new value
/// </summary>
/// <param name="req">The HTTPRequest object</param>
/// <param name="parameterName">The parameter name to update</param>
/// <param name="parameterValue">The new value for the parameter</param>
/// <returns></returns>
public static string UpdateQueryString(HttpRequest req, string parameterName, string parameterValue)
{
@sotirisf
sotirisf / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@sotirisf
sotirisf / Comma Delimited List from IPublishedContent IDs
Last active August 29, 2015 14:15
Create a comma-delimited list from an IEnumerable collection of Umbraco IPublishedContent Ids
var storedVal = content.Aggregate<IPublishedContent, StringBuilder, string>(
new StringBuilder()
, (sb, x) => sb.Append(x.Id).Append((content.Last().Id==x.Id) ? "" : ",")
, (sb) => sb.ToString()
);