Posts

Showing posts from March, 2015

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

pg socket in ruby on rails

default: &default   adapter: postgresql   pool: 5   username: 'yuva'   password: "12345678"   timeout: 5000 development:   <<: *default   database: artmag_development

add and remove fields in jquery

<div class="my-form">     <form role="form" method="post">         <p class="text-box">             <label for="box1">Box <span class="box-number">1</span></ label>             <input type="text" name="boxes[]" value="" id="box1" />             <a class="add-box" href="#">Add More</a>         </p>         <p><input type="submit" value="Submit" /></p>     </form> </div> <script type="text/javascript"> jQuery(document).ready( function($){     $('.my-form .add-box').click(function(){         var n = $('.text-box').length + 1;         var box_html = $('<p class="text-box"><label for="box' + n + '">Box <span class="box-number">'

undefined method `where' for array in rails

yourarray.inject(User) { |q, str| q.where('approved = ?', true) }

site-enables nginx setting in ruby in rails

/etc/nginx/sites-available/ default # You may add here your # server { # ... # } # statements for each of your virtual hosts to this file ## # You should look at the following URL's in order to grasp a solid understanding # of Nginx configuration files in order to fully unleash the power of Nginx. # http://wiki.nginx.org/Pitfalls # http://wiki.nginx.org/ QuickStart # http://wiki.nginx.org/ Configuration # # Generally, you will want to move this file somewhere, and start with a clean # file but keep this around for reference. Or just disable in sites-enabled. # # Please see /usr/share/doc/nginx-doc/ examples/ for more detailed examples. ## server {       listen 80;       server_name localhost;       root /home/yuva/YuvaSoft/new_ pollutionapi/public;   # <--- be sure to point to 'public'!       passenger_enabled on; # Make site accessible from http://localhost/ # passenger_enabled on; location / { # Fir