Skip to content

Instantly share code, notes, and snippets.

huezoaa / ruby_ftp_example.rb
Created Apr 17, 2020 — forked from 3dd13/ruby_ftp_example.rb
Sample code of using Ruby Net::FTP library. Login to FTP server, list out files, check directory existence, upload files
View ruby_ftp_example.rb
require 'net/ftp'
CONTENT_SERVER_FTP_LOGIN = "saucy-ftp-server-login"
CONTENT_SERVER_FTP_PASSWORD = "saucy-ftp-server-password"
# LOGIN and LIST available files at default home directory, CONTENT_SERVER_FTP_LOGIN, CONTENT_SERVER_FTP_PASSWORD) do |ftp|
files = ftp.list
huezoaa / custom_headers.rb
Last active Aug 29, 2015 — forked from aliang/custom_headers.rb
setting custom headers with ruby net/http
View custom_headers.rb
# this was surprisingly difficult to find, the documentation and API is poor
require "net/http"
require "uri"
url = URI.parse("")
req =
req.add_field("X-Forwarded-For", "")
# For content type, you could also use content_type=(type, params={})
View map_hash_to_hash.rb
def transform_hash(original, options={}, &block)
original.inject({}){|result, (key,value)|
value = if (options[:deep] && Hash === value)
transform_hash(value, options, &block)