❖
Posts
-
Comments
Given an Array, find number of subsets with K elements, where absolute difference between the maximum and mininmum element is at most X
Problem Given an Array consisting of N integers, we need to find the number of subsets of this Array of size K, where Absolute difference between the Maximum and Minimum element of the subset is at most X.
-
Comments
Automated testing of google autocomplete using cucumber and capybara
Ruby script for automated testing of google autocomplete in HTML form using cucumber and capybara. Add the following script for google autocomplete.
-
Comments
How to manage assets in rails, Difference between app, vendor and lib assets, what is asset pipeline?
What is assets pipeline? In rails asset pipeline offers tools and mechanism to manage assets i.e. JavaScript, css, image, video files. Using it you can pre-process(coffeescript,sass), compress, minify and prepare assets for use by browsers. Problems solved by it Asset pipeline solves problem of multiple requests for each asset by compressing and compiling all alike files into one master file.
-
Comments
Difference between Vanilla.js, JavaScript, ECMAScript, ember.js, node.js
Vanilla.js Vanilla.js is nothing but a name given to the practice of using plain JavaScript without any additional JavaScript libraries as a mockery to remind framework lovers that many things can be done without the need for additional JavaScript libraries.
-
Comments
Swap elements in DOM by drag and drop
Drag and drop is a very common feature. In which you drag an element and drop it somewhere else. Drag and drop is a standard feature in HTML5, You can make any element draggable. Below are the steps on how to achieve the same.
-
Comments
What are the options with which protect_with_forgery is called?
class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception end What happens if the token is missing or wrong depends on the option with which protect_from_forgery method is called. In Rails there are three options: Throw an exception, create a new session or clear the current session.
-
Comments
How to add csrf in Ember app
What if i’m using rails as api, so my frontend is seperated from rails can i still prevent csrf and how? So lets take an example where we use ember for frontend and rails as api. In this case, apart from adding protect_from_forgery in application controller you have to do additional three things. One you have to add the following code in application controller:
-
Comments
Sessions and csrf in rails.
Most apps need to be able to store some data about a user. Maybe it’s a user id, or a preferred language. session is the perfect place to put this kind of data. Little bits of data you want to keep around for more than one request. Sessions are easy to use:
-
Comments
Modules vs Classes in Ruby
A Module is a collection of methods and constants. The methods in a module may be instance methods or module methods. Instance methods appear as methods in a class when the module is included, module methods do not. Conversely, module methods may be called without creating an encapsulating object, while instance methods may not. (See Module#module_function.)
subscribe via RSS