Skip to content

Instantly share code, notes, and snippets.

// jQuery fix for Webkit SVG height bug.
// Documented here: https://bugs.webkit.org/show_bug.cgi?id=82489 & http://www.brichards.co.uk/blog/webkit-svg-height-bug-workaround
// Found via: http://stackoverflow.com/questions/7570917/svg-height-incorrectly-calculated-in-webkit-browsers
// Original Gist: https://gist.github.com/pfulton/4259378
// Call the fix function on resize and/or ready
svgElements = $('svg')
function fixWebkitHeightBug(){
svgElements.each(function() {
$(this).parent().height(this.prop('viewBox').baseVal / this.prop('viewBox').baseVal * $(this).parent().width() )
<head>
<!-- a bunch of stuff in the head -->
</head>
<body>
<h1>Blog</h1>
<article class="blog-post">
<h2>Blog Post</h2>
<p>
@bttmly
bttmly / aal.css
Created November 20, 2013 05:09 — forked from btbytes/aal.css
/*
aardvark.legs by Anatoli Papirovski - http://fecklessmind.com/
Licensed under the MIT license. http://www.opensource.org/licenses/mit-license.php
URL: http://aardvark.fecklessmind.com/aal.css.txt
*/
/*
Reset first. Modified version of Eric Meyer and Paul Chaplin reset
from http://meyerweb.com/eric/tools/css/reset/
*/
@bttmly
bttmly / text-measure.coffee
Last active December 31, 2015 05:19
SASS + CoffeeScript snippets for estimating text measure. Useful for development. Make sure you set a line-height, since it defaults to "normal" which will give you NaN. Based on http://stackoverflow.com/a/14376445/2942909
getTextMeasure = ( $elements ) ->
$elements.each ->
numLines = $( this ).height() / $( this ).css("line-height").replace( "px", "" )
textLength = $( this ).text().length
$( this ).data("text-measure", textLength / numLines )
$textMeasure = $( ".text-measure" )
$( document ).ready ->
getTextMeasure( $textMeasure )
@bttmly
bttmly / nesting.js
Created January 19, 2014 04:36 — forked from geddski/nesting.js
function nestCollection(model, attributeName, nestedCollection) {
//setup nested references
for (var i = 0; i < nestedCollection.length; i++) {
model.attributes[attributeName][i] = nestedCollection.at(i).attributes;
}
//create empty arrays if none
nestedCollection.bind('add', function (initiative) {
if (!model.get(attributeName)) {
model.attributes[attributeName] = [];
curl https://my.tok3n.com/api/v1/otpValid
-d "ApiKey=HcI561xLCo4666st0871VP"
-d "UserKey=Ngfl6Gn2q15g8mR28vi2no"
-d "otp=123456"
<?php
require_once('tok3n.php');
$response = tok3n_verify ("your_private_key",
$user_key,
$_POST["tok3n_otp_field"]);
if ($response -> is_valid) {
// Successful verification
} else {
// Failed verification
# 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
<%@ 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
var Tok3n = require('tok3n').Tok3n,
tok3n = new Tok3n('yourPrivateKey',
userKey,
req.body.tok3nOtpField);
tok3n.verify(function(success, error_code) {
if (success) {
// Successful verification
}
else {