Find Class of a variable in Javascript
As we have object.class method in Ruby, to check the class of a variable in Javascript, here is the snippet
var ss = "some string";
alert (typeof ss); #=> string
alert (typeof pp); #=> undefined
Related cards:
listing methods of class and object (instance)
class Myclass
def one
puts "one is called"
end
end
ss = Myclass.new
puts Myclass.methods
# returns array of methods for the class. Includes both class and instance methods and methods inherited from parents.
puts Myclass.instanc...
Abstract classes in rails
class AbstractModel < ActiveRecord::Base
self.abstract_class = true
end
class Foo < AbstractModel
end
class Bar < AbstractModel
end
Foo and Bar both inherit properties and methods of the Abstract Model while being in separate tables...
difference between attr_accessor and initialize
attr_accessor is used to create setter and getter methods for instance variables so that they can be accessed outside the class. initialize is the special method in ruby that gets called when an object is instantiated.
class Birthday
attr_ac...
Adobe flash player installation in ubuntu chromium browser
For Chromium browser versions greater than 34, to use flash one must install Pepper flash.
For Ubuntu 14.04 or newer, run
sudo apt-get install pepperflashplugin-nonfree
sudo update-pepperflashplugin-nonfree --status
# to see what version of...
include and extend in ruby
The extend method will mix a module’s methods at the class level.
On the other hand, the include method will mix a module’s methods at the instance level, meaning the methods will become instance methods of the class.
module Stringify
# R...
Class_eval and Instance_eval
class_eval is called on a class object and is used to create instance methods for the class at runtime.
%w(administrator developer teamlead tester).each do |user|
class_eval <<-EOR
def is_#{user}?
site == "MYACCOUNT_#{org.upcase}" ...
detect and select method in ruby
detect method in ruby returns the first item in the collection for which the block returns TRUE and returns nil if it doesn't find any. It has an optional argument containing a proc that calculates a “default” value — that is, the value to return ...
Adobe flash player installation in Ubuntu
This is to install adobe flash player in Ubuntu 14.04 or higher. This works for Firefox browser.
If you have a 32-bit OS, run
sudo apt-get update
sudo apt-get install flashplugin-installer
Make sure each of the commands executed success...
using ack in place of grep
To use Ack, make sure you have Perl installed and run the following commands in Ubuntu
sudo apt-get install ack
sudo apt-get install ack-grep
Now you can use ack-grep command to search for matches in the files
ack-grep -i some-text
#...
deploying wordpress blog in rails application
1.First of all make sure that your server can parse both php and rails application.
-
Make a blog directory in side the public folder of rails application.
-
Deploy all WordPress content inside blog directory.
-
Configure your database conne...