Skip to content

Instantly share code, notes, and snippets.

View rsutphin's full-sized avatar

Rhett Sutphin rsutphin

  • Human Practice, Inc.
  • Chicago, Illinois
View GitHub Profile
@nolanlawson
nolanlawson / protips.js
Last active February 4, 2024 18:06
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@rsutphin
rsutphin / tag_and_push_tag.cap
Last active April 18, 2018 13:08
A capistrano 3 task to tag the repo after every deploy
# Requires Capistrano 3.2 or later
namespace :deploy do
after :finishing, :tag_and_push_tag do
on roles(:app) do
within release_path do
set(:current_revision, capture(:cat, 'REVISION'))
# release path may be resolved already or not
resolved_release_path = capture(:pwd, "-P")
@mislav
mislav / gist:938183
Created April 23, 2011 02:28
Faraday SSL example
connection = Faraday::Connection.new('http://example.com') do |builder|
builder.request :url_encoded # for POST/PUT params
builder.adapter :net_http
end
# same as above, short form:
connection = Faraday.new 'http://example.com'
# GET
connection.get '/posts'
# selenium-webclient does not clean up cookies unless your currently on that page.
module CookieRemover
def self.delete_all(path)
Capybara.current_session.driver.visit(path)
Capybara.reset_sessions!
end
end
After("@external-site") do
CookieRemover.delete_all("http://www.external-site.com")