Skip to content

Instantly share code, notes, and snippets.

View stefanpenner's full-sized avatar
🎯
Focusing

Stefan Penner stefanpenner

🎯
Focusing
View GitHub Profile
@stefanpenner
stefanpenner / if.rb
Created March 22, 2010 14:45 — forked from burke/if.rb
# This isn't necessarily "better", or even "useful" in any way, just sort of fun.
class Object
# I like how I can actually create methods with these names.
def if
@__if_result = yield self
self
end
def then
@__if_result ? yield self : self
module Enumerable
def map_to_hash(&block)
self.inject({}) do |acc,v|
acc.merge(block.call(v))
end
end
end
x = [:a, :b, :c].map_to_hash do |v|
{v => v.to_s.upcase}
@stefanpenner
stefanpenner / Yehudalize.rb
Created April 21, 2011 19:12 — forked from eqdw/stefanize.rb
An extension that stef should always include
module Yehudalize
def method_missing(method_sym, *arguments, &block)
if method_sym.to_s =~ /^(?:omg_)?(.*)_to_me$/
send($1.to_sym, *arguments, &block)
else
super
end
end
end
@stefanpenner
stefanpenner / acceptance_helper.rb
Created May 31, 2011 03:18 — forked from ssoroka/acceptance_helper.rb
Use feature, background, and scenario blocks to write acceptance tests in test/unit
# Use feature, background, and scenario blocks to write acceptance tests in test/unit
# which are really just integration tests. include capybara or webrat or something and voila.
# test/acceptance_helper.rb
require 'test_helper'
module ActionDispatch
class AcceptanceTest < ActionDispatch::IntegrationTest
class << self
alias :background :setup
@stefanpenner
stefanpenner / gist:1507777
Created December 21, 2011 21:26 — forked from wisq/gist:1507733
Why I love zsh (and hate being forced to use bash)

Cool things that make zsh appealing

  • Filename correction during completion

  • if dir1/x exists and dir2 exists, then "dir/x<TAB>" completes to dir1/x

  • if name1 is a file and name2 is a directory with files in it, "name/<TAB>" completes to "name2/"

  • Better ctrl-R behaviour

  • alerts you if your ctrl-R is failing

  • completes it right on the prompt line while showing you what you're searching for below

@stefanpenner
stefanpenner / quoter.html
Created January 27, 2012 21:10 — forked from jonharmon/quoter.html
Zip Form Redirect to another jQuery Tab
<div id="instantquoter" class="reveal-modal">
<script src="http://cdn.jquerytools.org/1.2.6/full/jquery.tools.min.js"></script>
<script>
$(function() {
$("ul.tabs").tabs("div.main > div.panes");
});
</script>
diff --git a/index.js b/index.js
index 2ec4b85..d010a51 100644
--- a/index.js
+++ b/index.js
@@ -59,9 +59,9 @@ Babel.prototype = Object.create(Filter.prototype);
Babel.prototype.constructor = Babel;
Babel.prototype.targetExtension = ['js'];
-Babel.prototype.rebuild = function() {
+Babel.prototype.build = function() {
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
import Ember from 'ember';
function optionsProperty(dependentKey) {
return Ember.computed(dependentKey, function() {
return this.get(dependentKey).split(',').map(Function.prototype.call, String.prototype.trim);
});
}
export default Ember.Controller.extend({
init() {
@stefanpenner
stefanpenner / application.controller.js
Created January 21, 2016 06:59 — forked from jeradg/application.controller.js
Computed Properties with @each (broken - Ember 2.2.0)
import Ember from 'ember';
let lastId = 0;
export default Ember.Controller.extend({
rootItems: Ember.computed.filter('owner.items', function(item) {
return item.get('parent.content') === null;
}).property('owner.items.@each.parent'),
owner: Ember.computed(function() {