1. alias for ‘.call‘
View the code on Gist.
2. Disabling (SSL) Certificate Check from all Gems or Ruby Libraries.
View the code on Gist.
i. Do this only on your local or development environment.
ii. Also the above code only work if the libraries or gem uses ‘Net::HTTP’ API internally,
iii. Tested with HTTParty,Faraday,RestClient not working with Excon (so Excon adapter over Faraday might not work as well).
3. Locking a file using flock.
Firstly, I’ll advise you to read through flock and also this amazing answer by Arjun Shankar.
flock (locking_constant )→ 0 or false
Locks or unlocks a file according to locking_constant (a logical or of the values in the table below). Returns false
if File::LOCK_NB
is specified and the operation would otherwise have blocked. Not available on all platforms.
Locking constants (in class File):
LOCK_EX - Exclusive lock. Only one process may hold an exclusive lock for a given file at a time. LOCK_NBL - Don't block when locking. May be combined with other lock options using logical or. LOCK_SH - Shared lock. Multiple processes may each hold a shared lock for a given file at the same time. LOCK_UN - Unlock.
Example
open(file,'w+') do |file| ## lock the file so that no one can use it. file.flock(File::LOCK_EX) read(file_name).each do |row| file.puts jsonify(row) end end
Thanks.
The post Some Ruby Things. appeared first on Ruby on Rails | Microservices | UI/UX | Android/iOS | Rants and everything else.
This post first appeared on Ruby On Rails | Microservices | UI/UX | Android/, please read the originial post: here