Skip to content

Instantly share code, notes, and snippets.

View ashtonkj's full-sized avatar

Kevin Ashton ashtonkj

View GitHub Profile
@ashtonkj
ashtonkj / keybase.md
Created September 30, 2014 15:01
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 September 9, 2014 13:59
WebApi Default Args Binder
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
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 July 29, 2014 17:07
Stack Overflow Chat - Check for New Users
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>