-
Install and run an MQTT server (mosquitto is a good choise)
-
Install mqtt and ncurses-ruby gems
sudo gem install ruby-mqtt ncurses-ruby
-
Run the client
ruby ./mqtt-chat.rb
| import java.lang.Process; | |
| import java.io.BufferedReader; | |
| import java.io.IOException; | |
| import java.io.InputStreamReader; | |
| import java.util.ArrayList; | |
| import java.util.Arrays; | |
| import java.util.List; | |
| class Test { | |
| static public class OsProcess { |
[[7,"Qix"],[5,"Bar"],[3,"Foo"]].inject(_.to_s){|r,d|i,k=d;r[/^/]=(_%i==0)?k:"";r.gsub!(/#{i}/,k);(r[/\D/].nil?)?r:r.tr("0124689","")}
This is Ruby \o/
No! Wait, this one is better :
((f={3=>:Foo,5=>:Bar,7=>:Qix}).sort.collect{|i,j|_%i==0?j:""}+_.to_s.split(//).collect{|c|f[c.to_i]||""}).join.sub(/^$/,_.to_s) #foobarqix
| (setq *fbq* (make-hash-table)) | |
| (setf (gethash 3 *fbq*) "Foo") | |
| (setf (gethash 5 *fbq*) "Bar") | |
| (setf (gethash 7 *fbq*) "Qix") | |
| (defun foo (v) ( | |
| let ((div "")) | |
| (maphash #'(lambda (key value) | |
| (cond ((= (mod v key) 0) | |
| (setf div (concatenate 'string value div)) |
| #!/bin/sh | |
| _() { | |
| [ $(expr $V % $1) == 0 ] && R=$(echo $R$2) | |
| } | |
| foobarqix() { | |
| _ 3 "Foo";_ 5 "Bar";_ 7 "Qix" | |
| R=$(echo $R$V | sed -e 's/3/Foo/g' | sed -e 's/5/Bar/g' | sed -e 's/7/Qix/g' | sed -e 's/[0-9]//g') | |
| [ "Z$R" == "Z" ] && R=$V | |
| } |
| #!/usr/bin/env ruby | |
| require 'tempfile' | |
| require 'rubygems' | |
| require 'gtkmozembed' | |
| require 'markdown' | |
| class MarkdownViewer < Gtk::Window | |
| def initialize(file) | |
| super | |
| #!/usr/bin/ruby | |
| require 'rubygems' | |
| require 'mp3info' | |
| require 'readline' | |
| TAGS = { | |
| "AENC" => "Audio encryption", | |
| "APIC" => "Attached picture", | |
| "COMM" => "Comments", |
| #!/bin/sh | |
| usage() { | |
| echo "$0 /path/to/image.dmg [/output/path]" | |
| exit 0 | |
| } | |
| DMG=$1 | |
| OUTPUT=$2 |
| #define CONCATENATE(arg1, arg2) arg1##arg2 | |
| #define IN_NARG(...) IN_NARG_(__VA_ARGS__, IN_RSEQ_N()) | |
| #define IN_NARG_(...) IN_ARG_N(__VA_ARGS__) | |
| #define IN_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, N, ...) N | |
| #define IN_RSEQ_N() 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 | |
| #define IN_1(x, v, ...) ((v) == (x)) | |
| #define IN_2(x, v, ...) ((v) == (x)) || IN_1(x, __VA_ARGS__) | |
| #define IN_3(x, v, ...) ((v) == (x)) || IN_2(x, __VA_ARGS__) |
| #!/bin/sh | |
| # This script is a very naive XML parser for sh | |
| # ... | |
| # This fontion is called once for each file. It initialize the parser | |
| # | |
| # Type: private | |
| # Parameters: |