This file contains hidden or 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 compose = function compose(f) { | |
var queue = f ? [f] : []; | |
var fn = function fn(g) { | |
if (arguments.length) { | |
queue.push(g); | |
return fn; | |
} | |
return function() { | |
var args = Array.prototype.slice.call(arguments); | |
queue.forEach(function(func) { |
This file contains hidden or 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
// adapted from: | |
// http://javascriptweblog.wordpress.com/2010/04/05/curry-cooking-up-tastier-functions/ | |
// http://javascriptweblog.wordpress.com/2010/04/14/compose-functions-as-building-blocks/ | |
function curry( fn ) { | |
if ( arguments.length < 2 ) { | |
return fn; | |
} | |
var args = [].slice.call( arguments, 1 ); | |
return function() { |
This file contains hidden or 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 getPrototypeChainOf = function( obj ) { | |
var chain = []; | |
if ( isFunction(obj) ) { | |
obj = obj.prototype; | |
} else { | |
obj = obj.constructor.prototype; | |
} | |
do { |
This file contains hidden or 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
compose = do -> | |
each = ( obj, itr ) -> | |
list = if Array.isArray( obj ) then obj.map ( e, i ) -> i else Object.keys( obj ) | |
i = 0 | |
while i < list.length | |
itr( obj[ list[i] ], list[ i ], obj ) | |
i += 1 | |
obj | |
This file contains hidden or 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
# uses dummy elements to listen for/dispatch events | |
class ControlCollectionA extends Array | |
constructor : ( arr ) -> | |
this.push( item ) for item in arr | |
this.el = document.createElement "dummy" | |
on : ( eventType, handler ) -> | |
thisEl = this.el | |
thisEl.addEventListener eventType, handler.bind( this ), false |
This file contains hidden or 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 prototypeChain = function( o ) { | |
prototypes = []; | |
while ( o = Object.getPrototypeOf( o ) ) { | |
prototypes.push( o ) | |
} | |
return prototypes; | |
} |
This file contains hidden or 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
<form action="your-action.lang" method="POST"> | |
<script | |
src="https://my.tok3n.com/v1/embed.js" class="your-class" | |
data-publicKey="dOcPsnXndcRw3QdIosnE0j" | |
data-userKey="Ngfl6Gn2q15g8mR28vi2no" | |
data-theme="default" | |
data-action-name="Login" | |
data-app-name="Demo Site"> | |
</script> | |
<input type="submit" /> |
This file contains hidden or 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 Tok3n = require('tok3n').Tok3n, | |
tok3n = new Tok3n('yourPrivateKey', | |
userKey, | |
req.body.tok3nOtpField); | |
tok3n.verify(function(success, error_code) { | |
if (success) { | |
// Successful verification | |
} | |
else { |
This file contains hidden or 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
<%@ page import="net.tok3n.Tok3nImpl" %> | |
<%@ page import="net.tok3n.Tok3nResponse" %> | |
<% | |
tok3n.setPrivateKey("your_private_key"); | |
Tok3nImpl tok3n = new Tok3nImpl(); | |
String otp = request.getParameter("tok3n_otp_field"); | |
Tok3nResponse tok3nResponse = tok3n.verify(user_key, otp); | |
if (tok3nResponse.isValid()) { | |
// Successful verification |
This file contains hidden or 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
# Gemfile: gem 'tok3n', :require => "tok3n/rails" | |
respond_to do |format| | |
if tok3n_verify(:private_key => 'your_private_key', | |
:user_key => @user_key, | |
:otp => 'tok3n_otp_field') | |
# Successful verification | |
else | |
# Failed verification |