Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts

Sunday, February 3, 2013

MessQ : message queue for quickly trying any idea

Past some time while trying up some set-up based on Message Queue at infrastructure... needed a quick to set-up, localhost friendly, network available Message Queue service to try out ideas.
So here is Mess(age)Q(ueue). Something quickly thrown together. Would work later to get it more performance oriented, good to go with smaller projects.

@GitHub:       https://github.com/abhishekkr/messQ
@RubyGems: https://rubygems.org/gems/messQ
_________________________

A Quick Tryout

[+] Install
$ gem install messQ --no-ri --no-rdoc
[+] Start Server (starts at 0.0.0.0 on port#5566)
$ messQ --start
[+] Enqueue user-id & home value to the Queue
$ messQ -enq $USER
$ messQ --enqueue $HOME
[+] Dequeue 2 values from Queue
$ messQ -deq
$ messq --dequeue
[+] Stop Server
$ messQ --stop
_________________________

Via Code

[+] Install
$ gem install messQ --no-ri --no-rdoc
or add following to your Gemfile
gem 'messQ'
require 'messQ'

[+] Start Server
MessQ.host = '127.0.0.1' # default is 0.0.0.0
MessQ.port = 8888 # default is 5566
MessQ.messQ_server

[+] Enqueue user-id & home value to the Queue
MessQ.host = '127.0.0.1' # default is 0.0.0.0
MessQ.port = 8888 # default is 5566
MessQ::Agent.enqueue(ENV['USER'])
MessQ::Agent.enqueue(ENV['HOME'])

[+] Dequeue 2 values from Queue
MessQ.host = '127.0.0.1' # default is 0.0.0.0
MessQ.port = 8888 # default is 5566
puts MessQ::Agent.dequeue
puts MessQ::Agent.dequeue

[+] Stop Server
MessQ::Server.stop

Wednesday, September 19, 2012

ci-go-nfo v0.0.1 : console util for ThoughtWorks' Go CI Server



ci-go-nfo v0.0.1



Just a rubygem console utility to get focussed INFO about your Go Continuous Integration pipeline easily, no more switching again to browsers.

@RubyGems: https://rubygems.org/gems/ci-go-nfo

@GitHub:  https://github.com/abhishekkr/ci-go-nfo


Installation 

$ gem install ci-go-nfo



Usage Ci-Go-Nfo ver.0.0.1 

to set-up credential config for your go-ci
$ ci-go-nfo setup
it asks for
(a.) the location where you want to store your configuration file
(b.) the URL for your Go Server like http://my.go.server:8153
(c.) then username and password (create a read-only a/c for it)



to show go-ci info of all runs
$ ci-go-nfo

to show go-ci info of failed runs
$ ci-go-nfo fail

to show go-ci info of passed runs
$ ci-go-nfo pass

_____

.....more to come


output example:

 $ ci-go-nfo setup
 Store sensitive Go Configs in file {current file: /home/myuser/.go.abril}:

 Enter Base URL of Go Server {like http://:8153}:
                                                           http://my.go.server:8153


 This is better to be ReadOnly account details...

 Enter Log-in UserName: go_user

 Password: restrictedpassword


 $ ci-go-nfo pass
  my_pipeline -> specs -> specs
  Success  for run#2 at 2012-09-19T04:24:38
  details at http://my.go.server:8153/go/tab/build/detail/my_pipeline/10/specs/2/specs

  my_pipeline -> package ->gemify
  Success  for run#1 at 2012-09-19T07:04:39
  details at http://my.go.server:8153/go/tab/build/detail/my_pipeline/10/package/1/gemify

 $ ci-go-nfo fail
  your_pipeline -> smoke -> cukes
  Failure  for run#5 at 2012-09-19T04:24:38
  details at http://my.go.server:8153/go/tab/build/detail/your_pipeline/7/smoke/5/cukes

 $ ci-go-nfo
  my_pipeline -> specs -> specs
  Success  for run#2 at 2012-09-19T04:24:38
  details at http://my.go.server:8153/go/tab/build/detail/my_pipeline/10/specs/2/specs

  my_pipeline -> package ->gemify
  Success  for run#1 at 2012-09-19T07:04:39
  details at http://my.go.server:8153/go/tab/build/detail/my_pipeline/10/package/1/gemify

  your_pipeline -> smoke -> cukes   Failure  for run#5 at 2012-09-19T04:24:38   details at http://my.go.server:8153/go/tab/build/detail/your_pipeline/7/smoke/5/cukes

Friday, June 8, 2012

rss-motor v0.0.4 ~ a rubygem to ease up your RSS interactions

started a new rubygem project 'rss-motor' (http://rubygems.org/gems/rss-motor) to aid all RSS consuming code by providing the entire (or filtered as per choice) of feeds as Array of Hash values per Feed Item.
===============================================
 ||}}  //\  //\ _ ||\/|| ||@|| ~++~ ||@|| ||))
 ||\\ _\\  _\\    ||  || ||_||  ||  ||_|| ||\\
===============================================

I tried it in a new project 'rss-fanatic' (https://github.com/abhishekkr/rss-fanatic) making to help out RSS Feed fanatics collecting required content without pain of browsing/saving/downloading. Though RSS-Fanatic project is just started and shall be usable in some time soon.



Here is just a mini HowTo easily power you code with rss-motor:

First, obviously you'll need to install the gem
$  gem install rss-motor
or if luckily you already have a Gemfile usage, add following lines to it
source "http://rubygems.org" gem 'rss-motor'

Now, currently available engines from the rss-motor
  • simple way of getting all the items as array of key=value
    puts Rss::Motor.rss_items 'http://news.ycombinator.com/rss'

  • get an array of items filtered by one or more keywords
    puts "#{Rss::Motor.rss_grep 'http://news.ycombinator.com/rss', ['ruby', 'android']}"

  • to filter even the data of content available at >link/< field present in item plus normal filter
    puts "#{Rss::Motor.rss_grep_link 'http://news.ycombinator.com/rss', ['ruby', 'android']}"

now go on, ride your own rss-bikes.....

Saturday, March 24, 2012

xml-motor ~ what it is; how & why should you use it

xml-motor ~ what it is; why & how you should use it

Download this article as pdf on what,why,how
http://speakerdeck.com/u/abhishekkr/p/xml-motor-whatwhyhow-this-xml-parsing-rubygem#


or read it all here.....

Late 2011, I started with a new rubygem project for parsing xml, html content.
  @Rubygems: http://rubygems.org/gems/xml-motor
  @GitHub     : https://github.com/abhishekkr/rubygem_xml_motor

Just created it to test out my work at compact, quick & easy xml-parsing algorithm... can see that
  @Slideshare: http://www.slideshare.net/AbhishekKr/xmlmotor

So, currently this is a non-native, completely independent less-than-250 ruby-LOC available as a simple rubygem to be require-d and use in an easy freehand notation and match with any node attributes.

Current Features:
  • Has a single method access to parse require xml nodes from content or file. Use it only if you are gonna parse that xml-content once. For using same xml-content more than once, follow the 3-way step mentioned in examples.
  • It doesn't depend on presence of any other system library, purely non-native.
  • It parses broken or corrupted xml/html content correctly, just for the content it have.
  • Can parse results on looking for node-names, attributes of node or both.
  • Uses free-freehand notation to retrieve desired xml nodes
    if your xml looks like,
    '<library>...
      <book> <title>ABC</title> <author>CBA</author> </book>...
      <book>
        <title>XYZ</title>
         <authors> <author>XY</author><author>YZ</author> </authors></book>...
    </library>'

    and you look for 'book.author',
    then, you'll get back ['CBA', 'XY', 'YZ'];
    what that means is the child-node could be at any depth in the parent-node.
  • Default return mode is without the tags, there is a switch to get the nodes.
    as you'd have seen in above example:
    'CBA' gets sent by default, not 'CBA'
  • To filter your nodes on the basis of attributes, single or multiple attributes can be provided.
  • These attribute searches can be combined up with freehand node name searches.
  • Readme (a bit weird): https://raw.github.com/abhishekkr/rubygem_xml_motor/master/README


Features To Come:
  • Work on making it more performance efficient.
  • Limit over result-nodes retrieved from start/end of matching nodes.
  • Multi-node attribute-based filter for a hierarchical node search.
  • Add dev-knows CSS Selector, it's already present using attribute based search... just need to add a mapping method.


EXAMPLES of usage:
example code to try: https://github.com/abhishekkr/axml-motor/tree/master/ruby/examples
  • say, you have an xml file 'dummy.xml', with data as
    <dummy>
      <ummy>    <mmy class="sys">non-native</mmy>  </ummy>
      <ummy>
        <mmy class="sys">      <my class="sys" id="mem">compact</my>    </mmy>
      </ummy>
      <mmy type="user">    <my class="usage">easy</my>  </mmy></dummy>
  • its available at rubygems.org, install it as
      $ gem install xml-motor
  • include it in your ruby code,
      #!/usr/bin/env ruby
      require 'xml-motor'
  • get the XML Filename and/or XML data available
      fyl = File.join(File.expand_path(File.dirname __FILE__),'dummy.xml')
      xml = File.open(fyl,'r'){|fr| fr.read }
  • One-time XML-Parsing directly from file
      XMLMotor.get_node_from_file(fyl, 'ummy.mmy', 'class="sys"')
         Result: ["non-native", "\n      compact\n    "]
  • One-time XML-Parsing directly from content
      XMLMotor.get_node_from_content xml, 'dummy.my', 'class="usage"'
         Result: ["easy"]
      
  • Way to go for XML-Parsing for xml node searches
      xsplit = XMLMotor.splitter xml
      xtags  = XMLMotor.indexify xsplit


      [] just normal node name based freehand notation to search:

        XMLMotor.xmldata xsplit, xtags, 'dummy.my'
        Result: ["compact", "easy"]
      [] searching for values of required nodes filtered by attribute:
        XMLMotor.xmldata xsplit, xtags, nil, 'class="usage"'
        Result: ["easy"]

      [] searching for values of required nodes filtered by freehand tag-name notation & attribute:

        XMLMotor.xmldata xsplit, xtags, 'dummy.my', 'class="usage"'
        Result: ["easy"]

      [] searching for values of required nodes filtered by freehand tag-name notation & multiple attributes:

        XMLMotor.xmldata xsplit, xtags, 'dummy.my', ['class="sys"', 'id="mem"']
        Result: ["compact"]

Monday, March 5, 2012

messQ ~ just a fun little project providing socket-based Queue service

messQ is a small project started to implement and improve in the areas of message queue mechanisms.

What it does currently? Just a Network Service to be connect and enqueue/dequeue messages.

What it requires? Ruby, terminal and your fingers :)

Git it:           $ git clone git://github.com/abhishekkr/messQ.git
Download:   https://github.com/abhishekkr/messQ/tarball/master

Start messQ server:       $ ruby messQ.rb
  This starts a message queue server at  port 8888.

Enque new message:
  Open a connection at port 8888, then say "enq MESSAGE_TO_BE_QUEUED".

Deque oldest message:
  Open a connection at port 8888, then say "deq". It returns the dequed message.


+++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
 _  _   __   ___  ___     _____
||\/|| //_  //_  //_  _  //  //  messQ v0.0.1beta
||  || \\_  __// __//   //__//\\_  simplistic socket message Q

+++++++++++++++++++++++++++++++++++++++++++++++++++++++


Saturday, November 12, 2011

XML-Motor v0.0.3 ~ mine XML once..... multiple search

released v0.0.3 of xml-motor with following update: http://rubygems.org/gems/xml-motor

Earlier:
  * it just supported one search per every XML data processing
Now:
  * could retrieve processed XML 'Information' once, and search again & again with minimized cost

Now, along-with.....
  * a single method-call search for Tag (w/ or w/o Attribute) in provided XML String or File
You also have the capability to.....
  * fetch the two (or one, depends how you wanna roll) required set of Information mined by providing it XML String
  * then provide that information everytime to search anything, and hence making it way quicker for multiple searches


So, the improved way for multiple searches:

  First, update your 'xml-motor' gem using
    $ gem install xml-motor

  Now, the way to use it
#!/usr/bin/env ruby
require 'xml-motor'

fyl = File.open "myXMLfile.xml"
str = fyl.read
xNodes = XMLMotorEngine._splitter_ str
xTags = XMLMotorEngine._indexify_ xNodes
result1 = XMLMotorEngine.pre_processed_content(
            xNodes, xTags, "h1")

result2 = XMLMotorEngine.pre_processed_content(
            xNodes, xTags, "div", "class='wanted'")

Wednesday, November 9, 2011

[new portable algo] Easy XML Parsing using XML-Motor (currently just in Ruby)

Easy XML Parsing using XML-Motor 
(currently just implemented in Ruby as a Gem)
Using a new, compact algorithm of XML Partsing

===================================================
v 0.0.2
@GitHub: https://github.com/abhishekkr/rubygem_xml_motor

@RubyGems: http://rubygems.org/gems/xml-motor
===================================================

A new short XML Parsing Algorithm implemented in LessThan 200 Ruby lines.
An easy-to-use XML Parser without any Native Dependencies.

[How To Use]

Installing and Loading:
   + $ gem install xml-motor
   + in your ruby code: require 'xml-motor'

Usage:
  + To find values of an xml node from an xml file
      XMLMotor.get_node_from_file [file_name_with_path], [tag_name]
  + To find values of an xml node from an xml string
      XMLMotor.get_node_from_content [xml_data], [tag_name]
  + To find values of an xml node with a tag_name having required attribute
      XMLMotor.get_node_from_content [xml_data], [tag_name], [attr_key=attr_value]

Example Calls As Code:
 + XMLMotor.get_node_from_content "<A i='1'>a<A><B>b<C>c<C><A>ba<A><B>", "A"
     RETURNS: ["a", "ba"]
 + XMLMotor.get_node_from_content "<A i='1'>a<A><B>b<C>c<C><A>ba<A><B>", "B.A"
     RETURNS: ["ba"]
 + XMLMotor.get_node_from_content "<A i='1'>a<A><B>b<C>c<C><A>ba<A><B>", "A", "i='1'"
     RETURNS: ["a"]

===================================================

[Example Code]

require 'xml-motor'

puts XMLMotor.get_node_from_file "eloqjs.htm", "h1"
 
fyl = File.open("elogjs.htm")
XMLData = fyl.read

puts XMLMotor.get_node_from_content XMLData, "div.span"

puts XMLMotor.get_node_from_content XMLData, "div"

===================================================

Thursday, October 20, 2011

http_voodoo_mongo ~ remote control your MongoDB over HTTP

@github: https://github.com/abhishekkr/http_voodoo_mongo

project name: http_voodoo_mongo
platform:     linux
requirement:  ruby

usage: it's a remote controller for your local/remote MongoDB instances working over an HTTP mocking service

What it consists of?

[] a rakefile 'Rakefile' allowing you to auto install and start 'http_voodoo_mongo' as a system service using "rake http_mongo:install" task.

[] a ruby script 'mongo_voodoo.rb' which mocks HTTP Server and allows you control MongoDB using HTTP Requests.

[] a system service script 'mongo_voodoo' which enables you to start||stop||status||restart the Ruby Script as a System Service

*currently I've just added "mongodump" task to it (with & without authorization detail), will slowly add more..... it's all opensource, even you can update if you want


======================================================
a REST API for Remote Controlling MongoDB Server over HTTP using the same 'authentication' as of MongoDB Server

[] need to access the service at HTTP_URL => http://[MongoDB_IP]:30303/

[] Optional GET Request Parameters [name] the username permitted access [pass] the password linked to username [port] the port at which MongoDB Server is running

 ::MongoDB Database Backup 
  http://[MongoDB_IP]:30303/[db_name]?action=dump&dir=[dir]&more_switch=[more_switch]&userniame=[username]&password=[password]&port=[port] 

[] GET Parameters [dir] the directory to take in backup using mongodump [more_switch] any options you wanna add to mongodump command 
======================================================