Skip to content

Instantly share code, notes, and snippets.

View uhhuhyeah's full-sized avatar

David A McClain uhhuhyeah

View GitHub Profile
@uhhuhyeah
uhhuhyeah / rvm_saddness.txt
Created March 21, 2012 19:37
rvm saddness
`rvm use #{ruby_version}@identity-service --create`
# Can't run this from the script. :(
# results in `RVM is not a function, selecting rubies with 'rvm use ...' will not work.`
# Is there something special about rvm that's going to prevent us from accessing it from within the script?
mc-identity-service (master *) λ type rvm | head -1
rvm is a function
mc-identity-service (master *) λ irb
1.9.3-p125 :001 > `type rvm | head -1`
@uhhuhyeah
uhhuhyeah / meta.rb
Created April 4, 2012 21:25
Metaprogramming eg
# Permission based relations
# define admins, uploaders and guests associations via users
%w(admins uploaders guests).each do |method_name|
define_method(method_name) { self.memberships.where(role: method_name.singularize).collect(&:user) }
end
## vs...
def admins
self.memberships.where(role: :admin).collect(&:user)
@uhhuhyeah
uhhuhyeah / performance_metrics.md
Created June 16, 2012 00:11
Concepts used in browser-side performance testing

Outline

The purpose of this document is to outline the main metrics we use when discussing various end-user performance measurements such as "page speed".

Fig 1) A diagram we have been using in conversations to help illustrate the various events and how they inter-relate.

Events discussed

  • FIRST BYTE
  • DOC READY/DOM CONTENT EVENT
@uhhuhyeah
uhhuhyeah / outfitCollectionView.js
Created September 6, 2012 18:33
How do I test this?
window.app.OutFitCollectionView = Backbone.View.extend({
// redacted code for brevity...
render: function() {
this.collection.each(this.renderOutfit);
// redacted code for brevity...
return this;
},
@uhhuhyeah
uhhuhyeah / self-clearing-floats.css
Created October 22, 2012 04:25
Self-clearing floats
.some-floated-element:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
@uhhuhyeah
uhhuhyeah / self-clearing-floats-ie.css
Created October 22, 2012 04:29
Self-clearing floats IE
* html .some-floated-element { /* IE6 */
height: 1%;
}
*:first-child+html .some-floated-element { /* IE7 */
min-height: 1px;
}
@uhhuhyeah
uhhuhyeah / fancy-javascript.js
Created October 22, 2012 04:49
Fancy JavaScript
if ( foo == "bar" || foo == "foobar" || foo == "foo" ) {
//...
}
// can be written as
if ( foo in { bar:1, foobar:1, foo:1 } ) {
//...
}
@uhhuhyeah
uhhuhyeah / ids-from-dom-elements.js
Created October 22, 2012 04:56
grab the ids (or other attribute) from a set of DOM elements
// grab the ids (or other attribute) from a set of DOM elements
var ids = $("#mydiv span[id]") // find spans with ID attribute
.map(function() { return this.id; }) // convert to set of IDs
.get(); // convert to instance of Array (optional)
@uhhuhyeah
uhhuhyeah / erb-pre-processing.css.scss.erb
Created October 23, 2012 16:56
Using erb in css (asset pipeline)
.foo {
background: url(<%= asset_path 'image.png' %>);
}
@uhhuhyeah
uhhuhyeah / sprocket-helper.css.scss
Created October 23, 2012 16:57
Using sprocket helpers in css (asset pipeline)
.foo {
background: url( image_path 'image.png' );
}