Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View bguiz's full-sized avatar

Brendan Graetz bguiz

View GitHub Profile
@bguiz
bguiz / original.css
Created May 28, 2013 11:12
original FT view modules #ft #html5
.apple {}
.apple_headline {
//...
}
.apple_sub-head {
//...
}
@bguiz
bguiz / improved.css
Created May 28, 2013 11:39
improve FT view modules #ft #html5
<div class="apple">
<h2 class="headline">{{headline}}</h2>
<h3 class="sub-head">{{subhead}}</h3>
<div class="body">{{body}}</div>
</div>
@bguiz
bguiz / semantic.css
Created May 28, 2013 11:40
semantic FT view modules #ft #html5
.apple h2 {
//...
}
.apple h3 {
//...
}
.apple section {
//...
@bguiz
bguiz / shimForNewHtmlElements.css
Created May 28, 2013 11:51
css shim/ reset for new elements introduced in HTML5. see http://diveintohtml5.info/semantics.html#new-elements for a full discussion. #ft #html5
article,aside,details,figcaption,figure, footer,header,hgroup,menu,nav,section {
display:block;
}
var Foo = Backbone.Model.extend({
/* some code here */
});
//Default sollection
Foo.Collection = Backbone.Collection.extend({
model: Foo
/* some code here */
});
@bguiz
bguiz / diamond-using-async.js
Created October 20, 2013 11:03
A comparison of async to qryq in specifying a compound query that is diamond-shaped. http://bguiz.com/post/64567226287/a-sneak-peek-from-my-talk-about-qryq-at-osdc-2013
var async = require('async');
var _ = require('underscore');
var api = {
add: function(qry, callback) {
if (!qry || ! _.isNumber(qry.a) || ! _.isNumber(qry.b)) {
callback('Must specify two numeric params, a and b. Params were: '+JSON.stringify(qry), null);
}
else {
callback(null, qry.a + qry.b);
@bguiz
bguiz / sleep-until-modified-invoke.sh
Created November 3, 2013 09:57
useful for automating deployments
wget https://bitbucket.org/denilsonsa/small_scripts/raw/9159fee62dc7cca7f81f47cef41bd9ae1324553e/sleep_until_modified.py
chmod u+x ./sleep_until_modified.py
touch testfile.old
touch testfile
#note limitation of this script: needs file to exist beforehand
while ./sleep_until_modified.py testfile || sleep 1; do echo "diff detected" $( date -u --rfc-3339=seconds ) ; diff testfile.old testfile ; cp testfile testfile.old ; done
@bguiz
bguiz / silence-alerts-and-console-in-sinon-qunit.js
Last active December 27, 2015 23:39
When running unit tests using sinon-qunit, it can be rather annoying if you have to click through modal alert dialogs, and console errors can create clutter. However, failure scenarios in which these typically occur still need to be tested. Use this function to satisfy both requirements.
/*
* Use this method when we want to silence window alerts and console output within
* a test case.
* Most useful when testing error messages.
*
* Sample usage:
test("should not show any dialogs or output to console", function() {
this.silenceAlertsAndConsole();
window.alert("Hello");
console.log("World");
@bguiz
bguiz / workaroundIosFixedPositionBug.js
Created November 22, 2013 03:33
Workaround for bug in iOS5+ where `position: fixed;` behaves incorrectly when virtual keyboard is opened Solution somewhat similar to: http://stackoverflow.com/a/15537846/194982 Presently simply hides/ shows anything with class 'myFixed' (e.g. a header bar), but may be modified to do fancier things like repositioning it manually with JavaScript…
function workaroundIosFixedPositionBug() {
var isIosSafari = /(iPad|iPhone|iPod)/g.test(navigator.userAgent);
if (isIosSafari) {
// workaround for bug in iOS5+ where `position: fixed;` behaves incorrectly when virtual keyboard is opened
// Solution somewhat similar to: http://stackoverflow.com/a/15537846/194982
// Presently simply hides/ shows anything with class 'myFixed' (e.g. a header bar), but may be modified to do
// fancier things like repositioning it manually with javascript, should that be a requirement
$('#main').on("focus", "input, textarea", function() {
$('.myFixed').css('display', 'none');
});
@bguiz
bguiz / generator-angular-add-express-stub-server.diff
Last active August 29, 2015 13:56
Add express stub server to Gruntfile (from generator-angular as starting point)
diff --git a/ngyo/Gruntfile.js b/ngyo/Gruntfile.js
index 3df3112..2cb746a 100644
--- a/ngyo/Gruntfile.js
+++ b/ngyo/Gruntfile.js
@@ -1,6 +1,8 @@
// Generated on 2014-02-13 using generator-angular 0.7.1
'use strict';
+var path = require('path');
+