Skip to content

Instantly share code, notes, and snippets.

View sandheepg's full-sized avatar

Sandeep Guduru sandheepg

View GitHub Profile
@sandheepg
sandheepg / 32-64-processor.md
Last active March 8, 2017 05:54
Is my kernel 32-bit or 64-bit ?

Try running the below command in the terminal.

uname -a

or

@sandheepg
sandheepg / nautilus-root.md
Last active March 8, 2017 06:00
Open file browser with root privileges
gksudo nautilus

aletrnatively,

sudo nautilus
@sandheepg
sandheepg / find-text-linux.md
Created March 8, 2017 06:01
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"
@sandheepg
sandheepg / ssh-without-password.md
Last active March 8, 2017 06:12
SSH without password

To access remote machine using SSH

> ssh user@remote-host
> enter password when prompted

To get rid of entering password everytime you try to access, SSH keys has to be exchanged between local machine and remote server.

> ssh-keygen [Enter] [Enter] [Enter]
@sandheepg
sandheepg / wired-connection-issues.md
Last active March 8, 2017 06:15
Device not managed issue with wired connection

In case you have trouble in accessing internet using your wired connection and while troubleshooting, if your network manager says that

"device is not managed"

open the terminal and follow the below steps to fix the issue.

sudo vim /etc/NetworkManager/NetworkManager.conf

change the line managed=false to managed=true
@sandheepg
sandheepg / js-variable-class.md
Created March 8, 2017 06:17
Find class of a variable in Javascript

As we use object.class method in Ruby world, 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
@sandheepg
sandheepg / mysql-select-results.md
Created March 8, 2017 06:18
Formatted select query results in MySQL

To get formatted results for select statements use \G as a suffix for the query.

select * from table_name \G;
@sandheepg
sandheepg / attr-accessor-initialize.md
Created March 8, 2017 06:20
Difference between attr_accessor and initialize in Ruby

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_accessor :name
 
 def initialize age, gender
   @age = age
   self.gender = gender
@sandheepg
sandheepg / terminal-copy-paste.md
Created March 8, 2017 06:49
Copy and paste in terminal

To copy code from the terminal use

  • Cntrl + Insert
  • Rightclick + copy text

To paste code into the terminal use

  • Shift + Insert
  • Rightclick + p
@sandheepg
sandheepg / super-initialize.md
Last active March 8, 2017 07:20
Calling super in initialize method of Ruby
class Person    
    def initialize(name)
        @name = name
    end    
end

class Employee < Person
end