This file contains 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
window.bootstrapAlert = (type, message) -> | |
$('#alert_message').text message | |
$('#alert').addClass "alert-#{type}" | |
$("#alert").slideDown() | |
setTimeout (-> | |
$("#alert").slideUp(400, -> | |
$('#alert').removeClass "alert-#{type}" | |
) | |
), 5000 |
This file contains 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 ApiProviderHost | |
ENVIRONMENTS = [:development, :test, :staging, :production] | |
ALIASES = { | |
dev: :development, testing: :test, stage: :staging, show: :staging, | |
live: :production, prod: :production | |
} | |
FALLBACKS = { | |
development: [:development, :test, :staging, :production], | |
test: [:test, :development, :staging, :production], | |
staging: [:staging, :production], |
This file contains 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
<% message = flash[:notice] || flash[:alert] %> | |
<% flash.delete(:notice); flash.delete(:alert) %> | |
<% alert = message.present? ? "alert('#{message}');" : '' %> | |
<% if <a href="/path">@path</a>.present? %> | |
$.ajax({ url: "<%= @path %>", data: <%= raw @data.to_json %>, type: "<%= @method.to_s.upcase %>", dataType: "script"}).done(function(data) { | |
eval(data); | |
<%= raw alert %> | |
}) | |
.fail(function(data) { |
This file contains 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
describe 'example.html.erb' do | |
it 'renders HTML like this' do | |
render | |
compare_texts rendered, 'example.html' | |
end | |
end |
This file contains 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 MusicArtist < ActiveRecord::Base | |
include LastfmRequest | |
end | |
lastfm = Lastfm.new(LastfmApiKey, LastfmApiSecret) | |
# Simplest option | |
lastfm_artist = artist.lastfm_request(lastfm, :artist, :get_info, 'The artist you supplied could not be found', artist: 'Dummy') | |
# Option raise_if_response_is_just_nil |
This file contains 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 'rubygems' | |
require 'octokit' # gem install octokit | |
page = 1 | |
catch(:done) do | |
while (repositories = Octokit.repositories('railscasts', page: page, per_page: 100, sort: 'created', direction: 'desc')).length > 0 | |
repositories.each do |repository| | |
throw :done if File.exist? repository.name | |
This file contains 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 Presenter | |
def initialize(subject, options = {}) | |
@subject = subject | |
init_haml_helpers | |
end | |
private | |
def method_missing(*args, &block) | |
@subject.send(*args, &block) |