This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
namespace Enum.Extensions | |
{ | |
public static class EnumerationExtensions | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jobsOwing = from t in Db.Transactions | |
group t by t.Job into g | |
where g.Sum(t => t.Value) < 0 | |
select new { Job = g.Key, NetPosition = g.Sum(t => t.Value) }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ko.bindingHandlers.typeahead = { | |
init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { | |
$(element).typeahead(); | |
}, | |
update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) { | |
var value = ko.utils.unwrapObservable(valueAccessor()); | |
$(element).data('typeahead').source = value; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ko.validation.configure({ | |
insertMessages: true, | |
decorateElement: true, | |
errorElementClass: 'error', | |
errorMessageClass: 'help-inline' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ko.bindingHandlers.addressAutocomplete = { | |
init: function (element, valueAccessor, allBindingsAccessor) { | |
var value = valueAccessor(), allBindings = allBindingsAccessor(); | |
var options = { types: ['geocode'] }; | |
ko.utils.extend(options, allBindings.autocompleteOptions) | |
var autocomplete = new google.maps.places.Autocomplete(element, options); | |
google.maps.event.addListener(autocomplete, 'place_changed', function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<body> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script> | |
function chaosGame(width, height, numSamplesMax) { | |
var corners = [ | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var connect = new Connect({ | |
apiKey: 'YOUR_API_KEY' | |
}); | |
var purchase = { | |
customer: { | |
firstName: 'Tom', | |
lastName: 'Smith' | |
}, | |
id: '1849506679', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as _ from 'lodash' | |
const camelize = (object: any): any => { | |
if (_.isArray(object)) return _.map(object, camelize) | |
if (_.isPlainObject(object)) return _.chain(object) | |
.mapKeys((value: any, key: any) => _.camelCase(key)) | |
.mapValues((value: any) => camelize(value)) | |
.value() | |
return object | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createSelector, Selector } from 'reselect' | |
import { isNil } from 'lodash' | |
export default function mapSelector<S, A, B>( | |
selector: Selector<S, A>, | |
mapping: (a: NonNullable<A>) => B | |
) { | |
return createSelector( | |
selector, | |
value => { |