Find text in linux files
grep -rnw 'directory' -e "text-to-search"
-r is recursive, -n is line number and -w stands match the whole word.
grep --include={*.c,*.h} -rnw 'directory' -e "pattern"
This will only search through the files which have .c or .h extensions.
grep --exclude=*.o -rnw 'directory' -e "pattern"
Above will exclude searching all the files ending with .o extension.
Related cards:
Check if package is installed in linux
To check if a given package is installed in Debian / Ubuntu, type
dpkg -s <package-name>
To get a neater output use dpkg-query which accepts wildcards as well.
dpkg-query -l <package-name>
In Redhat / Fedora / CentOS use the foll...
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...
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...
Isues w/ caching in Incognito mode
I've noticed that Incognito mode retain cache from the previous session, it just don't collect any new cache while in incognito.
I usually clear the cache/cookies then go into incognito, or run a different browser profile, or a different browser ...
what is ./ and ../ in linux
In linux, we often see the use of ./ or ../ before a file name. Here is the explanation for the same
. Current Directory
.. Parent Directory
./filename # referring to file name in current directory
../filename # referring to file name in p...
escape japaneese text in url
when the file names were actually in japaneese, IE by default will not converting the links from Japanese text to unicode URL format i.e %20. Here is the fix that required
<a href="<%= product.product_image.url) %> ">SOME FILE NAME</a>
CHANGE...
calling super in initialize
class Person
def initialize(name)
@name = name
end
end
class Employee < Person
end
emp = Employee.new # throws error wrong number of arguments
emp = Employee.new("foo") # parent class initialize method is called
cla...
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
add sublime text option to the contextual menu
After installing sublime text, we must be able to open text files with it. Right click on a text file and you must see the option "open with sublime text". In case you don't , click Open with other applications and you should see Sublime text opti...