Sometimes you want to only execute a given piece of code if a specific gem has is available. Testing if a constant is defined doesn't aslways work when using autoloading.
Gem.loaded_specs.has_key?('gemname')
There are 20 posts filed in Code Snippets (this is page 2 of 4).
Sometimes you want to only execute a given piece of code if a specific gem has is available. Testing if a constant is defined doesn't aslways work when using autoloading.
Gem.loaded_specs.has_key?('gemname')
Running a rsync command to an old server, specifying a different HostKeyAlgorithm fails very strangely on OpenSuSE
rsync -av --stats --delete '-oHostKeyAlgorithms=+ssh-dss' root@192.168.1.1:/data/path/ /local/path/
rsync: [Receiver] Failed to exec yAlgorithms=+ssh-dss: No such file or directory (2)
rsync error: error in IPC code (code 14) at pipe.c(85) [Receiver=3.2.3]
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in IPC code (code 14) at io.c(228) [Receiver=3.2.3]
No such file or directory.... IPC code (code 14)
What? 🤔
I don't know exactly what's causing this, but a workaround seems to be to use the -e option and to supply this command to your ssh shell
rsync -av --stats --delete -e "ssh -o HostKeyAlgorithms=+ssh-dss" root@192.168.1.1:/data/path/ /local/path/
defaults write com.apple.screencapture type jpg; killall SystemUIServer
# Your options are JPG, TIFF, GIF, PDF and PNG.
Snippet to directly send an e-mail in Rails, without templates
ActionMailer::Base.mail(
from: "gamecreatre@example.com",
to: "receiver@example.com",
subject: "Sample Subject",
body: "Message Body"
).deliver
find . -name config.rb -print0 | xargs -0 grep 'search-thing'