Skip to content

Instantly share code, notes, and snippets.

Avatar

John Reilly johnnyreilly

View GitHub Profile
@johnnyreilly
johnnyreilly / sh
Last active Feb 21, 2021
markdown blogpost with sed
View sh
// with markdown
npx markdown README.md | sed -e 's|<pre>|<pre class="prettyprint json">|'
// with showdown
npx showdown makehtml -i README.md
View Goals
Goals:
- single page application
- code splitting
- ts-loader?
- react
- TypeScript
- .NET backend (C#)
- swagger
- auto-generated TypeScript client
- continuous deployment
View globalize-localeDisplayNames.js
<!DOCTYPE html>
<!-- saved from url=(0094)http://johnnyreilly.github.io/jQuery.Validation.Unobtrusive.Native/AdvancedDemo/Globalize.html -->
<html lang="en" class=" js flexbox flexboxlegacy canvas canvastext webgl no-touch geolocation postmessage websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Globalize - jQuery Validation Unobtrusive Native</title>
<link href="https://johnnyreilly.github.io/jQuery.Validation.Unobtrusive.Native/Content/
@johnnyreilly
johnnyreilly / comparers.js
Last active Sep 2, 2015
Helper functions for sorting arrays by multiple criteria
View comparers.js
function composeComparers(...comparers) {
return comparers.reduce((prev, curr) => (a, b) => prev(a, b) || curr(a, b));
}
function stringComparer(propLambda) {
return (obj1, obj2) => {
const obj1Val = propLambda(obj1) || '';
const obj2Val = propLambda(obj2) || '';
return obj1Val.localeCompare(obj2Val);
};
@johnnyreilly
johnnyreilly / confirm.html
Last active Dec 29, 2015
Rolling your own confirm mechanism using Q and jQuery UI
View confirm.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Roll your own confirm</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<style type="text/css">
body {
padding: 0em 1em 0em;
}
@johnnyreilly
johnnyreilly / jquery.validate.unobtrusive-remote.js
Last active Dec 22, 2015
jQuery Remote Validation gets unobtrusively driven additional parameters.
View jquery.validate.unobtrusive-remote.js
(function($) {
var originalRemote = $.validator.methods.remote;
$.validator.methods.remote = function(value, element, param) {
param.data = {};
if (param.dataSelector) {
var dataToSend = $(element)
.closest(param.dataSelector)
@johnnyreilly
johnnyreilly / Index.js
Last active Dec 19, 2015
TypeScript and Cassette
View Index.js
/// <reference path="../../typings/jquery/jquery.d.ts" />
// @reference ~/bundles/core
$(document).ready(function () {
var $body = $("#body");
$body.fadeOut(1000, function () {
$body.html('<div style="width: 150px; margin: 0 auto;">I made it all go away...</div>').fadeIn();
});
});
//@ sourceMappingURL=Index.js.map
@johnnyreilly
johnnyreilly / Demo.html
Last active Jun 18, 2018
jQuery Validate - using the native unobtrusive support
View Demo.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
<style>
form { padding: 10px; }
.error { color: red; }
</style>
</head>
@johnnyreilly
johnnyreilly / Index.js
Last active Dec 17, 2015
Cassette and Asset References
View Index.js
// @reference ~/bundles/core
$(document).ready(function () {
var $body = $("#body");
$body.fadeOut(1000, function() {
$body.html(
'<div style="width: 150px; margin: 0 auto;">'+
@johnnyreilly
johnnyreilly / ko.binding.valueNumber.js
Last active Apr 3, 2018
A value number style binding for Knockout made using Globalize for parsing / formatting
View ko.binding.valueNumber.js
ko.bindingHandlers.valueNumber = {
init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
// This will be called when the binding is first applied to an element
// Set up any initial state, event handlers, etc. here
var observable = valueAccessor(),
properties = allBindingsAccessor();
var interceptor = ko.computed({
read: function () {