Blog Posts

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

N-choose-R

Simple Solution for creating Permutations While working on a research project, i came across a simple task of creating sets of permutation for a given objects. What i thought simple task become tedious after goggling it. I didn’t find any simple solutions for creating a permutations. So i create his one for those who wants simple solution for creating permutations. How to solve complicated problems of creating permutation. Creating permutation of object such as set of colors, basically the task is to find combination of colors

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

Custom Pre-Processor In Rails 3.1

Well long break,Let me guess It over 3 month since I wrote my last post. I’ve been kind of  busy lately not manage to dedicate much time to thing that I do. Rails 3.1.0 is been in picture for a quite a while a now and major feature that been included in Rails 3.1.0 is asset pipeline and pre-processor. For those is who aren’t aware of Rails 3.1.0 asset pipeline and pre-processor there is a very good article on rails

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

Site Footer