-
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
| require 'active_model' | |
| # Most of this is the basic boilerplate described in the docs for active_model/errors; ie, the bare minimum | |
| # a class must have to use AM::Errors | |
| class Post | |
| extend ActiveModel::Naming | |
| attr_reader :errors | |
| attr_accessor :title, :author, :publication_date |
| // Takes a URL, param name, and data string | |
| // Sends to the server.. The server can respond with binary data to download | |
| jQuery.download = function(url, key, data){ | |
| // Build a form | |
| var form = $('<form></form>').attr('action', url).attr('method', 'post'); | |
| // Add the one key/value | |
| form.append($("<input></input>").attr('type', 'hidden').attr('name', key).attr('value', data)); | |
| //send request | |
| form.appendTo('body').submit().remove(); |
| # | |
| # UPDATE for 10.10.4+: please consider this patch obsolete, as apple provides a tool called "trimforce" to enable trim support for 3rd party SSDs | |
| # just run "sudo trimforce enable" to activate the trim support from now on! | |
| # | |
| # Original version by Grant Parnell is offline (http://digitaldj.net/2011/07/21/trim-enabler-for-lion/) | |
| # Update July 2014: no longer offline, see https://digitaldj.net/blog/2011/11/17/trim-enabler-for-os-x-lion-mountain-lion-mavericks/ | |
| # | |
| # Looks for "Apple" string in HD kext, changes it to a wildcard match for anything | |
| # | |
| # Alternative to http://www.groths.org/trim-enabler-3-0-released/ |
| module AuthHelper | |
| def http_login | |
| user = 'username' | |
| pw = 'password' | |
| request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user,pw) | |
| end | |
| end | |
| module AuthRequestHelper | |
| # |
| ARCHFLAGS="-arch x86_64" gem install mysql2 -- –with-mysql-config=/usr/local/bin/mysql_config |
| class MyResource | |
| include HTTParty | |
| debug_output $stdout # <= will spit out all request details to the console | |
| #... | |
| end |
| RSpec.configure do |config| | |
| config.before(:suite) do | |
| DatabaseCleaner.clean_with(:truncation) | |
| end | |
| config.before(:each) do | |
| DatabaseCleaner.strategy = :transaction | |
| end | |
| config.before(:each, js: true) do |
I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api
Rails.application.routes.draw do
constraints subdomain: "api" do
scope module: "api" do| # -*- coding: utf-8 -*- | |
| """ | |
| Zendesk timezones are represented by friendly names that map to tz database names. | |
| For example, an API request returns "Eastern Time (US & Canada)" instead of "America/New_York". | |
| You can map the friendly names to the tz database names by referencing the Constants > Mapping | |
| section of the Ruby on Rails TimeZone object doc. | |
| https://developer.zendesk.com/rest_api/docs/core/users#time-zone |