Confused about Thrift, what does it really do? - ruby

Can someone explain to me what thrift really does?
Say i have a Rails app, and I also have some code written in Scala.
Could thrift be used to generate an interface for my Scala code so that I could call it from Ruby?
Would the Scala code have to be written as a daemon for this to work?
I'm not really sure what Thrift's job is, other than it is used to link between various languages. Does it communicate over a socket?

Thrift is simply a binary serialization protocol. It is cross-language, so you can serialize in Scala, and then unserialize in Ruby.
Then you have to move the data, that's another story. You can use files, play directly with sockets, use a server, etc.

So how is this used for cross-platform development? Still not getting it!
Your Ruby and Scala code can reside on different machines running completely different OSes.

Related

Does exist any BoltDB Ruby gem binding?

Bolt is an amazing embedded key/value database for Go:
https://www.progville.com/go/bolt-embedded-db-golang/
https://github.com/boltdb/bolt
There is any binding (gem) for Ruby language ?
It shouldn't be a driver for any language rather than Go because as you say it's embedded e.i. it works like a Go library that just do data manipulation over a file.
What I know for sure there's HTTP or other network protocols wrappers on top of BoltDB, for example: https://github.com/skyec/boltdb-server and even with Raft: https://github.com/hashicorp/raft-boltdb. As you may see it's pretty easy create your own network layer, I've been thinking in do my own.
Maybe this's not your answer, but it's too big for a comment :)

data driven development framework with Ruby

Does anybody know a good data driven development framework/library/gem for Ruby? I know a ton for Rails but I couldn't find anything for Ruby itself. I have a standalone Ruby app and I want to generate test data and write test cases for different data sets. I don't want to use fixtures. Any suggestions?
You mean something like machinist? The readme mentions it can work without Rails.

Is communication between two ruby processes possible/easy?

If I have a ruby script Daemon that, as it's name implies, runs as a daemon, monitoring parts of the system and able to perform commands which require authentication, for example changing permissions, is there an easy way to have a second ruby script, say client, communicate to that script and send it commands / ask for information? I'm looking for a built in ruby way of doing this, I'd prefer to avoid building my own server protocol here.
Ruby provides many mechanisms for this including your standards such as: sockets, pipes, shared memory. But ruby also has a higher level library specifically for IPC which you can checkout Here, Drb. I haven't had a chance to play around with it too much but it looks really cool.
You may want to look into http://rubyeventmachine.com/

Run a site on Scheme

I can't find this on Google (so maybe it doesn't exist), but I basically'd like to install something on a web server such that I can run a site on Scheme, PHP is starting to annoy me, I want to get rid off it, what I want is:
Run Scheme sources towards UTF-8 output (duh)
Support for SXML, SXLT et cetera, I plan to compose the damned thing in SXML and -> to normal representation on at the end.
Ability to read other files from the server, write them, set permissions et cetera
Also some things to for instance determine the filesize of files, height of images, mime-types and all that mumbo-jumbo
(optionally) connect to a database, but for what I want to do storing the entire database in S-expressions itself is feasible enough
I don't need any fancy libraries and other things that come with it like CMS'es and what-not, except the support for SXML but I'm sure I can just find a lib for that anyway that I can load.
Spark-Scheme has a full web server. If you don't need that, it also has a FastCGI interface so that you can serve Scheme scripts from a web servers like Apache, Lighttpd etc. Spark-Scheme also seem to meet your requirements for database support, UTF-8, file handling and SXML. See the Spark-Scheme Programming Guide (pdf) for more information.
mod_lisp and FastCGI are the only two Apache modules I'm aware of that might work at this time. mod_lisp provides Scheme support because it's architecture is similar to FastCGI, where CGI like parameters are sent over a socket to a second process which remains running as the Scheme backend to the web server. Basically you use one or the other to send CGI like parameters across a socket to a running Scheme backend.
You can find some information about these solutions here. There was another FastCGI like effort called SCGI which demoed a simple SCGI receiver in Scheme called gambit. That code is probably not maintained anymore, but the scheme receiver might be useful.
Back in the Apache 2.0 days, there were more projects playing with scheme and clisp bindings. I don't believe that mod_scheme ever released anything, but if they did, odds are it is not compatible with the modern releases of Apache.
Did you come across Fermion (http://vijaymathew.wordpress.com/2009/08/19/fermion-the-scheme-web-server/)?
If you're looking for a lispy language to develop web applications in, I'd recommend looking into Clojure. Clojure is a lisp variant that's fairly close to scheme; here is a list of some of the differences.
Clojure runs on the Java virtual machine and integrates well with Java libraries, and there's a great webapp framework available called Compojure.
Check out Chicken Scheme's Eggs Unlimited. I think what you want is a combination of the sxml- packages coupled with the fastcgi package.
PLT Scheme has a web application server here: http://docs.plt-scheme.org/web-server/index.html

How can i use RAW Sockets in Ruby?

I'm trying to create a raw socket using Ruby.
The problem is, there isn't anything called "raw socket" there and, on the other hand, the Socket class itself is not fully documented.
Does anybody have some code samples for that kind of socket in Ruby, or maybe some kind of a documentation for that?
By the way, I already know how to work with TCPSocket and TCPServer classes, and what I need is particularly a raw socket.
Google brings up the following result: http://www.ruby-forum.com/topic/90408
Short version:
require 'socket'
rsock = Socket.open(Socket::PF_INET, Socket::SOCK_RAW, Socket::IPPROTO_RAW)
rsock.send(string, flags)
rsock.recv(1024)
More documentation on the various Socket classes: http://www.rubycentral.com/pickaxe/lib_network.html
(The whole raw sockets thing is rather nasty on unices since it usually requires root access. I did not test this code. You may need to construct the whole packet yourself if you're not using IPSocket)
Have a look at the racket gem (https://rubygems.org/gems/racket). It seems to be a bit outdated since the last version was released in 2009 but its also used in the metasploit framework.
Have a look at PacketFu. It is very well maintained and used by the Metasploit Project.

Resources