Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View domenu's full-sized avatar

Dominique domenu

View GitHub Profile
@domenu
domenu / gist:7785602
Created December 4, 2013 10:43
Tablesorter: sort checbox columns
// add tablesorter parser to be able to sort on checkboxes
$.tablesorter.addParser({
id: 'checkbox',
is: function (s, table, cell) {
return $(cell).find('input[type=checkbox]').length > 0;
},
format: function (s, table, cell) {
return $(cell).find('input:checked').length > 0 ? 0 : 1;
},
type: "numeric"
@domenu
domenu / gist:7801886
Created December 5, 2013 08:21
Resets the form's jQuery unobtrusive validation after elements where added dynamically to the form
// Resets the form's jQuery unobtrusive validation after elements where added dynamically to the form
(function ($) {
$.fn.resetUnobtrusiveValidation = function () {
// dynamically added element with unobtrusive validation attributes that was added to the form
var $this = $(this);
// remove unobtrusive validator from the elmement's form
var form = $this.closest("form")
.removeData("validator")
.removeData("unobtrusiveValidation");
// parse the form again, validation is picked up for all elements (also dynamically added elements)
@domenu
domenu / gist:b932f48bac76ec5b95b3
Created November 5, 2014 12:27
Change namespace in XML
XNamespace ns = "http://mycompany/myproduct/v2";
foreach (XElement el in document.Root.DescendantsAndSelf())
{
el.Name = ns.GetName(el.Name.LocalName);
List<XAttribute> atList = el.Attributes().ToList();
el.Attributes().Remove();
foreach (XAttribute at in atList)
{
el.Add(new XAttribute(ns.GetName(at.Name.LocalName), at.Value));
}
public static class HtmlExtensions
{
public static IHtmlString DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression,
Dictionary<string, IEnumerable<SelectListItem>> selectList)
{
/*
* <select name="tmodel">
* <optgroup label="Items">
* <option value="item">Item</option>
* </select>
@domenu
domenu / gist:246374c61f137a7e78865aefdac82b0b
Created December 18, 2018 14:46
Remove all folders with a specific name recursively on Windows
To see which folders will be deleted:
FOR /d /r . %d in (node_modules) DO @IF EXIST "%d" echo %d"
And then to actually delete them, just run this:
FOR /d /r . %d in (node_modules) DO @IF EXIST "%d" rd /q /s "%d"
@domenu
domenu / add-prop.ts
Created January 14, 2020 11:18
Add a prop to an existing type, located in a Typescript module
declare module 'path/to/the/module/file.ts' {
interface ClassNameInModule {
id: number;
}
}
@domenu
domenu / Startup.cs
Last active July 13, 2020 17:56 — forked from GiorgioG/Startup.cs
Snake Case support for Swashbuckle w/ ASP.NET Core 3.0
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// ...
services.AddControllers().AddJsonOptions(options =>
{
options.JsonSerializerOptions.PropertyNamingPolicy = new SnakeCasePropertyNamingPolicy();
});