Pipeable Ruby - forget about grep / sed / awk / wc … use pure, readable Ruby!
Network programming with Go
Clojure to JS compiler
PhantomJS - Headless WebKit with JavaScript API
most - alternative to man
I’m checking man pages regularly, so I feel at home when using most.
$ sudo apt-get install most
$ export MANPAGER=”/usr/bin/most -s”
$ man test
And you call that API ?
Hey folks at edno23, are you retarded ? I bet you are.
First of all you provided unofficial API for your crappy twitter-clone which was basically modified feed. Second you said that you won’t support extensive API, because you want your users to use the website instead of applications. Yeah, you are retarded.
Yesterday I saw that these fuckheads realsed official APIs.
1. Why the hell you wrote it in english when your audiance is only bulgarians. You even don’t have english version of the crappy site.
2. Why you copied twitter documentation claiming yours is compatible !?!
3. Do you know what content-type is ?
You want JSON ? No problem, mate. Here is your HTML.
And these guys are paid to do that kind of shit.
Kod - a programmers’ editor for OS X
Today I’ve heard about Kod - “programmers” editor based on Chromium with support for Node.js scripting. You can read all over the place how cools it is and some other shit about this editor. I decided to try it out, but when I downloaded it that’s what happened:
Then I’ve read that Kod is optimized for 10.6 which as you can see I’m not running. How the hell you can optimize a text editor ? This is insane. VIM is fast, Emacs is fast. And we’re talking about 25+ years old editors. I know that Mac is cool and Chrome is cool and Node.js is cool, but this is just wrong. An editor which runs only on 10.6 is the “programmers” editor ? No Linux, no Windows version, damn it, no 10.5 version ?
Syntax highlighting distributed across available CPU cores ? What a joke.
Designer Friendly Templates in Lift
Today I’ve read an article about 7 reasons why “Lift is the most powerful, most secure web framework available today”. One of the reasons got my attention - Designer Friendly Templates. First thing in my mind was - What does “designer friendly template” has to do with security and power of web framework ? The second thought was after reading the argument for the previous statement:
The designers do not have to learn any tag libraries or any other language.
Ok, so it’s easy to learn css class names rather then take 15 minutes to learn template engine like haml or mustache ? Really ?
I’ve looked over Scala/Lift and I think it’s pretty neat combination, but these guys need to learn how to promote their product. Every time I read/hear something from Lifts camp it’s always the same : “Secure, powerfull” and still I don’t really understand why it’s better than Django/Rails for example.
Messaging patterns in ZeroMQ
In the previous post I’ve outlined what to expect from ZeroMQ. In this is post I’ll focus on infrastructure and messaging patterns options ZeroMQ gives us to play with.
Infrastructure
ZeroMQ gives us the choice of how to organize your “network”. In the simple case it’s a “server” who binds to a socket and a “client” who connects to the “server”. The “client” sends a message and the “server” receives it.
It’s possible to bind a socket to an address and at the same time to connect to other end point. This means that we can use it as a forwarder:
Those examples use pipeline messaging pattern and it’s to time to explain how to handle the message flow.
Messaging patterns
ZeroMQ supports four messaging patterns:
- Pipeline - used for distributing data to nodes arranged in a pipeline
- Request-Reply - used for sending requests from a client to one or more instances of a service, and receiving subsequent replies to each request sent
- Publish-Subscribe - used for sending requests from a client to one or more instances of a service, and receiving subsequent replies to each request sent
- Exclusive Pair - advanced pattern used for communicating exclusively between two peers
Pipeline
We can see the usage of pipeline pattern in the previous example. ZMQ::UPSTREAM(ZMQ::PULL) socket only gets data, ZMQ::DOWNSTREAM(ZMQ::PUSH) socket pushes date.
In more complicated manner, a pipeline stage can connect to multiple nodes. If so data is automatically load-balanced among all connected nodes.
NOTICE: ZMQ::DOWNSTREAM/ZMQ::UPSTREAM are deprecated. The new names of the socket types are ZMQ::PUSH/ZMQ::PULL. Right now the names are not updated in zmq ruby gem, but in ffi version everything is working correctly.
Request-Reply
Making request
- create ZMQ::REQ socket and connect to server
- send a message using send method
- capture reply with recv method
Accepting request and sending reply
- create ZMQ::REP socket and bind on specific address/port
- receive message with recv method
- send a reply with send method
It’s also possible to make more than one request per socket. Just use connect on different addresses/ports.
In the following example we’re sending 10 numbers as 10 separate requests, the server get the request(the number), multiply it and then send it back to the client.
Publish-Subscribe
It’s the well know pattern. And this is how it works in ZeroMQ
Publisher
- Create a ZMQ::PUB socket and bind it on address/port
- Publish data using send
Subscriber
- Create a ZMQ::SUB socket and connect it to the publisher
- Set the filter of the received messages
- Receive messages with recv
Let assume that we have news for the revenue of Microsoft, Apple, Google and Oracle. Our publisher will broadcast news for all of these companies, but our subscriber is interested only in Google’s revenue:
Using setsockopt method we set the filter to get only news about Google. If we don’t provide filter, the subscriber wont’ get any news. If we set the filter to empty string, the subscriber will get all the news form the publisher.
Exclusive Pair
Simple enough - bidirectional communication, no routing or filtering. Looks like regular socket. ZMQ::PAIR socket can only be connected to a single peer.
Wrapping up
In the next chapter I’ll use the knowledge of this one to write a simple Hello World app in Ruby - a chat server. Stay tuned.
PS: Feel free to write me at mitko.kostov[at]gmail.com if you find some rubbish statement.