Skip to content

Instantly share code, notes, and snippets.

View exocode's full-sized avatar
🏠
Working from home

Jan exocode

🏠
Working from home
View GitHub Profile
@exocode
exocode / MegaGen.rb
Last active December 16, 2015 21:59
SETUP your advanced Ruby on Rails app in seconds. This generator-setup-script which I call "MegaGen" provides a complete automatic setup of mongoid, mySQL, pg, Guard, rSpec, Cucumber, Shoulda Matchers, Capybara, fabrication, factory_girl, haml, amazon-aws, omniauth, devise, cancan, carrierwave, paperclip, and more. Simply choose your desired add…
####
# Copyright by mediatainemnt-productions.com
# Created by Jan Jezek
# 2012
############################
## PLUGIN
#########
@mixin sprite-background($name, $folder) {
$sprites: sprite-map("#{$folder}/*.png");
$sprites-retina: sprite-map("#{$folder}@2x/*.png");
background-image: sprite-url($sprites);
background-position: sprite-position($sprites, $name);
background-repeat: no-repeat;
@include inline-block;
height: image-height(sprite-file($sprites, $name));
width: image-width(sprite-file($sprites, $name));
@exocode
exocode / vendor-ffmpeg-x264-mp3lame-heroku
Last active December 19, 2015 19:58 — forked from czivko/vendor-ffmpeg-x264-mp3lame-heroku
more precise documentation added libavfilter for amerge, amix and co...
## Get FFMpeg working on heroku by building binaries using vulcan
# also added instructions on how to compile with libmp3lame and libx264
####################################
# INSTALL VULCAN if not done already
gem install vulcan
#################
# CREATE YOUR APP "Foo"
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@exocode
exocode / capybara cheat sheet
Last active December 27, 2015 06:49 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@exocode
exocode / selenium-webdriver-cheatsheet.md
Last active December 28, 2015 02:49 — forked from huangzhichong/selenium-webdriver-cheatsheet.md
selenium-webdriver-cheatsheet

API workthough

  1. Open a browser

    # start an instance of firefox with selenium-webdriver
    driver = Selenium::WebDriver.for :firefox
    # :chrome -> chrome
    # :ie     -> iexplore
    
  • Go to a specified URL
# config/locales/en.yml
en:
exception:
show:
not_found:
title: "Not Found"
description: "The page you were looking for does not exists."
internal_server_error:
title: "Internal Server Error"
@exocode
exocode / gist:8390721
Last active January 3, 2016 01:39
# workaround, to set default locale for ALL rspecs https://github.com/rspec/rspec-rails/issues/255
class ActionView::TestCase::TestController
def default_url_options(options={})
logged_in = options[ :controller ] =~ /admin/ ? 'members' : nil
{ locale: I18n.default_locale, logged_in: logged_in }
end
end
class ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper
def call(t, args)
logged_in = @options[ :controller ] =~ /admin/ ? 'members' : nil
@exocode
exocode / flash_message_helper.rb
Last active April 20, 2018 06:38
Useful Flash Messages in #Rails
Inevitably somewhere in your rails app you display flash messages to your users to inform them that an action has (or hasn't) taken place. Sometimes they need to provide more info, maybe you've just created some new information for them. Why make them sit around, or wonder where they need to go next when you can take them straight to it in the message itself?
I've ripped this code out of a project I've been working on and made it a little more generic. Initially I was going to just insert a link in the flash message, but as I was rightly pointed out by my pair and elegant coder extraordinaire, that would mean I'd be polluting my controller with logic and content that should be handled by the view. How do we solve a problem like pollution?
First, we updated the controller so that the flash message now looked something like this:
flash[:error] = "Username and password do not match. If you have
forgotten your password you can %s"
The %s is there to use a string substitution later. If you w
<head>
<%= yield :title %>
</head>
<body>
<%= render_breadcrumbs %>
<%= yield # regular content %>
</body>