Skip to content

Instantly share code, notes, and snippets.

# add in a before(:all) in your test suite for example
ls_command = [
"-rw-r--r-- 1 ftp ftp 671686268 Feb 21 03:14 some_file",
"drw-r--r-- 1 ftp ftp 671686268 Feb 21 03:14 directory",
# ...
]
class FakeFtp < OpenStruct
# So that for example fake_ftp.chdir("path/to/dir") will be send as fake_ftp.chdir
def method_missing(method, *args)
@varyonic
varyonic / docker-compose.yml
Last active May 18, 2021 13:18
Capybara standalone Selenium Chrome config
web:
build: .
volumes:
- .:/opt/myapp
ports:
- '3000:3000'
links:
- db
- redis
- selenium
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@lulalala
lulalala / banner.rb
Last active January 14, 2019 12:58 — forked from matheusvetor/banner.rb
Carrierwave image model validation on image dimensions/height/width.
class Banner < ActiveRecord::Base
attr_accessor :image_width, :image_height
mount_uploader :image, ImageUploader
validate :check_dimensions, :on => :create
def check_dimensions
if !image_cache.nil? && (image.width < 300 || image.height < 300)
errors.add :image, "Dimension too small."
end
end