Skip to content

Instantly share code, notes, and snippets.

@zacechola
zacechola / override-input.js
Created June 22, 2015 15:50
Override input focus
// Wait for forms.js to load, then override input focus
$.when(Toolkit.promises.form)
.done(function {
$('#yourSelectID').focus().attr('autofocus', autofocus);
});
@zacechola
zacechola / polyfill.js
Created June 5, 2015 14:34
Polyfill history.js using Modernizr
Modernizr.addTest('history', function() {
var ua = navigator.userAgent;
if ((ua.indexOf('Android 2.') !== -1 ||
(ua.indexOf('Android 4.0') !== -1)) &&
ua.indexOf('Mobile Safari') !== -1 &&
ua.indexOf('Chrome') === -1 &&
ua.indexOf('Windows Phone') === -1) {
return false;
}
var React = require('react')
var Hello = React.createClass({
displayName: 'Hello',
render: function() {
return <div>Hello, {this.props.name}</div>
}
})
React.render(<Hello name="World" />, document.body)
@zacechola
zacechola / coercion-is-fun.md
Created May 12, 2015 20:30
JavaScript is logical
[1] + [6] * [2] == 112 // true

Because:

[6] * [2] coerces to "6" * "2", which further coerces to 6 * 2, which equals 12.

[1] + 12 coerces to "1" + 12, which changes the meaning of "+" to concatenate, so the string "1" is concatenated to number 12, resulting in the string "112".

@zacechola
zacechola / 100to1-2.js
Last active August 29, 2015 14:18
beat this
// This is way better. for loops are for losers
Object.keys(new Int8Array(100)).map(Number).sort(function(a,b) { return b - a; }).map(function(i) { console.log(i + 1); });
@zacechola
zacechola / bs-qunit
Created February 3, 2015 17:06
¯\_(ツ)_/¯
66-247-17-199 in ~/Sites/bootstrap-3.3.2
○ → npm install
> phantomjs@1.9.15 install /Users/zacharyechola/Sites/bootstrap-3.3.2/node_modules/grunt-contrib-qunit/node_modules/grunt-lib-phantomjs/node_modules/phantomjs
> node install.js
Downloading https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-macosx.zip
Saving to /var/folders/p8/nb453vcx38x2tjsnfxy43z0h0000gn/T/phantomjs/phantomjs-1.9.8-macosx.zip
Receiving...
- [===================================-----] 89% 0.0s-

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@zacechola
zacechola / form-group.html
Created December 2, 2014 20:32
how to .form-group
<form role="form">
<div class="form-group">
<label class="control-label" for="thing">Label</label>
<input type="text" class="form-control" id="thing" title="A note about what's required here">
</div>
</form>
@zacechola
zacechola / dates.html
Created November 25, 2014 22:02
date filtering two things
<!-- first form -->
<form role="form" novalidate>
<div class="form-group" id="startDates_other">
<label for="startDate" class="control-label">Start date</label>
<input type="date" class="form-control" name="startDate_other" placeholder="Start date" data-filter-type="date_other">
</div>
<div class="form-group" id="endDates">
<label for="endDate" class="control-label">End date</label>
<input type="date" class="form-control" name="endDate_other" placeholder="Start date" data-filter-type="date_other">
</div>
// Core variables and mixins
@import "../bootstrap/less/variables.less";
@import "../bootstrap/less/mixins.less";
// My variable overrides
@import "my-variables.less";
// Reset and dependencies
@import "../bootstrap/less/normalize.less";
@import "../bootstrap/less/print.less";