Skip to content

Instantly share code, notes, and snippets.

View tochman's full-sized avatar
💭
Coding on my own SaaS project (Rails + React)

Thomas Ochman tochman

💭
Coding on my own SaaS project (Rails + React)
View GitHub Profile
@tochman
tochman / basic_navigation.feature
Last active December 29, 2015 23:19
Custom error pages - cucumber scenario
@allow-rescue
Scenario: Show custom 404 page
When I am on the "foobar" page
Then the page should be titled "404 File Not Found"
And the response status should be 404
Then show me the page
And I should see "We're sorry, but we couldn't find the page you requested"
@allow-rescue
Scenario: Show custom 500 page
@tochman
tochman / _login_forms.html.erb
Last active December 30, 2015 03:09
Fields for Avatar upload using carrierwave
<div class="collapse" id="register">
<%= form_for(resource, :class => "collapse", :html => { :id => "registerForm", :multipart => true }, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<!--[if lt IE 9]>
<label for="user_password">Enter email</label>
<![endif]-->
<%= f.email_field :email, :autofocus => true, :id => 'signup_email', :name => 'user[email]', :placeholder => "you@example.com" %>
<!--[if lt IE 9]>
# RSpec
require 'spec/expectations'
# Webrat
require 'webrat'
require 'test/unit/assertions'
World(Test::Unit::Assertions)
Webrat.configure do |config|
@tochman
tochman / gist:7863374
Created December 8, 2013 20:24
The 3 books that have most influence how we think about are business are:
Nudge - Richard Thaler -- an incredible primer on behavioral economics and the psychology of decision making
Rework - 37signals -- the new way of running a company
Lean Startup - Eric Ries -- the new way to build products that fill a need
@tochman
tochman / contributors_controller.rb
Last active December 31, 2015 06:09
GitHub API: Grab list of contributors with a map of keys
class ContributorsController < ApplicationController
require 'rubygems'
require 'json'
def show
url = 'https://api.github.com/repos/AgileVentures/LocalSupport/stats/contributors'
uri = URI.parse url
request = Net::HTTP::Get.new(uri.request_uri)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
@tochman
tochman / avatar_uploader.rb
Last active January 1, 2016 05:29
Carrierwave & Dropbox
# app/uploaders/avatar_uploader.rb
# encoding: utf-8
class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :dropbox
process :resize_to_fit => [150, 150]
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
@tochman
tochman / media_content
Last active January 1, 2016 08:59
youtube_it syntax and examples
#try this!
(rdb:189) Video.yt_session.my_videos.videos[0].media_content[0].url
"http://www.youtube.com/v/UvgMW4XiN3c?version=3&f=user_uploads&c=youtube_it&d=Ae_QTuvYrTPr2cwuB_kjD8IO88HsQjpE1a8d1GxQnGDm&app=youtube_gdata"
(rdb:189) Video.yt_session.my_videos.videos[0].media_content[1].url
"rtsp://r5---sn-5hn7su7k.c.youtube.com/ClcLENy73wIaTgl3N-KFWwz4UhMYDSANFEIKeW91dHViZV9pdEgGUgx1c2VyX3VwbG9hZHNyIQHv0E7r2K0z69nMLgf5Iw_CDvPB7EI6RNWvHdRsUJxg5gw=/0/0/0/video.3gp"
(rdb:189) Video.yt_session.my_videos.videos[0].media_content[2].url
"rtsp://r5---sn-5hn7su7k.c.youtube.com/ClcLENy73wIaTgl3N-KFWwz4UhMYESARFEIKeW91dHViZV9pdEgGUgx1c2VyX3VwbG9hZHNyIQHv0E7r2K0z69nMLgf5Iw_CDvPB7EI6RNWvHdRsUJxg5gw=/0/0/0/video.3gp"
(rdb:189) Video.yt_session.my_videos.videos[0].media_content[3].url
*** NoMethodError Exception: undefined method `url' for nil:NilClass
echo "Install and configure github/tochman/website in current dir."
echo "On Ubuntu 13.10 64-bit, clean VM image from "
echo "http://virtualboximages.com/Ubuntu+13.10+amd64+VirtualBox+VDI+Virtual+Appliance"
echo "Dec 31, 2013"
read -p "Hit any key to continue.. "
if [ -d "website" ] ; then
read -p 'Directory ./website exists. Exiting.'
return 0
fi

Capybara

save_and_open_page

Matchers

have_button(locator)
@tochman
tochman / edit.html.erb
Created January 22, 2014 11:02
devise/registrations/edit.html.erb
<div class="col-md-4 col-md-offset-4" style="margin-top: -80px; padding-left: 140px; padding-right: 60px">
<%= devise_error_messages_flash %>
<h3>Account details</h3>
<img src="<%= gravatar_for(resource.email) %>" class="img-rounded">
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
<div><%= f.label :first_name %>
<div class="form-group">
<%= f.text_field :first_name, :autofocus => true, class: 'form-control' %>
</div>
</div>