Skip to content

Instantly share code, notes, and snippets.

View mrmicahcooper's full-sized avatar
🥋
Focusing

Micah Cooper mrmicahcooper

🥋
Focusing
View GitHub Profile
defmodule TimeMacro do
defmacro deftime(function_name, [do: block] = expression) do
quote do
def unquote(function_name) do
start_time = NaiveDateTime.utc_now()
result = unquote(block)
finish_time = NaiveDateTime.utc_now()
IO.puts("sent #{start_time} and #{finish_time}")
result
end
import Ember from 'ember';
import computed from 'ember-computed';
export default Ember.Component.extend({
classNameBindings: ['componentName'],
componentName: computed(function() {
return this
.toString()
.match(/:(.+)::/)[1]
}),
import Ember from 'ember';
import titleComponent from 'app/components/x-list/list-item'
export default Ember.Component.extend({
titleComponent: titleComponent,
});
require 'pry'
results = `git branch -r`.split("\n")
ignored = ['master', 'production', 'new_mobile_nav']
results.map!(&:strip)
results.map! do |branch|
args = branch.split("/")
[args[0], args[1]]
module NavigationHelpers
def path_to(page_name)
case page_name
when /the home\s?page/
'/'
when /^that ([\w ]+)'s page$/
polymorphic_path(instance_variable_get("@#{$1.parameterize('_')}"))
require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
Given /^(?:|I )am on (.+)$/ do |page_name|
visit path_to(page_name)
end
Then /^(?:|I )should be on (.+)$/ do |page_name|
current_path = URI.parse(current_url).path
if current_path.respond_to? :should
current_path.should == path_to(page_name)
US_STATES = [
['Alabama', 'AL'],
['Alaska', 'AK'],
['Arizona', 'AZ'],
['Arkansas', 'AR'],
['California', 'CA'],
['Colorado', 'CO'],
['Connecticut', 'CT'],
['Delaware', 'DE'],
['District of Columbia', 'DC'],
unless defined?(Rails)
require 'active_record'
connection_info = YAML.load(File.open("config/database.yml"))["test"]
ActiveRecord::Base.establish_connection(connection_info)
RSpec.configure do |config|
config.around do |example|
ActiveRecord::Base.transaction do
require 'active_model'
def errors_on(attribute)
self.valid?
[self.errors[attribute]].flatten.compact
end
alias :error_on :errors_on
%ul
- Dir.glob('app/views/ui/*.html.haml').sort.each do |file|
- wireframe = File.basename(file,'.html.haml')
- unless wireframe == 'index' || wireframe.match(/^_/)
%li= link_to wireframe.titleize, action: wireframe unless wireframe == 'index'