Posts

Integrating sunspot solr in rails with tomcat7

Image
At a first glance it seems too easy to integrate a gem in rails but when it comes to Tomcat7 and java dependencies it always end up in  tricky part so here it is follow these simple steps to integrate solr with all it's dependencies. first you need to have java environment sudo apt-get -y install openjdk-7-jdk sudo mkdir /usr/java sudo ln -s /usr/lib/jvm/java-7-openjdk-amd64 /usr/java/default Install tomcat sudo apt - get install tomcat7 sudo apt - get install tomcat7 - admin Then download solr (check for a newer version if you want) sudo wget http : //archive.apache.org/dist/lucene/solr/4.8.1/solr-4.8.1.tgz sudo tar - xvf solr - 4.8 . 1.tgz sudo cp - R solr - 4.8 . 1 / example / / opt / solr Set Solr with Tomcat: sudo cp - R / opt / solr / lib / ext /* /usr/share/tomcat7/lib/ sudo cp /opt/solr/webapps/solr.war /var/lib/tomcat7/webapps/solr.war sudo cp -R /opt/solr /var/lib/tomcat7 sudo chown -R tomcat7:tomcat7 /var/lib/tomcat7/solr service tomcat7 restart ...

Removing blank nodes recursively from nokogiri object

While parsing xml using Nokogiri it contains blank nodes in parent and childre nodes it looks like this #<Nokogiri::XML::Text:0x2d02be8 "\n"> and noblanks removes only blank nodes in parent node which become really hard when  recursively fetching nodes. To remove blank nodes recursively from every children and their children this code will work for you.       module NokoHacks       extend ActiveSupport::Concern       Nokogiri::XML::NodeSet.send :include, NokoHacks       Nokogiri::XML::Text.send :include, NokoHacks       Nokogiri::XML::Element.send :include, NokoHacks       def remove_blank_node         self.children.each do |node|           if node.blank?             node.remove    ...

Controller Concerns in Rails 4

If you setup a Rails 4 app, you’ll notice the app/models/concerns and app/controllers/concerns directories.  Concerns are modules that can be mixed into your models and controllers to share code between them.   Some developers falsely classify mixins as composition when they are actually a form of inheritance.  When you include a module in a class, that module’s methods are added to the inheritance chain just like a parent class’ methods are added to a subclass.  So, don’t think you’ve solved the problem of inheritance by simply splitting your inherited code into separate files! That being said, mixins can be a valuable tool to share code between classes that are otherwise unrelated. Here’s an example of how I chose to use it recently.    I have an admin control...

Installing Wowza Streaming Engine on ubuntu

Image
When you complete the free trial form you will get a screen like this: click whatever the linux version you do have then it will install the .run file. Linux– In the folder where you downloaded the Linux package, run the commands below for your platform. Then, follow the wizard instructions. 64-bit Linux Systems sudo chmod +x WowzaStreamingEngine-4.4.0-linux-x64-installer.run sudo ./WowzaStreamingEngine-4.4.0-linux-x64-installer.run 32-bit Linux Systems sudo chmod +x WowzaStreamingEngine-4.4.0-linux-installer.run sudo ./WowzaStreamingEngine-4.4.0-linux-installer.run If you acquired a new license key, you'll find it in the email that you received  from Wowza Sales. To create a user name and password for an Administrator account. You'll use this account to sign in to the browser-based Wowza Streaming Engine Manager. The user name and password values are case-sensitive. Linux – /usr/local/WowzaStreamingEngine-4.4.0/ (as the root user) Starting and Stopping ...

Highcharts with grouped categories

In highcharts may be some time you need subcategories of a category or more deep nested categories for that you need to use a js file called grouped-categories.js it is a plugin provided by highcharts for grouped categories. this plugin can be downloaded from  https://github.com/blacklabel/grouped_categories/   after download please refer to the home page for examples http://www.highcharts.com/plugin-registry/single/11/Grouped-Categories but even though I followed there documentation but I haven't found it easy for me to implement it in column range chart <div id="container" style="width: 100%; height: 100%;"></div> <script src =''> </script>    var chart = new Highcharts.Chart({             chart: {                 renderTo: "container",           ...

Integration of twilio into rails 4

Image
After some trial and error and much fumbling through online documentation, I managed to get the text notification functionality integrated into my Rails app. Here is a quick summary of the steps I took to get the Twilio API working. I hope that this document will help other developers navigate through the setup process much quicker than I did. Step 1 – Create a Twilio Dev Account You will need a Twilio test account to test your application. There is no charge for the test account and you get a free number to validate your voice or texting application. The account setup process is very straightforward and is explained very well in this video. The speaker does a thorough job walking you through the setup. You can choose the area code for your test number (and avoid long distance charges). You can even choose a number based on a set of letters. You will get an API SID and authorization token to configure your account in your Rails application. I used the Figaro ge...

Difference between remove_method and undef_method

You can remove a method in two easy ways. The drastic Module #undef_method( ) removes all methods, including the inherited ones. The kinder Module #remove_method( ) removes the method from the receiver, but it leaves inherited methods alone. See below 2 simple example - Example 1 using undef_method class A def x puts "x from A class" end end class B < A def x puts "x from B Class" end undef_method : x end obj = B . new obj . x result : undefined method x' for # (NoMethodError) Example 2 using remove_method class A def x puts "x from A class" end end class B < A def x puts "x from B Class" end remove_method : x end obj = B . new obj . x x from A class