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
defmodule Files do | |
def run do | |
process_file File.read("hello.txt") | |
end | |
def process_file({:ok, contents}) do | |
IO.puts "File contents are here:" | |
IO.puts contents | |
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
# I am pasting that into setup steps | |
# binary provided by the amazing Codeship.io support | |
PHANTOMJS_URL="https://s3.amazonaws.com/codeship.io/checkbot/binaries/phantomjs_2.0.1" | |
set -e | |
rm -rf ~/.phantomjs | |
wget --continue "${PHANTOMJS_URL}" -O "${HOME}/cache/phantomjs" | |
ln -s "${HOME}/cache/phantomjs" "${HOME}/bin/" | |
chmod +x "${HOME}/bin/phantomjs" |
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
module XPath | |
module HTML | |
def link(locator) | |
locator = locator.to_s | |
link = descendant(:a) #[attr(:href)] | |
link[attr(:id).equals(locator) | string.n.is(locator) | attr(:title).is(locator) | descendant(:img)[attr(:alt).is(locator)]] | |
end | |
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
["2013-08-01", 27], | |
["2014-03-21", 24], | |
["2014-09-05", 18], | |
["2013-07-05", 18], | |
["2014-08-02", 16], | |
["2014-01-22", 16], | |
["2013-11-07", 13], | |
["2012-12-29", 13], | |
["2013-12-06", 13], | |
["2015-01-01", 12], |
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
// example using the raf module from npm. try changing some values! | |
var requestAnimationFrame = require("raf") | |
var canvas = document.createElement("canvas") | |
canvas.width = 500 | |
canvas.height = 500 | |
document.body.appendChild(canvas) | |
var context = canvas.getContext("2d") |
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
def create | |
session[:user_account_params].stringify_keys!.merge!(params[:user_account]) if params[:user_account] | |
session[:user_account_params]["browser_locales"] = request.env['HTTP_ACCEPT_LANGUAGE'] | |
@user_account = UserAccount.new(session[:user_account_params]) | |
@user_account.current_step = session[:user_account_step] | |
if @user_account.valid? | |
if params[:back_button] | |
@user_account.previous_step | |
elsif @user_account.last_step? |
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 ApplicationController < ActionController::Base | |
... | |
def intranet | |
@intranet ||= Intranet.for_employee(current_user) | |
end | |
helper_method :intranet | |
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
def seconds_to_units(t) | |
mm, ss = t.divmod(60) | |
hh, mm = mm.divmod(60) | |
"#{hh}:#{mm}:#{ss}" | |
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
source :rubygems | |
# We are not loading Active Record, nor Active Resources etc. | |
# We can do this in any app by simply replacing the rails gem | |
# by the parts we want to use. | |
gem "actionpack", "~> 4.0" | |
gem "railties", "~> 4.0" | |
gem "tzinfo" | |
# Let's use thin |
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
gem 'foreman', require: false | |
gem 'rvm-capistrano', require: false |