This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gravatar_url(email,options = {}) | |
require 'digest/md5' | |
hash = Digest::MD5.hexdigest(email) | |
url = "http://www.gravatar.com/avatar/#{hash}" | |
options.each do |option| | |
option == options.first ? url+="?" : url+="&" | |
key = option[0].to_s | |
value = option[1].to_s | |
url+=key + "=" + value | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# A quick and dirty implementation of an HTTP proxy server in Ruby | |
# because I did not want to install anything. | |
# | |
# Copyright (C) 2009 Torsten Becker <[email protected]> | |
require 'socket' | |
require 'uri' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add this file capybara_wait_until.rb to your /test directory | |
module Capybara | |
class Session | |
## | |
# | |
# Retry executing the block until a truthy result is returned or the timeout time is exceeded | |
# | |
# @param [Integer] timeout The amount of seconds to retry executing the given block | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "timeout" | |
module WaitSteps | |
extend RSpec::Matchers::DSL | |
matcher :become_true do | |
match do |block| | |
begin | |
Timeout.timeout(Capybara.default_wait_time) do | |
sleep(0.1) until value = block.call |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(XHR) { | |
"use strict"; | |
var stats = []; | |
var timeoutId = null; | |
var open = XHR.prototype.open; | |
var send = XHR.prototype.send; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.controller 'CollectionsController', ($scope) -> | |
$scope.sort_column = 'created_at' | |
$scope.sort_order = 'DESC' | |
current_sort_order = $scope.sort_order | |
$scope.sort_by_column = (column) -> | |
$scope.sort_order = 'ASC' | |
$scope.sort_order = 'DESC' if $scope.sort_column == column && current_sort_order == 'ASC' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
step %{I save a task without the required fields} do | |
within_task_form do | |
# NOTE filling with '' won't work as it does not trigger keypress events | |
# and thus breaks angular bindings | |
fill_in 'task_name', with: ' ' | |
end | |
step %{I save the task} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.expand_path("../production.rb", __FILE__) | |
RailsAppName::Application.configure do | |
config.middleware.insert_after(::Rack::Lock, "::Rack::Auth::Basic", "Staging") do |u, p| | |
[u, p] == [ENV['STAGING_USERNAME'], ENV['STAGING_PASSWORD']] | |
end | |
config.action_mailer.default_url_options = { :host => 'some-app.herokuapp.com' } | |
config.action_mailer.asset_host = "" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AwsS3 | |
AWS_ACCESS_KEY = ENV['AWS_ACCESS_KEY_ID'] | |
AWS_SECRET_KEY = ENV['AWS_SECRET_ACCESS_KEY'] | |
S3_BUCKET = ENV['S3_BUCKET'] || "#{Rails.application.class.parent_name}_#{Rails.env}".downcase | |
attr_accessor :file_name, :mime_type, :path, :acl, :expires_in | |
attr_writer :as_attachment | |
def initialize(file_name, mime_type, acl: 'private', path: '/') | |
@file_name = esc file_name # escape for spaces and the like |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module("app", []) | |
.directive 'formtasticInlineErrors', ($compile) -> | |
return { | |
restrict: 'A' | |
link: (scope, element, attrs) -> | |
scope.$on 'event:form-FormErrors', (evt, model_name, errors) -> | |
element.find('.input .inline-error').remove() | |
if !errors? || errors.length == 0 | |
else |