Skip to content

Instantly share code, notes, and snippets.

@jayzz55
jayzz55 / Gemfile
Last active August 29, 2015 14:10 — forked from eliotsykes/Gemfile
# Add poltergeist gem to Gemfile, in :test group,
# then run `bundle` to install
group :test do
...
gem 'poltergeist'
...
end

#Heroku, Ruby on Rails and PhantomJS

In this post, I’m going to show you how to modify an existing Ruby on Rails app running on Heroku’s Cedar stack to use PhantomJS for screen scraping. If you’ve never heard of PhantomJS, it’s a command-line WebKit-based browser (that supports JavaScript, cookies, etc.).

Let’s get started. This is a high-level overview of the required steps:

  • Modify your app to use multiple Heroku buildpacks.
  • Extend your app to use both the Ruby as well as the PhantomJS buildpacks.
  • Confirm that everything worked.
@jayzz55
jayzz55 / PT-Melb.md
Last active August 29, 2015 14:17 — forked from mattswann/PT-Melb.md

###PT PLANNER ####Melbourne Public Transport Journey Planner

There are 3 train lines:

The Alamein line has the following stops: Flinders Street, Richmond, East Richmond, Burnley, Hawthorn, and Glenferrie.

The Glen Waverly line has the following stops: Flagstaff, Melbourne Central, Parliament, Richmond, Kooyong and Tooronga.

The Sandringham line has the following stops: Southern Cross, Richmond, South Yarra, Prahran, and Windsor.

@jayzz55
jayzz55 / 0_reuse_code.js
Last active August 29, 2015 14:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

###The Ultimate Life Decider Never make a decision again!

####Part One a. - The Coin of Inevitability


  1. Create a file called decider.js
  2. Write a function called coinFlip that 'console.logs' HEADS or TAILS when called
  3. Add a counter that declares WINNER in the console when either HEADS or TAILS is flipped 5 times.

Queen Attack

In the game of chess, a queen can attack pieces which are on the same row, column, or diagonal.

A chessboard can be represented by an 8 by 8 array.

Write a program that positions two queens on a chess board and indicates whether or not they are positioned so that they can attack each other.

require 'minitest/autorun'
require 'minitest/reporters' # optional
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new() # optional
require_relative './allergies'
class AllergiesTest < MiniTest::Test

##Rollin with the Install

####Stage 1 - Ruby Version Manager

go to rvm.io copy and paste the two commands

 commands to copy and paste in terminal

@jayzz55
jayzz55 / pubkeys_concept.ex
Last active November 19, 2015 04:37
PubKeys - concept
def main(options) do
path = files_path(Mix.env)
files_list = System.cmd("ls", [path]) |> elem(0) |> String.split("\n")
case options do
["--help"] -> IO.puts @instructions
["--deploy-all"] -> deploy_all(files_list, path)
["--add", ssh_key] -> add_user_key(ssh_key, files_list, path)
["--remove", ssh_key] -> remove_user_key(ssh_key, files_list, path)
_ -> IO.puts "Unrecognized input.\n#{@instructions}"
@jayzz55
jayzz55 / PubKeys_deploy_all.ex
Created November 19, 2015 04:37
PubKeys_deploy_all
def deploy_all(files_list, path) do
files_list
|> Enum.reject(&empty?(&1))
|> Enum.map(&scp_to_server(&1, path))
end