Skip to content

Instantly share code, notes, and snippets.

View codenamev's full-sized avatar
🌩️

Valentino Stoll codenamev

🌩️
View GitHub Profile
@codenamev
codenamev / pass-fail
Created September 8, 2017 15:22
Pass/Fail command wrapper
#!/usr/bin/env bash
#
# Usage: set any of the following environment variables to get run before
# tests or after success/failure
#
# PASS_FAIL_INIT_COMMAND - is run before tests run
# PASS_COMMAND - is run after tests if they all pass
# FAIL_COMMAND - is run after tests if there are any failrues
set -e
@codenamev
codenamev / upgrade_rubygems.sh
Created August 30, 2017 15:08
Upgrade rubygems for every version of ruby you have installed.
for v in $(rbenv versions --bare); do echo "-----> Upgrading $v"; rbenv shell $v; gem update --system; done
@codenamev
codenamev / .rspec
Last active July 14, 2020 12:26
Lightning fast Rails unit tests in RSpec
-I app

Keybase proof

I hereby claim:

  • I am codenamev on github.
  • I am codenamev (https://keybase.io/codenamev) on keybase.
  • I have a public key ASDzv4NQL0JUfXukZXDekrRgxzinhVKU78V-mLSv9JAewwo

To claim this, I am signing this object:

@codenamev
codenamev / coordinate_delta.js
Created March 22, 2016 15:50
Calculate the largest latitude and longitude deltas needed to fit a set of points into based on an existing center point.
/**
* Given a pre-defined set of coordinates as {latitude: ..., longitude: ...}
* and a pre-defined center point with {latitude: ..., longitude: ...}
* Find the zoom deltas needed for maps
**
// Example:
var center = {latitude: 40.0348483, longitude: -73.00318473};
var points = [{latitude: ..., longitude: ...}, {latitude: ..., longitude: ...}, ...]
@codenamev
codenamev / wait_steps.rb
Last active October 6, 2015 18:12 — forked from jnicklas/wait_steps.rb
Capybara Javascript become_true RSpec matcher
require "timeout"
module WaitSteps
extend RSpec::Matchers::DSL
matcher :become_true do
match do |block|
begin
Timeout.timeout(ENV['CAPYBARA_TIMEOUT'] || Capybara.default_wait_time) do
sleep(0.1) until value = block.call
@codenamev
codenamev / gist:1f44a4d3cafac473d204
Created September 28, 2015 13:52 — forked from JosephPecoraro/shell-execution.rb
Shell Execution in Ruby
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Returns the result of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
# spec/support/rspec_stub_helpers.rb
#
# include in spec_helper.rb like so:
# Rspec.configure do |config|
# config.include RspecStubHelpers
# end
#
# usage example:
# stub_with_fallback(File, :exist?).with(/txt/).and_return(true)
module RspecStubHelpers
@codenamev
codenamev / rollout.rb
Created February 26, 2014 15:04
Easy Feature Rollouts in Rails
module Rollout
def self.features
@features ||= YAML.load_file(Rails.root.join("config", "rollout.yml"))[Rails.env]
end
def self.features=(value)
@features = value
end
def self.active?(key)
require 'open-uri'
require 'json'
language = 'en'
unless article = ARGV.shift
print 'What do you need to know? : '
article = URI::encode gets.chomp
end