This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'bundler/setup' | |
Bundler.setup :system | |
require 'pry-byebug' | |
require 'benchmark' | |
require 'benchmark/ips' | |
require 'benchmark/memory' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bot.rb | |
require 'socket' | |
require 'logger' | |
# Create logger | |
log = Logger.new("log.txt") | |
# Required Info | |
PASS = "oauth:xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # "oauth:YourOauthToken" https://twitchapps.com/tmi/ <--- REQUIRED <--- REQUIRED | |
NICK = "botname" # Name of bot <--- REQUIRED <--- REQUIRED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/support/feature_helper.rb | |
RSpec.configure do |config| | |
config.before :all do | |
ENV['PRECOMPILE_ASSETS'] ||= begin | |
case self.class.metadata[:type] | |
when :feature, :view | |
STDOUT.write "Precompiling assets..." | |
system "bundle exec rake assets:precompile > /dev/null 2>&1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:latest | |
MAINTAINER Colby Swandale <colby@taplaboratories.com.au> | |
# update apt cache and install dependencies | |
RUN apt-get update && apt-get install git curl build-essential libssl-dev libreadline-dev zlib1g-dev sqlite3 libsqlite3-dev -y | |
# add app user | |
RUN adduser --gecos '' --disabled-password app | |
# set user to app | |
USER app | |
# set rbenv, ruby-build bin paths | |
ENV HOME /home/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomeORM | |
def self.attributes(*names) | |
if const_defined?(:DynamicAttributes, false) | |
mod = const_get(:DynamicAttributes) | |
else | |
mod = const_set(:DynamicAttributes, Module.new) | |
include mod | |
end | |
mod.module_eval do | |
names.each do |name| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if "foo@example.com" =~ /@(.*)/ | |
$1 | |
else | |
raise "bad email" | |
end | |
# => "example.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def alias_task(name, old_name) | |
t = Rake::Task[old_name] | |
desc t.full_comment if t.full_comment | |
task name, *t.arg_names do |_, args| | |
# values_at is broken on Rake::TaskArguments | |
args = t.arg_names.map { |a| args[a] } | |
t.invoke(args) | |
end | |
end |