Skip to content

Instantly share code, notes, and snippets.

View tdegrunt's full-sized avatar

Tom de Grunt tdegrunt

View GitHub Profile
@tdegrunt
tdegrunt / .gitignore
Created May 22, 2018 07:13
Ruby programming with VS Code
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
@tdegrunt
tdegrunt / readme.md
Created April 5, 2018 09:37 — forked from maxivak/readme.md
Integrating Gem/Engine and Main Rails App
@tdegrunt
tdegrunt / async_console.rb
Created February 5, 2018 14:35 — forked from postmodern/async_console.rb
An asynchronous Console that can evaluate Ruby code in the background.
require 'thread'
class AsyncConsole
#
# Creates a new Asynchronous Console, within the given context.
#
# @param [Module] context
# The context to evaluate code within.
#
Verifying my Blockstack ID is secured with the address 1MF4R8dVMT4AQB1KGxmSqBv1HYbRffW3Zh https://explorer.blockstack.org/address/1MF4R8dVMT4AQB1KGxmSqBv1HYbRffW3Zh
@tdegrunt
tdegrunt / better_image_tag.rb
Created October 30, 2017 11:28 — forked from pichfl/better_image_tag.rb
Liquid Image Tag for Jekyll
# A simple plugin for Jekyll that allows you to use {% url "alt text" %} to add images to your posts.
# It will automatically check those images for width and height.
#
# Requires http://imagesize.rubyforge.org/
require 'image_size'
require 'open-uri'
module Jekyll
@tdegrunt
tdegrunt / brew-pgupgrade.sh
Created October 26, 2017 10:00
Auto-upgrade homebrew's PostgreSQL data directory
#!/usr/bin/env bash
old=$1
new=$2
if ! [ "$new" ]; then
new=`psql -V | cut -d' ' -f3`
fi
if ! [ "$old" ]; then
echo "Usage: pgupgrade.sh <old-version> [new-version]"
@tdegrunt
tdegrunt / env.rb
Created April 20, 2017 17:38
Browserstack remote capabilities and tunnel setup (capybara with cucumber)
Capybara.app_host = "http://localhost:3001"
Capybara.run_server = false
@tdegrunt
tdegrunt / agent.rb
Created February 25, 2017 23:03 — forked from genericsteele/agent.rb
Custom Assertions
class Agent < ActiveRecord::Base
validates :first_name, :last_name, :email, presence: true
validates :email, uniqueness: true
has_many :missions
scope :on_assignment, -> { Agent.joins(:missions).where(missions: { status: 'active' }) }
scope :not_on_assignment, -> { where.not(id: Agent.on_assignment.pluck(:id)) }
def name
"#{first_name} #{last_name}"
end
@tdegrunt
tdegrunt / test_mail_purge.rb
Created February 25, 2017 19:06 — forked from adamsanderson/test_mail_purge.rb
An example of using MiniTest::Mock
require 'minitest/mock'
require 'minitest/unit'
require 'date'
MiniTest::Unit.autorun
class TestMailPurge < MiniTest::Unit::TestCase
class MailPurge
def initialize(imap)
@imap = imap
@tdegrunt
tdegrunt / tasks.json
Created February 15, 2017 12:51
Visual Studio Code - Ruby / Rails tasks
{
"version": "0.1.0",
"tasks": [
{
"isShellCommand": true,
"taskName": "bundle install",
"command": "bundle",
"args": ["install"],
"suppressTaskName": true
},