Skip to content

Instantly share code, notes, and snippets.

View paulccarey's full-sized avatar
🙂

Paul Carey paulccarey

🙂
  • Indeed.com
  • Liverpool/Manchester, UK
View GitHub Profile
@matthieuprat
matthieuprat / capybara-eventually.rb
Created October 7, 2016 14:49
Capybara eventually helper
def eventually(timeout: Capybara.default_max_wait_time, interval: 0.2)
Timeout.timeout(timeout) do
begin
next yield
rescue Minitest::Assertion, Capybara::ExpectationNotMet
sleep interval
retry
end
end
rescue Timeout::Error
@miguelmota
miguelmota / mount_fat32.sh
Last active March 13, 2024 15:49
OS X mount FAT32 partition with read/write permissions
diskutil list
diskutil unmount /dev/disk0s6
sudo mount -w -t msdos /dev/disk0s6 /Volumes/data
@leftclickben
leftclickben / gist:322b7a3042cbe97ed2af
Last active June 7, 2023 10:58
Steps to migrate from SVN to GitLab

Steps to migrate from SVN to GitLab

This process worked for me. I take no responsibility for any damage or loss incurred as a result of following or not following these steps or, for that matter, anything else you might do or not do.

Setup

  • SVN is hosted at svn.domain.com.au.
  • SVN is accessible via http (other protocols should work).
  • GitLab is hosted at git.domain.com.au and:
@kristopherjohnson
kristopherjohnson / install_wine_homebrew_osx.sh
Last active February 27, 2019 14:19
Commands to set up OS X to run Enterprise Architect (assumes Homebrew is installed)
# Install Wine and other necessary components using Homebrew
brew install wine
brew install winetricks
brew install cabextract
# Instructions from http://www.sparxsystems.com/support/faq/enterprise-architect-WINE.html
winetricks allfonts
winetricks msxml
winetricks msxml3
winetricks msxml4
@demisx
demisx / active_record_objects_autosave.md
Last active April 29, 2024 09:02
When Active Record Child Objects are Autosaved in Rails

belongs_to:

  1. Assigning an object to a belongs_to association does not automatically save the object. It does not save the associated object either.

has_one:

  1. When you assign an object to a has_one association, that object is automatically saved (in order to update its foreign key).
  2. In addition, any object being replaced is also automatically saved, because its foreign key will change too
  3. If either of these saves fails due to validation errors, then the assignment statement returns false and the assignment itself is cancelled.
  4. If the parent object (the one declaring the has_one association) is unsaved (that is, new_record? returns true) then the child objects are not saved. They will automatically when the parent object is saved.
@seyhunak
seyhunak / seeds.rb
Created December 7, 2013 14:54
Rails - Import SQL file as seed
unless Rails.env.production?
connection = ActiveRecord::Base.connection
connection.tables.each do |table|
connection.execute("TRUNCATE #{table}") unless table == "schema_migrations"
end
sql = File.read('db/import.sql')
statements = sql.split(/;$/)
statements.pop
@nhance
nhance / method_logger.rb
Created September 6, 2012 12:58
Rails compatible method logging. Use this to log all calls to instance methods of a class to the log.
Model.new.foo
@guzart
guzart / download
Created March 21, 2012 17:14
bash: Download and Compress Rails API
#!/bin/bash
rm -rf api.rubyonrails.org/
wget -r -k -p http://api.rubyonrails.org/
rm rails_api.rar
rar a -r rails_api.rar api.rubyonrails.org/
@mxcl
mxcl / uninstall_homebrew.sh
Created August 26, 2011 11:25
Uninstall Homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e