Pular para o conteúdo principal

Postagens

Mostrando postagens com o rótulo Ruby

The Interview Game - Part I

Introduction Do you want to work at a top company of Nasdaq. Ok. Go ahead, but be aware with the interviewing process. It could be not so easy as you would like to. Companies as Amazon, Google, Microsoft have famous hard selective process. So, I will try my best to help you to improve your results. In these posts, I will talk about questions that I have been asked and what solutions I found as more appropriated. To be simpler, I will divide questions in 2 groups: general technical knowledge and algorithm questions. This post is about the first group… General Technical Knowledge What is TCP? What is UDP? What is fundamental difference between each one? TCP is a network protocol that provides reliable, ordered, error-checked delivery of a stream of octets between programs running on computers connected to a local area network, intranet or the public Internet. TCP could be seen as a facility to communication. As TCP, UDP is a network protocol however UDP provides communication with...

Very short REST client in Ruby

I've studied Ruby for 2 years. I feel Ruby like Lego blocks: it is cool, funny, and you could even build a wall with this easily but it could be expensive to make a very solid wall. Anyway, here is a funny to.  Look how simple is to do a Getter REST client in ruby (you could try RESTfolia, restfulie, etc). I call Getter REST client because, it just for GET requests. require "net/http" require "uri" require 'json' require 'methodize' uri = URI.parse("http://localhost:8080/jdb/list") response = Net::HTTP.get_response(uri) json = JSON.parse(response.body) json.extend(Methodize) With authentication, we get: req = Net::HTTP::Get.new(uri.request_uri) req.basic_auth 'user', 'password' res = Net::HTTP.start(uri.hostname, uri.port) {|http| http.request(req) } json = JSON.parse(res.body) json.extend(Methodize) That is it!