Skip to content

Instantly share code, notes, and snippets.

Mike Knoop mikeknoop

Block or report user

Report or block mikeknoop

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
# APPLICATION CODE (uses underscore.js)
lawnchair = new Lawnchair({}, (->))
# hackery to cope with firefox and lawnchair, indexedDB not doing asnyc validation
# so well. If indexedDB isn't available (after doing a .open() check) then remove it
# from the available adapters and re-init lawnchair with a new instance.
# see:
indexedDBValid = (callback) =>
idb = window.indexedDB or window.webkitIndexedDB or window.mozIndexedDB or window.oIndexedDB or window.msIndexedDB
View helper_use.html
<div>There is {{#article}}{{animal}}{{/article}} in the middle of the room.</div>
<!-- context passed as {noun: 'elephant'} -->
<div>There is an elephant in the middle of the room.</div>
<!-- context passed as {noun: 'mouse'} -->
<div>There is a mouse in the middle of the room.</div>
# accessor: returns the article "a" or "an" depending on the context string. Eg. "Computer" will return "a"
# and "Elephant" will return "an". Can pass a hash option `capitalize` which will capitalize the article.
# usage: {{#article}}string{{/article}} outputs "a string"
Handlebars.registerHelper "article", (options) ->
# options: pass `capitalize` true to get a capital article
string = options.fn(@)
vowels = ['a', 'e', 'i', 'o', 'u']
vowel = false
letter = string.toLowerCase()[0]
vowel = true for v in vowels when letter == v
View seriously?.coffee
View extend.scss
button {
color: black;
.success { color: green; }
.error { color: red; }
.disabled { color: gray; }
.homepage {
// make the home page call to action green
.call-to-action { @extend button.success; }
Book = new Backbone.Model.extend()
Paginate =
page: 0
turnPage: () ->
@page += 1
@fetch {data: {page: @page}}
book = _.extend new Book(), Paginate
View example.js
setCaret: function($el) {
var caret, lastCaret,
_this = this;
if (_.any(this.NO_CARET_TYPES, function(type) {
return type === _this.model.get('type');
})) {
lastCaret = this.getCaret();
if (($el != null ? $el[0] : void 0) != null) {
setCaret: ($el) ->
return if _.any @NO_CARET_TYPES, (type) => return type == @model.get('type')
lastCaret = @getCaret()
caret = $el.atCaret('getCaretPosition') if $el?[0]?
@model.set {caret: caret, lastCaret: lastCaret}
$el.attr 'data-caret', caret if caret?
$el.attr 'data-last-caret', lastCaret if lastCaret?
View html-header.php
<?php $blog = true; // only set on blog pages ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
$title = "Mike Knoop | Founder, Web Developer, and Mechanical Engineer";
$description = "Personal archive and blog for all the awesome stuff I work on, including my current startup Zapier. Connect with me on Twitter and Google+.";
if ($blog) {
$title = "Blog | Mike Knoop";
if (!$all_posts) {
$title = get_post()->post_title . " | Mike Knoop";
View WP HN Comment.php
$code = "XXXX";
$u = urlencode(get_permalink());
$t = urlencode(get_post()->post_title);
$next = "".$u."&t=".$t;
$next = urlencode($next);
$href = "" . $next . "&zid=" . $code;
<a class="hn" href="<?php echo $href; ?>">Upvote and Comment on Hacker News</a>
You can’t perform that action at this time.