Skip to content

Instantly share code, notes, and snippets.

View pelted's full-sized avatar

Chris Born pelted

  • Seattle, WA
  • 06:44 (UTC -07:00)
View GitHub Profile
@pelted
pelted / bot.js
Created September 8, 2016 03:24 — forked from ben/bot.js
Something like Hubot, implemented on top of Botkit
require('dotenv').config()
var Fs = require('fs')
var Path = require('path')
var Botkit = require('botkit')
if (!process.env.SLACK_TOKEN) {
console.error('ERROR: this requires "SLACK_TOKEN" to be a valid Slack API token.')
process.exit(-1)
}
@pelted
pelted / index.md
Created April 6, 2017 15:10 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@pelted
pelted / Dockerfile
Created January 17, 2018 20:04 — forked from hubertlepicki/Dockerfile
Ruby 2.4.1, Rails 5.1.1, PostgreSQL, Docker + docker-compose config files
FROM phusion/baseimage:0.9.22
CMD ["/sbin/my_init"]
RUN add-apt-repository -y ppa:brightbox/ruby-ng
RUN apt-get update
RUN apt-get install -y libpq-dev git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs wget autoconf tzdata ruby2.4 ruby2.4-dev rubygems ruby-switch
RUN ruby-switch --set ruby2.4
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
@pelted
pelted / application_helper.rb
Last active February 9, 2021 09:52
Ruby on Rails. Class "active" for menu items based on Path or Controller and Action names
ACTIVE_CLASS = 'is-active'.freeze
def active_for(options)
name_of_controller = options.fetch(:controller) { nil }
name_of_action = options.fetch(:action) { nil }
request_path = options.fetch(:path) { nil }
return ACTIVE_CLASS if request_path && request_path == request.path
if name_of_controller == controller_name
@pelted
pelted / reset.css
Last active October 12, 2021 22:49 — forked from simonausten/reset.css
Email CSS Reset
<style type="text/css">
/****** EMAIL CLIENT BUG FIXES - BEST NOT TO CHANGE THESE ********/
.ExternalClass {
width: 100%;
}
/* Forces Outlook.com to display emails at full width */
.ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div { line-height: 100%; }
/* Forces Outlook.com to display normal line spacing, here is more on that: http://www.emailonacid.com/forum/viewthread/43/ */
@pelted
pelted / migration.md
Created April 21, 2022 16:26 — forked from mariochavez/migration.md
RSpec to Minitest

These are the scripts that I used to migrate from RSpec to Minitest in a Rails aplication.

It is expected for the test suite to be in RSpec 3.x sintax.

  1. Install rename library from Homebrew
  2. Remove RSpec/TestUnit from Gemfile
  3. Add minitest-rails gem
  4. Rename spec forder to test
  5. Add a test_helper.rb file
@pelted
pelted / initializer_notification_center.rb
Created May 16, 2022 18:01 — forked from nhocki/initializer_notification_center.rb
Simple Async ActiveSupport::Notification example
# config/initializer/notification_center.rb
NotificationCenter.queue
NotificationCenter.thread
ActiveSupport::Notifications.subscribe /(.)+\.notification/i do |*args|
NotificationCenter.queue << args
end