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.

@amiel
amiel / engine.rb
Created October 10, 2012 21:37
Testing routes with Rails 3.2 mountable engines and RSpec 2
# 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.
#
class Foo < ActiveRecord::Base
extend TimeScopes
# ...
end
@amiel
amiel / capybara_select_dates_and_times.rb
Created March 7, 2012 01:02 — forked from szimek/capybara_select_dates_and_times.rb
Cucumber steps for selecting time and date (using Capybara)
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
class Asset < AR
end
class Alert < AR
belongs_to :asset
has_many :logs
accepts_nested_attributes_for :logs
end
class Log < AR
@amiel
amiel / helpers.rb
Created October 27, 2011 21:59 — forked from adrianpike/helpers.rb
Page title helper for I18n with to_s for :show!
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
}
else
locals = {}
end
#! /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
amiel / caveatPatchor.js
Created February 22, 2011 01:31 — forked from protocool/caveatPatchor.js
fork of caveatPatch.js for propane that supports gravatars
/*
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.
@amiel
amiel / .gitignore
Created November 15, 2010 18:38 — forked from redoPop/.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Equal Heights Test</title>
<style type="text/css" media="screen">
#container{ width: 960px; margin: 20px auto; }