How to run examples:
- Run $ createdb nplusonedb to create DB
- Run specs $ rspec demo.rb
# frozen_string_literal: true | |
# This script illustrates caveats of ActiveRecord association autosave | |
# when using a combination of database constrains with a through association (join model) | |
# | |
# ## USAGE | |
# | |
# ruby through_association_autosave.rb | |
# | |
# ## EDGE CASE |
How to run examples:
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam' | |
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes' | |
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no' |
Custom format for displaying bytes as kb
, mb
, gb
or tb
.
Response to a few places on the internet: https://productforums.google.com/forum/#!topic/docs/x_T_N-yRUYg And here: https://stackoverflow.com/questions/1533811/how-can-i-format-bytes-a-cell-in-excel-as-kb-mb-gb-etc
Here is one that I have been using:
[<1000000]0.00," KB";[<1000000000]0.00,," MB";0.00,,," GB"
# This task should be run inside an environment that is already configured to connect to the redis | |
# instance that we're transfering AWAY FROM. | |
# | |
# The task should be handed the URL of the redis instance that we're MOVING TO. | |
# | |
# To run it and pass in the destination Redis you'd do something like this: | |
# rake sidekiq:transfer[redis://...] | |
# | |
# As jobs are added to the destination Redis, they're deleted from the source Redis. This | |
# allows the task to be restarted cleanly if it fails in the middle due to a network error |
require 'spec_helper' | |
describe "Homepage" do | |
before :each do | |
visit "/index.html" | |
end | |
it "has a title" do | |
expect(page).to have_css("h1", text: "GitHub Help") |
# DOCKER-VERSION 0.4.8 | |
FROM ubuntu:12.04 | |
MAINTAINER Deepak Kannan "deepak@codemancers.com" | |
RUN apt-get -y install python-software-properties | |
RUN apt-add-repository -y ppa:brightbox/ruby-ng-experimental | |
RUN apt-get -y update |
require 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
class << self | |
define_method :call do |env| | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func, *attrs)] | |
end |