Posts

Install Redis on Amazon EC2 Linux AMI or CentOS

Complete guide on installing and configuring Redis 2.6 as a service on Amazon EC2 running with Amazon Linux AMI or CentOS. The procedure should apply to Fedora and Red Hat distributions as well. In case you feel like skipping these steps, feel free to use the Github Script for an even simpler installation and configuration of Redis as a service. By the way, a hearty thanks to John over at SaltWebsites  for his awesome tutorial. Also, for a tutorial on installing Redis 2.6 as a service on Ubuntu and Windows, please click here and here respectively. Another tutorial on installing and using the C- client library for Redis, Hiredis is provided here . 1. Install Linux updates, set time zones, followed by GCC and Make sudo yum -y update sudo ln -sf /usr/share/zoneinfo/America/Indianapolis \ /etc/localtime sudo yum -y install gcc make 2. Download, Untar and Make Redis 2.6 wget http://redis.googlecode.com/files/redis-2.6.0-rc3.tar.gz tar xzf redis-2.6.0-rc3.tar.gz cd redis-2.

copy ssh key on server

cat ~/.ssh/id_rsa.pub | ssh <user>@<hostname> 'cat >> .ssh/authorized_keys && echo "Key copied"'

Capistrano setting for stagin and productin in deploy.rb

# Required variables set :application, "app" task :staging do   set :user, "root"   set :environment, "staging"   set :repository, 'git@github.com:app.git'   set :revision, "origin/#{environment}"   set :domain,    "root@server2180.railsvserver.de"   set :deploy_to, "/var/www/#{application}" end task :prod do   set :user, "app"   set :environment, "production"   set :repository, 'git@github.com:app.git'   set :revision, "origin/#{environment}"   set :domain,    "user@162.13.152.39"   set :deploy_to, "/var/www/#{application}" end namespace :vlad do   desc "Symlinks the upload folder"   remote_task :symlink_assets, :roles => :web do     %w(uploads).each do |file|       run "ln -s #{shared_path}/#{file} #{current_path}/public/#{file}"     end        run "ln -s #{current_path}/public/images #{current_path}/public/assets"   end   des

assign sudo permission

adduser deploy usermod -a -G sudo deploy

Go to multiple actions by click on same image

      <img src="/assets/social_links.png" width="160" height="40" alt="Social" usemap="#social">       <map name="social">         <area shape="twitter"  coords="0,0,40,40" alt="twitter" href="#-" title="twitter">         <area shape="facebook" coords="40,0,80,40" alt="facebook" href="#-" title="facebook">          <area shape="youtube" coords="80,0,120,40" alt="youtube" href="#-" title="youtube">          <area shape="instagram" coords="120,0,160,40" alt="instagram" href="#-" title="instagram">       </map>

Steps for installing ruby on rails successfully on Ubuntu

The first step is to install some dependencies for Ruby. sudo apt-get update sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties sudo apt-get install libmysqlclient-dev sudo apt-get install libpq-dev sudo apt-get install imagemagick sudo apt-get install libmagickwand-dev The installation for rvm is pretty simple: sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev curl -L https://get.rvm.io | bash -s stable source ~/.rvm/scripts/rvm echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc rvm install 2.1.2 rvm use 2.1.2 --default ruby -v The last step is to tell Rubygems not to install the documentation for each package locally echo "gem: --no-ri --no-rdoc" > ~/.gemrc Installing Rails sudo add-apt-repository ppa:chri

create user using factory in ruby on rails

factories.rb:- ------------------- FactoryGirl.define do   factory :user do     email ' user@example.com '     password 'welcome'   end end user_spec.rb:- --------------------- require 'spec_helper' describe User do   it 'has a valid factory' do     FactoryGirl.create :user   end end

open other instance of skype

skype --dbpath=~/.Skype2

Can't verify CSRF token authenticity in ruby on rails

class ApplicationController < ActionController::Base protect_from_forgery with : : null_session , if : Proc . new { | c | c . request . format =~ % r { application / json } } end Now it handles additional content types terms such as: application/json; charset=utf-8

Edit contents in github pages using prose

Hi Guys, http://prose.io  is the tool to provide github pages editing functionality. To open you github pages for editing you just need to add github username with prefix # like as http://prose.io/# githubusernam e/

searching like facebook tag in autocomplete

<div id="post_content" contenteditable="true" class="post_content_textarea">         </div> <script> var availableTags = <%= raw @users %>;  var availableTags_category = <%= raw @categories %>;    function split(val) {       return val.split(/@\s*/); } function split2(val) {       return val.split(/#\s*/); } function extractLast(term) {     return split(term).pop(); } function extractLast2(term) {     return split2(term).pop(); }   $(".post_content_textarea")   // don't navigate away from the field on tab when selecting an item   .bind("keydown", function(event) {       if (event.keyCode === $.ui.keyCode.TAB && $(this).data("autocomplete"). menu.active) {           event.preventDefault();       }   }).autocomplete({       minLength: 0,       source: function(request, response) {           var term = request.

search by @ symbol in autocomplete

<div id="post_content" contenteditable="true" class="post_content_textarea">         </div> <script> var availableTags = <%= raw @users %>;    function split(val) {       return val.split(/@\s*/); } function extractLast(term) {     return split(term).pop(); }   $(".post_content_textarea")   // don't navigate away from the field on tab when selecting an item   .bind("keydown", function(event) {       if (event.keyCode === $.ui.keyCode.TAB && $(this).data("autocomplete"). menu.active) {           event.preventDefault();       }   }).autocomplete({       minLength: 0,       source: function(request, response) {           var term = request.term,               results = [];           if (term.indexOf("@") >= 0) {                              term = extractLast(request.term);               if (term.length >

Fwd: Steps to add dynamic tags to a post

Image
Hello, I have creating steps guide to add tags in jekyll with post 1.   Open   http://prose.io/# usern ame 3.  When you nevigate above url then a window will be open where bottom right corner there is a toggle button called “Authorized github”. Click this button and enter valid Github username and password. ​ Add tags in post:- 1. click on _posts folder the new page will open like this ​ 1.1 . Here you can edit existing posts or create new posts..suppose you want to edit " 2014-08-21-Seamus Kraft.md " then click on this post.then new page will open like this. ​ 1.2 If you want to add or edit tag then,click on meta data icon ,then view will be change.like this  ​ Here you can change tag,date , Author name,layout etc. 1.3 what ever tag you mentioned here ,those will be show in thinking page. 1.4 You can also put multiple tag you can add multiple tag like this --------- layout: default tags: - open - privacy - etc t

Share parameter with facebook share button

<div id="fb-root"></div> <script>(function(d, s, id) {   var js, fjs = d.getElementsByTagName(s)[0];   if (d.getElementById(id)) return;   js = d.createElement(s); js.id = id;   js.src = "// connect.facebook.net/en_US/ sdk.js#xfbml=1&appId= 676891735738912&version=v2.0 ";   fjs.parentNode.insertBefore( js, fjs); }(document, 'script', 'facebook-jssdk')); </script> <div class="col-xs-4 col-md-2"> <%= link_to "F Share","#",:id => "share_button"%> <script type="text/javascript">     var talent_id = 1         $(document).on('click','# share_button',function(e){             e.preventDefault();             FB.ui(             {                 method: 'feed',                 link: '<%= root_url%>',                                     name: 'Your friend "your name&

bold matched character form word in autocomplete

<script > $(document).ready(function(){     var termTemplate = "<span class='ui-autocomplete-term'>% s</span>"; var availableTags = <%=raw  @name_json %>; $( ".txt-search" ).autocomplete({     source: function(req, responseFn) {         var re = $.ui.autocomplete.escapeRegex( req.term);         var matcher = new RegExp( "^" + re, "i" );         var a = $.grep( availableTags, function(item,index){             return matcher.test(item);         });         responseFn( a.slice(0, 5) );       },   select: function(event, ui){         $('.txt-search').val(ui.item. value);         $(".search-form").submit()     },     search  : function(){$('.autocomplete- animation').show();},     open: function (e, ui) {             var             acData = $(this).data('autocomplete'),                             styledTerm = termTemplate.replace('%s', acData.term);                 acData.m

bold matched word in autocomplete jquery with loader

<div class="col-md-12 search_panel">                <form>                <input type="text "class=>"txt-search" name="search">                 <span class="autocomplete-animation" ><img id="ajaxanimation" src="../assets/loader.gif")/>< /span>                 </form>             </div> <script > $(document).ready(function(){     var termTemplate = "<span class='ui-autocomplete-term'>% s</span>"; var availableTags = [ "ActionScript" , "AppleScript" , "Asp" , "BASIC" , "C" , "C++" , "Clojure" , "COBOL" , "ColdFusion" , "Erlang" , "Fortran" , "Groovy" , "Haskell" ,

create environment variables files in rails

config/environment_variables. yml :- development:   DEV_TWITTER_KEY: AQ01uxmLsGnCU1SpkuwrwPc9l   DEV_TWITTER_SECRET: srSrs9fc1zDy6enD1zsHE1zdyiMGMn fp8yYePjMx8CmemVNYO3   DEV_FACEBOOK_KEY: '1374702796089833'   DEV_FACEBOOK_SECRET: 2aa34dfb69c3749dcd646a0a4239a0 72 production:   TWITTER_KEY: cFXhhlfWanscuTkldGkM5GVLC   TWITTER_SECRET: 5k3ysJVPfEEgQMzaZ6aN7QqOtfIbUx OUKIJVvTf9kMcdqZLjEH Load environment variables file:- config/initializer/ environment_variables.rb:- module EnvironmentVariables   class Application < Rails::Application     config.before_configuration do       env_file = Rails.root.join("config", 'environment_variables.yml'). to_s       if File.exists?(env_file)         YAML.load_file(env_file)[ Rails.env].each do |key, value|           ENV[key.to_s] = value         end # end YAML.load_file       end # end if File.exists?     end # end config.before_configuration   end # end class end # end module Now we can use this like as :-  provider :

reset heroku database

heroku pg:reset DATABASE --confirm APPNAME

google map with ajax

<div id="map_canvas" style="width=500px"></div> <div id="debug"></div> <script> var gMapsLoaded = false; window.gMapsCallback = function(){     gMapsLoaded = true;     $(window).trigger(' gMapsLoaded'); } window.loadGoogleMaps = function(){     if(gMapsLoaded) return window.gMapsCallback();     var script_tag = document.createElement(' script');     script_tag.setAttribute("type" ,"text/javascript");     script_tag.setAttribute("src", " http://maps.google.com/maps/ api/js?sensor=false&callback= gMapsCallback ");     (document. getElementsByTagName("head")[ 0] || document.documentElement). appendChild(script_tag); } $(document).ready(function(){     function initialize(){         var mapOptions = {             zoom: 8,             center: new google.maps.LatLng(47.3239, 5.0428),             mapTypeId: google.maps.MapTypeId.ROADMAP} ;         map = new goo

elasticsearch with fields

In Model:- require 'elasticsearch/model' class User < ActiveRecord::Base   include Elasticsearch::Model    after_save :reindex_users   before_destroy :reindex_users   settings index: { number_of_shards: 2, number_of_replicas: 0 } do     mapping do           indexes :skills       indexes :country       indexes :developer           end   end   def reindex_users     if self.changed?       self.__elasticsearch__.index_ document       # self.user.__elasticsearch__. index_document        #self.jobbers.__elasticsearch_ _.index_document     end   end   def self.search(skills,developer, country)   __elasticsearch__.search(     {               query: { query_string: {          query: "skills:\"#{skills}\" OR developer:\"#{developer}\"  OR country:\"#{country}\""       }}      }   ) end end In Controller:- @users =  User.search(params[:skills], params[:developer],params[: country]).records