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
define('validation', [], function() { | |
return { | |
allPropsSpecifiedMixing: { | |
componentDidMount: function() { | |
var unspecifiedPropKeys = _.difference( | |
_.keys(this.props), | |
_.keys(this.type.propTypes || {}).concat('ref')); | |
if (unspecifiedPropKeys.length) { | |
console.warn('Component ' + |
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
// this script works in linqpad (https://www.linqpad.net/) | |
void Main() | |
{ | |
var day = new DaysRevisions(); | |
day.State.Dump(); | |
day.State.To(LifecycleState.Draft, "me"); | |
day.State.Dump(); | |
day.State.To(LifecycleState.Historical, "me"); | |
} |
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
module domain = | |
type post = { id: Guid; title: string; content: string; author_id: Guid } | |
type author = { id: Guid; name: string; } | |
type crudAction = Create | Update | Delete | |
type change = { action: crudAction; entity: obj; id: Guid } | |
let addPost (p:post) : seq<change> = | |
// do stuff | |
seq { yield {action = Create; entity = box p; id = p.id} } | |
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
/// types | |
type addPersonEvent = { name: string; age: int } | |
type birthdayEvent = { name: string; } | |
type event = | |
| AddPerson of addPersonEvent | |
| Birthday of birthdayEvent | |
type person = { name: string; age: int; joined: DateTime } | |
type aggregateStream = seq<event> | |
/// event stream for person aggregate |
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
/** @jsx React.DOM */ | |
var Hello = React.createClass({ | |
render: function() { | |
return <div>Hello {this.props.name}</div>; | |
} | |
}); | |
React.renderComponent(<Hello name="World"><p>foo</p></Hello>, document.body); |
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
let lToS (l:char list) = System.String.Concat(Array.ofList(l)) | |
let sumString = | |
let parse (l:string) = | |
let guessDelimeter (l:string) = | |
match Seq.toList l with | |
| '/'::'/'::c::'\n'::_ -> c | |
| _ -> Seq.find (fun i -> i = ',' || i = '\n') l | |
let valuePart = (fun (s:string) -> | |
match Seq.toList s with |
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
$ curl --ntlm http://localhost:50695/Scripts/src.js -u : -o src.js |
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
public static class DictionaryExtensions | |
{ | |
public static Dictionary<TKey, TValue> Merge<TKey,TValue>(this Dictionary<TKey, TValue> first, | |
Dictionary<TKey, TValue> second) | |
{ | |
return new[] {first, second} | |
.SelectMany(d => d) // flatten dictionaries to IEnumerable<KeyValuePair<TKey,TValue>> | |
.ToLookup(kvp => kvp.Key, kvp => kvp.Value) // group by key | |
.ToDictionary(g => g.Key, g => g.Last()); // last value wins | |
} |
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
_ = require 'underscore' | |
class SurveyResponse | |
constructor: (@site, @results) -> | |
default_result = | |
'csharp': 0 | |
'fsharp': 0 | |
'haskell': 0 | |
'ruby': 0 |
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
public Markup Home(string name) { | |
return P("Welcome " + name) | |
} | |
public Markup Layout(Markup content) { | |
return Html( | |
Body ( | |
Div(content).attr(new {@class= "content"}) | |
) | |
} |