Skip to content

Instantly share code, notes, and snippets.

View amiel's full-sized avatar

Amiel Martin amiel

View GitHub Profile
@amiel
amiel / _readme.md
Last active December 25, 2015 13:19 — forked from svenfuchs/_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.

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 October 2, 2013 18:32
grouping items in an Ember.ArrayController
<table>
{{#each category in categories}}
<thead>
<tr>
<th class="large">
{{category.name}}
</th>
</tr>
<tr>
<th>Line Item</th>
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 July 24, 2013 22:14
Ruby private weirdness
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 June 13, 2013 20:59
Discover what methods in a class are actually being used. Either use dependency injection or completely replace your object with this one.
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
@amiel
amiel / no_workie_2.rb
Last active December 18, 2015 11:38
ARC vs GC gotcha example
describe WebService
def test_request(t, path, params, &block)
# Local variable t persists in both callbacks
# However, `block` doesn't make it
@result = nil
WebService.post(path, params) do |result|
@result = result
t.resume
end
@amiel
amiel / smarttrips_api_spec.md
Last active December 18, 2015 03:29
SmartTrips API spec draft

API Spec

POST /api/employers/trips

  • requires HTTP Basic authorization

Attributes

  • user_email -- users email required
import sublime_plugin
import os
class PomodoroStatus(sublime_plugin.EventListener):
# TODO: set up an interval callback on_activated
def update_pomodoro_status(self, view):
f = os.popen('~/Dropbox/dotfiles/bin/pomodoro time')
view.set_status("0_pomodoro_status", f.read())
@amiel
amiel / Charlie.ino
Last active December 16, 2015 04:29
Digispark Charlieplex http://digistump.com/products/13 using this charlieplexing library http://playground.arduino.cc/code/charlieplex
#include <Charlieplex.h>
#define NUMBER_OF_PINS 5
byte pins[] = {0,1,2,3,4};
Charlieplex charlieplex = Charlieplex(pins,NUMBER_OF_PINS);
typedef bool grid[6][5];
int h = 5;
int w = 4;