Skip to content

Instantly share code, notes, and snippets.

Avatar

Amiel Martin amiel

View GitHub Profile
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
View adapter-context.js
import Ember from 'ember';
export default Ember.Service.extend({
// this is intentionaly empty
});
View gist:7793267
# LineItemsController
categories: (->
@get('model').mapBy('category').uniq().map (category) =>
Ember.Object.create
name: category
line_items: @get('model').filterBy 'category', category
).property('@each.category')
View ab_test_helper.rb
module ABTestHelper
def test
yield
end
def variant(variant)
if variant_matches(variant)
yield
end
end
View _readme.md

Based on Mislav's gist, svenfuch's gist and vim-tmux-navigator.

My goal was to allow svenfuch's zoom feature to work in any direction. The original implementation relied on pane numbers, which works when you only split in one direction (either only horizontal or only vertical, but not both).

The logic is simple: use a panes width, height, x, and y along with the width width and height to determine if a pane is the top, bottom, leftmost, or rightmost pane. The reason I switched to ruby is that getting the panes x and y requires parsing the window_layout string.

View gist:6927952
module Draper
- begin
- require 'minitest/rails'
- rescue LoadError
- end
-
- active_support_test_case = begin
- require 'minitest/rails/active_support' # minitest-rails < 0.5
- ::MiniTest::Rails::ActiveSupport::TestCase
@amiel
amiel / line_items.handlebars
Created Oct 2, 2013
grouping items in an Ember.ArrayController
View line_items.handlebars
<table>
{{#each category in categories}}
<thead>
<tr>
<th class="large">
{{category.name}}
</th>
</tr>
<tr>
<th>Line Item</th>
View module_scope.rb
module Foo
class Bar;end
end
module Foo
class Baz
# lookup order: Foo::Baz::Bar, Foo::Bar, Bar
Bar.new # => #<Foo::Bar:...>
end
end
@amiel
amiel / gist:6075112
Created Jul 24, 2013
Ruby private weirdness
View gist:6075112
class Foo
private
attr_accessor :foo
public
def access_foo
foo # => nil # as expected
self.foo # => NoMethodError: private method...
end
@amiel
amiel / whaty_is_my_public_api.rb
Created Jun 13, 2013
Discover what methods in a class are actually being used. Either use dependency injection or completely replace your object with this one.
View whaty_is_my_public_api.rb
class WhatIsMyPublicApi < BasicObject
def initialize(*arguments)
method_missing('initialize', *arguments)
end
def method_missing(method, *arguments)
::File.open('what_is_my_public_api.log', 'a') do |f|
args = arguments.inspect.gsub(/^\[|\]$/, '')
f.write("#{method}(#{args})\n")
end
You can’t perform that action at this time.