Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Ashton ashtonkj

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am ashtonkj on github.
  • I am ashtonkj (https://keybase.io/ashtonkj) on keybase.
  • I have a public key whose fingerprint is B97C A48C 039B 0181 A3DF B6E6 203B 5112 8471 B8E9

To claim this, I am signing this object:

@ashtonkj
ashtonkj / CustomModelBinder.fs
Created Sep 9, 2014
WebApi Default Args Binder
View CustomModelBinder.fs
type CustomBinder() =
interface IModelBinder with
member this.BindModel(actionContext:HttpActionContext, bindingContext :ModelBindingContext) =
let qs = HttpUtility.ParseQueryString(actionContext.Request.RequestUri.Query)
bindingContext.Model <-
if (qs.AllKeys |> Seq.exists(fun q -> q.ToLower() = bindingContext.ModelName.ToLower())) then
qs.[bindingContext.ModelName] |> Some
else
None
true
View Maybe.fs
type MaybeBuilder() =
member this.Bind(m,f) = Option.bind f m
member this.Return(m) = Some(m)
let maybe = MaybeBuilder()
// Returns Some (querystring) or None if the let! returns None.
let queryString =
@ashtonkj
ashtonkj / SOWatch.js
Created Jul 29, 2014
Stack Overflow Chat - Check for New Users
View SOWatch.js
javascript:function somethingChanged(changes) {
changes.forEach( function ( change, i ) {
$("#chat").append('<div class="user-container user-24793 monologue mine catchup-marker catchup-marker-2">
<a href="/users/24793/ashtonkj" class="signature user-24793">
<div class="tiny-signature">
<div class="avatar avatar-16">
<img width="16" height="16" src="http://cdn.sstatic.net/stackoverflow/img/logo.png?v=c4" alt="AshtonKJ" title="AshtonKJ">
</div>
<div class="username">The Room</div>
</div>
You can’t perform that action at this time.