Skip to content

Instantly share code, notes, and snippets.

View vicmaster's full-sized avatar

Victor Velazquez vicmaster

View GitHub Profile
@vicmaster
vicmaster / Visible&HiddenTimeOnPage
Created January 22, 2018 18:46 — forked from RitwikGA/Visible&HiddenTimeOnPage
Time On Visible and Hidden Page
var prefix=function() {
var prefixes = ['moz', 'ms', 'o', 'webkit'];
if ('hidden' in document) {
return '';
}
// Loop through each prefix to see if it is supported.
for (var i = 0; i < prefixes.length; i++) {
@vicmaster
vicmaster / home_spec.rb
Created January 11, 2018 07:43 — forked from agmcleod/home_spec.rb
shopify api integration testing
require 'spec_helper'
describe "home" do
before do
@domain = "myshop.myshopify.com"
@token = SecureRandom.hex(16)
@shopify_session = ShopifyAPI::Session.new(@domain, @token)
end
@vicmaster
vicmaster / rbenv-howto.md
Created August 1, 2017 17:51 — forked from MicahElliott/rbenv-howto.md
Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.

aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev

@vicmaster
vicmaster / capybara_cheat_sheet.md
Created November 29, 2016 23:47 — forked from WaKeMaTTa/capybara_cheat_sheet.md
Capybara - Cheat Sheet

Navigating

visit("/projects")
visit(post_comments_path(post))

Clicking links and buttons

@vicmaster
vicmaster / schema.rb
Last active May 13, 2020 03:37
Database Schema
ActiveRecord::Schema.define(version: 20160930181923) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "categories", force: :cascade do |t|
t.string "name"
end
create_table "categories_products", id: false, force: :cascade do |t|
@vicmaster
vicmaster / bowlingkata.md
Last active February 5, 2019 22:42
The Bowling Game Kata

CodeKata: The Bowling Game

My image

The game consists of 10 frames as shown above. In each frame the player has two opportunities to knock down 10 pins. The score for the frame is the total number of pins knocked down, plus bonuses for strikes and spares.

A spare is when the player knocks down all 10 pins in two tries. The bonus for that frame is the number of pins knocked down by the next roll. So in frame 3 above, the score is 10 (the total number knocked down) plus a bonus of 5 (the number of pins knocked down on the next roll.)

A strike is when the player knocks down all 10 pins on his first try. The bonus for that frame is the value of the next two balls rolled.

@vicmaster
vicmaster / Refactoring.md
Last active August 29, 2015 14:20
Refactoring Tips

Refactoring Tips

  • When you find you have to add a feature to a program, and the program's code is not structured in a convenient way to add the feature, first refactor the program to make it easy to add the feature, then add the feature.

  • Before you start refactoring, check that you have a solid suite of tests. These test must be self-checking

  • Refactoring changes the programs in small steps. If you make a mistake, it is easy to find the bug.

  • Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

@vicmaster
vicmaster / gist:e52c4c9cf54b0e3e92ce
Created January 20, 2015 08:49
Mocking Facebook Omniauth

The mock_auth configuration allows you to set per-provider (or default) authentication hashes to return during integration testing. You can set it like so:

 OmniAuth.config.mock_auth[:facebook] = {
    'user_info' => {
      'name' => 'Mario Brothers',
      'image' => '',
 'email' =&gt; 'dpsk@email.ru' },
@vicmaster
vicmaster / gist:8578f33bff9e1f89cfa0
Created January 19, 2015 23:10
Mocking Twitter Omniauth

The mock_auth configuration allows you to set per-provider (or default) authentication hashes to return during integration testing. You can set it like so:

OmniAuth.config.mock_auth[:twitter] = OmniAuth::AuthHash.new({
  :provider => 'twitter',
  :uid => '123545'
  # etc.
})

You can set the :default key to return a hash for providers that haven't been specified. Once you set the mock auth hash and turn on test mode, all requests to OmniAuth will return an auth hash from the mock.

@vicmaster
vicmaster / gist:bd3e84fd55d0fb3f60d3
Last active August 29, 2015 14:13
Mocking Gmail Omniauth

The mock_auth configuration allows you to set per-provider (or default) authentication hashes to return during integration testing. You can set it like so:

  OmniAuth.configure do |config|
    config.test_mode = true
    config.add_mock(:default, {
      :info => {
                  :email => 'foobar@crowdint.com',
                  :name => 'foo',
 :password =&gt; 'qwerty123',