Skip to content

Instantly share code, notes, and snippets.

Dominique domenu

Block or report user

Report or block domenu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@domenu
domenu / Startup.cs
Last active Feb 14, 2020 — forked from GiorgioG/Startup.cs
Snake Case support for Swashbuckle w/ ASP.NET Core 3.0
View Startup.cs
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// ...
services.AddControllers().AddJsonOptions(options =>
{
options.JsonSerializerOptions.PropertyNamingPolicy = new SnakeCasePropertyNamingPolicy();
});
@domenu
domenu / add-prop.ts
Created Jan 14, 2020
Add a prop to an existing type, located in a Typescript module
View add-prop.ts
declare module 'path/to/the/module/file.ts' {
interface ClassNameInModule {
id: number;
}
}
@domenu
domenu / gist:246374c61f137a7e78865aefdac82b0b
Created Dec 18, 2018
Remove all folders with a specific name recursively on Windows
View gist:246374c61f137a7e78865aefdac82b0b
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"
View gist:bf59c55d93e566b21e25
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>
View gist:b932f48bac76ec5b95b3
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));
}
@domenu
domenu / gist:7801886
Created Dec 5, 2013
Resets the form's jQuery unobtrusive validation after elements where added dynamically to the form
View gist:7801886
// 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:7785602
Created Dec 4, 2013
Tablesorter: sort checbox columns
View gist:7785602
// 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"
You can’t perform that action at this time.