Skip to content

Instantly share code, notes, and snippets.


Amiel Martin amiel

View GitHub Profile
amiel / adapters.user.js
Last active Dec 23, 2016 — forked from samselikoff/mirage.config.js
Mirage dev boilerplate
View adapters.user.js
import DS from 'ember-data';
export default DS.JSONAPIAdapter.extend({
buildURL(type, id) {
return `/users/${id}.json`;

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.

amiel / engine.rb
Created Oct 10, 2012
Testing routes with Rails 3.2 mountable engines and RSpec 2
View engine.rb
# your-engine/lib/magic/rails/engine.rb
module Magic
module Rails
module Engine
# Automatically append all of the current engine's routes to the main
# application's route set. This needs to be done for ALL functional tests that
# use engine routes, since the mounted routes don't work during tests.
View app-models-foo.rb
class Foo < ActiveRecord::Base
extend TimeScopes
# ...
amiel / capybara_select_dates_and_times.rb
Created Mar 7, 2012 — forked from szimek/capybara_select_dates_and_times.rb
Cucumber steps for selecting time and date (using Capybara)
View capybara_select_dates_and_times.rb
require "xpath" # XPath is a separate gem now
module Cucumber
module Rails
module CapybaraSelectDatesAndTimes
def select_date(field, options = {})
date = Date.parse(options[:with])
selector = %Q{.//fieldset[contains(./legend, "#{field}")]}
within(:xpath, selector) do
find(:xpath, './/select[contains(@id, "_1i")]').find(:xpath, ::XPath::HTML.option(date.year.to_s)).select_option
View idea1.rb
class Asset < AR
class Alert < AR
belongs_to :asset
has_many :logs
accepts_nested_attributes_for :logs
class Log < AR
amiel / helpers.rb
Created Oct 27, 2011 — forked from adrianpike/helpers.rb
Page title helper for I18n with to_s for :show!
View helpers.rb
def page_title()
object_name = controller_name.singularize
if controller.instance_variables.include?(('@' + object_name).to_sym)
locals = {
object_name.to_sym => controller.instance_variable_get('@' + object_name).to_s
locals = {}
View set-matching.rb
#! /usr/bin/ruby
# data set:
# id | name | score | postal | color
# 1 | john | 14 | 12345 | blue
# 2 | jane | 10 | 12345 | blue
# 3 | jeff | 6 | 12345 | green
# define a simple class for holding the dataset
amiel / caveatPatchor.js
Created Feb 22, 2011 — forked from protocool/caveatPatchor.js
fork of caveatPatch.js for propane that supports gravatars
View caveatPatchor.js
As of version 1.1.2, Propane will load and execute the contents of
~Library/Application Support/Propane/unsupported/caveatPatchor.js
immediately following the execution of its own enhancer.js file.
You can use this mechanism to add your own customizations to Campfire
in Propane.
Below you'll find two customization examples.
View .gitignore
# This is a template .gitignore file for git-managed WordPress projects.
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
# See the comments below for more info on how to add exceptions for your
You can’t perform that action at this time.