Postgresql order by field

We have been using  PostgresSQL  in our new product Quiz Stack. Quiz Stack is a SAAS based  product. Which can  conduct,manage,analysis quizzes.We are using rails and postgresql as our backend.It’s subdomain app and hence we decide to use postgresql schema based approach for storing/querying data. While working on one of the feature It was needed to draw some random fixed questions for each user.So each user has different order of questions which  is maintain for each specific user. In Mysql it’s

Continue Reading

Searching Articles In Refinery Cms

I was working with Refinery cms  some times back.I want blogging facility to my CMS. Refinery has various engine which can easily plug and play including blogging. Blog Engine doesn’t facilitate with searching facility default,but it’s easy to add searching facility. Following Snippet will help you to do this. # app/models/refinery/blog/post.rb module Refinery module Blog class Post < ActiveRecord::Base ........ ....... class << self ...... # Considering "refinery" is a prefix so table name is refinery_blog_posts def search(search_string="") Post.includes(:categories,:tags).live.where( "refinery_blog_posts.title like

Continue Reading

PubSub Chat Using HTML5 Web Socket and em-websocket

It’s 5 in the morning and i am tired and its a possibility that i may be writing a long post, Last night i asked my self what is it that i have learned in the las t couple of months and out of nothingness i rememberd a VIDEO CHAT APPLICATION which my friend Viren and I worked on. I thought it might be useful for some of you. When we started, we didnt have enough knowledge where to begin

Continue Reading

Managing daemon using daemon-kit

Hey all, In Previous article i have given short bio of ruby daemon using daemon kit. In this post i am writing about how to manage daemon,how to start/stop a daemon from any directory. We can start a daemon using following way. Go to the directory and give the command. or (You know the difference right; To run it in foreground or background respectively.) But consider this possibility, what if you didn’t want to go to the directory where the

Continue Reading

Understanding Daemonkit

Hey all, Many of us knows what daemons are in linux. These are processes or programs that run in background with little or no user intervention. Now we can write daemons in ruby too. And for doing so we can use Daemon-Kit(https://github.com/kennethkalmer/daemon-kit). Now the daemon can do the task continuously or do it at particular interval of time or do it depending on a particular event. Daemon-Kit provides a skeleton to write these different types of daemons with the help

Continue Reading

acts_as_flying_saucer on Rails 3.1 and Heroku

Just quick post how to use acts_as_flying_saucer with rails 3.1 and Heroku. I was testing acts_as_flying_saucer with rails 3.1.It is working fine so far. but when i have added external style sheet it was hanging on dev mode. and later on i figure out it is external style sheet causing an issue. So i precomplied css and then try to generate pdf it is working. Now it is time to test on heroku. I am using cedar stack and ruby

Continue Reading

Passing arrays using Net-http in Ruby

Hi all, We needed to use net/http of ruby for sending parameters between two modules. We decided to use the get and the post request of http as follows: url = URI.parse(“http://SERVER:PORT”) http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Get.new(“/method_name?parameter=a”) response = http.request(request) In the above get request the parameter “a” is taken to the “http://SERVER:PORT/method_name” and data related to it is queried. url = URI.parse(“http://SERVER:PORT”) http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Post.new(“/method_name”) request.set_form_data({“parameter1” => “a”, “parameter2” => “b”, “parameter3” =>

Continue Reading

Selenium in headless with Xvfb under RUBY

Today I will demonstrate how did I manage to get Selenium (browser => “firefox”) running under headless state (click here to know more on this) . Now we need Xvfb to accomplish this dirty task. For Ubuntu the package is fairly straight forward just type in the command . Under Fedora the same can be achieve using command . For more on Xvfb package  check your distribution provider .

Continue Reading

Site Footer